This commit is contained in:
Yuhong Sun 2024-08-20 14:06:49 -07:00
parent 5053f4e383
commit 8de04acb7f
3 changed files with 14 additions and 5 deletions

View File

@ -2,4 +2,7 @@
<allow
until="DATE_REPLACEMENT"
comment="We need to be able to create/delete indices for swapping models">schema-removal</allow>
<allow
until="DATE_REPLACEMENT"
comment="We need to be able to update the schema for updates to the Danswer schema">indexing-change</allow>
</validation-overrides>

View File

@ -54,9 +54,11 @@ def _move_files_recursively(source: Path, dest: Path, overwrite: bool = False) -
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator:
if torch.cuda.is_available():
logger.notice("GPU is available")
logger.notice("CUDA GPU is available")
elif torch.backends.mps.is_available():
logger.notice("Mac MPS is available")
else:
logger.notice("GPU is not available")
logger.notice("GPU is not available, using CPU")
if TEMP_HF_CACHE_PATH.is_dir():
logger.notice("Moving contents of temp_huggingface to huggingface cache.")

View File

@ -11,6 +11,10 @@ def healthcheck() -> Response:
@router.get("/gpu-status")
def gpu_status() -> dict[str, bool]:
has_gpu = torch.cuda.is_available()
return {"gpu_available": has_gpu}
def gpu_status() -> dict[str, bool | str]:
if torch.cuda.is_available():
return {"gpu_available": True, "type": "cuda"}
elif torch.backends.mps.is_available():
return {"gpu_available": True, "type": "mps"}
else:
return {"gpu_available": False, "type": "none"}