Alessio Grancini
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -13,32 +13,29 @@ from point_cloud_generator import display_pcd
|
|
13 |
|
14 |
|
15 |
|
|
|
16 |
import subprocess
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
# Check
|
19 |
-
|
20 |
-
|
21 |
-
# Run nvidia-smi to check for GPU
|
22 |
-
gpu_check = subprocess.run(["nvidia-smi"], capture_output=True, text=True)
|
23 |
-
if "NVIDIA-SMI" in gpu_check.stdout:
|
24 |
-
print("β
GPU is available!")
|
25 |
-
return True
|
26 |
-
else:
|
27 |
-
print("β No GPU detected!")
|
28 |
-
return False
|
29 |
-
except FileNotFoundError:
|
30 |
-
print("β No nvidia-smi found! GPU likely unavailable.")
|
31 |
-
return False
|
32 |
-
|
33 |
-
# Set device based on GPU availability
|
34 |
-
if check_gpu() and torch.cuda.is_available():
|
35 |
-
print(f"β
CUDA available: {torch.cuda.get_device_name(0)}")
|
36 |
-
device = torch.device("cuda")
|
37 |
-
torch.cuda.empty_cache()
|
38 |
else:
|
39 |
-
print("β No
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
|
|
|
13 |
|
14 |
|
15 |
|
16 |
+
import torch
|
17 |
import subprocess
|
18 |
+
import os
|
19 |
+
|
20 |
+
# Check if CUDA is available in PyTorch
|
21 |
+
print(f"π PyTorch CUDA Available: {torch.cuda.is_available()}")
|
22 |
|
23 |
+
# Check available CUDA devices
|
24 |
+
if torch.cuda.is_available():
|
25 |
+
print(f"β
GPU detected: {torch.cuda.get_device_name(0)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
else:
|
27 |
+
print("β No GPU detected by PyTorch!")
|
28 |
+
|
29 |
+
# Check `nvidia-smi` output (if NVIDIA GPU is assigned)
|
30 |
+
try:
|
31 |
+
gpu_check = subprocess.run(["nvidia-smi"], capture_output=True, text=True)
|
32 |
+
print(f"π₯οΈ nvidia-smi output:\n{gpu_check.stdout}")
|
33 |
+
except FileNotFoundError:
|
34 |
+
print("β nvidia-smi not found! GPU might not be assigned.")
|
35 |
+
|
36 |
+
# Check if Hugging Face assigned a GPU
|
37 |
+
hf_gpu_env = os.getenv("CUDA_VISIBLE_DEVICES")
|
38 |
+
print(f"π Hugging Face CUDA_VISIBLE_DEVICES: {hf_gpu_env}")
|
39 |
|
40 |
|
41 |
|