-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect GPU on startup for default multi-pass indexing value (#2242)
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
from retry import retry | ||
|
||
from danswer.utils.logger import setup_logger | ||
from shared_configs.configs import INDEXING_MODEL_SERVER_HOST | ||
from shared_configs.configs import INDEXING_MODEL_SERVER_PORT | ||
from shared_configs.configs import MODEL_SERVER_HOST | ||
from shared_configs.configs import MODEL_SERVER_PORT | ||
|
||
logger = setup_logger() | ||
|
||
|
||
@retry(tries=5, delay=5) | ||
def gpu_status_request(indexing: bool = True) -> bool: | ||
if indexing: | ||
model_server_url = f"{INDEXING_MODEL_SERVER_HOST}:{INDEXING_MODEL_SERVER_PORT}" | ||
else: | ||
model_server_url = f"{MODEL_SERVER_HOST}:{MODEL_SERVER_PORT}" | ||
|
||
if "http" not in model_server_url: | ||
model_server_url = f"http://{model_server_url}" | ||
|
||
try: | ||
response = requests.get(f"{model_server_url}/api/gpu-status", timeout=10) | ||
response.raise_for_status() | ||
gpu_status = response.json() | ||
return gpu_status["gpu_available"] | ||
except requests.RequestException as e: | ||
logger.error(f"Error: Unable to fetch GPU status. Error: {str(e)}") | ||
raise # Re-raise exception to trigger a retry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters