Alessio Grancini commited on
Commit
85008f7
·
verified ·
1 Parent(s): 6ea8a1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -19
app.py CHANGED
@@ -14,26 +14,12 @@ from point_cloud_generator import display_pcd
14
  import os
15
  import torch
16
 
17
- # Disable NVML initialization to avoid errors in Hugging Face Spaces
18
- os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
19
- os.environ["TORCH_CUDA_ARCH_LIST"] = ""
20
- os.environ["CUDA_VISIBLE_DEVICES"] = "0" if torch.cuda.is_available() else "-1"
21
-
22
-
23
- # Ensure CUDA is properly initialized
24
  try:
25
- if torch.cuda.is_available():
26
- print(f" CUDA is available: {torch.cuda.get_device_name(0)}")
27
- torch.cuda.init()
28
- torch.cuda.empty_cache()
29
- device = torch.device("cuda")
30
- else:
31
- print("❌ No CUDA available. Falling back to CPU.")
32
- os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
33
- device = torch.device("cpu")
34
- except RuntimeError as e:
35
- print(f"🚨 CUDA initialization failed: {e}. Switching to CPU mode.")
36
- os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
37
  device = torch.device("cpu")
38
 
39
 
 
14
  import os
15
  import torch
16
 
17
+ # Let ZeroGPU handle initialization
 
 
 
 
 
 
18
  try:
19
+ device = torch.device("cuda" if spaces.is_gpu_available() else "cpu")
20
+ print(f"🔹 Running inference on {device}")
21
+ except Exception as e:
22
+ print(f"❌ ZeroGPU failed to initialize: {e}")
 
 
 
 
 
 
 
 
23
  device = torch.device("cpu")
24
 
25