-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (25 loc) · 764 Bytes
/
app.py
File metadata and controls
34 lines (25 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from pathlib import Path
import glob
import os
from fastapi import FastAPI
app = FastAPI()
def read_file(path: str):
try:
return Path(path).read_text(encoding="utf-8").strip()
except FileNotFoundError:
return None
@app.get("/health")
def health():
return {"ok": True}
@app.get("/")
def index():
return {
"message": "hello from ecs managed instances",
"gpu": {
"visibleDevicesEnv": os.getenv("NVIDIA_VISIBLE_DEVICES"),
"deviceFiles": sorted(glob.glob("/dev/nvidia*")),
"procGpus": sorted(glob.glob("/proc/driver/nvidia/gpus/*")),
"driverVersion": read_file("/proc/driver/nvidia/version"),
"cudaVersion": os.getenv("CUDA_VERSION"),
},
}