hf1024 commited on
Commit
c305aff
·
verified ·
1 Parent(s): ea29378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -6,6 +6,7 @@ from requests.exceptions import RequestException
6
  import os
7
  import logging
8
  import json
 
9
 
10
  # 配置日志
11
  logging.basicConfig(level=logging.INFO)
@@ -14,6 +15,11 @@ logger = logging.getLogger(__name__)
14
  app = FastAPI()
15
  XAI_API_BASE = "https://api.x.ai/v1"
16
 
 
 
 
 
 
17
  class ChatRequest(BaseModel):
18
  messages: list[dict] = Field(..., description="消息列表")
19
  model: str = Field(..., description="模型ID")
 
6
  import os
7
  import logging
8
  import json
9
+ import GPUtil
10
 
11
  # 配置日志
12
  logging.basicConfig(level=logging.INFO)
 
15
  app = FastAPI()
16
  XAI_API_BASE = "https://api.x.ai/v1"
17
 
18
+ cuda_available = True if len(GPUtil.getGPUs()) else False
19
+ if cuda_available:
20
+ print(GPUtil.getGPUs()[0].name)
21
+ print(cuda_available)
22
+
23
  class ChatRequest(BaseModel):
24
  messages: list[dict] = Field(..., description="消息列表")
25
  model: str = Field(..., description="模型ID")