Skip to content

Commit

Permalink
Improve GPU handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Dicklesworthstone committed Jun 3, 2024
1 parent b42322d commit 7664946
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions shared_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import asyncio
import urllib.request
import os
import nvgpu
import glob
import json
from filelock import FileLock, Timeout
Expand All @@ -17,7 +16,11 @@
from decouple import config
from fastapi import HTTPException
from apscheduler.schedulers.asyncio import AsyncIOScheduler

try:
import nvgpu
GPU_AVAILABLE = True
except ImportError:
GPU_AVAILABLE = False
logger = setup_logger()

embedding_model_cache = {} # Model cache to store loaded models
Expand Down Expand Up @@ -45,6 +48,14 @@
scheduler.start()

def is_gpu_available():
if not GPU_AVAILABLE:
return {
"gpu_found": False,
"num_gpus": 0,
"first_gpu_vram": 0,
"total_vram": 0,
"error": "nvgpu module not found"
}
try:
gpu_info = nvgpu.gpu_info()
num_gpus = len(gpu_info)
Expand Down

0 comments on commit 7664946

Please sign in to comment.