Spaces:
Running
Running
added runtime/env check and api key check
Browse files
src/utils/runtime_selector.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import platform
|
| 2 |
+
import GPUtil
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
load_dotenv()
|
| 5 |
+
|
| 6 |
+
def detect_runtime_environment():
|
| 7 |
+
os_type = platform.system().lower()
|
| 8 |
+
gpus = GPUtil.getGPUs()
|
| 9 |
+
if gpus:
|
| 10 |
+
return "gpu"
|
| 11 |
+
elif os_type in ["darwin", "linux"]:
|
| 12 |
+
return "cpu-local"
|
| 13 |
+
else:
|
| 14 |
+
return "cloud-only"
|