Huiwenshi commited on
Commit
cb4a765
1 Parent(s): 8590074

Upload app_hg.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app_hg.py +26 -1
app_hg.py CHANGED
@@ -28,7 +28,6 @@ import warnings
28
  import argparse
29
  import gradio as gr
30
  from glob import glob
31
- print(glob("/usr/local/cuda*"))
32
  import shutil
33
  import torch
34
  import numpy as np
@@ -52,6 +51,32 @@ parser.add_argument("--save_memory", default=True) # , action="store_true")
52
  parser.add_argument("--device", default="cuda:0", type=str)
53
  args = parser.parse_args()
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  def download_models():
56
  # Create weights directory if it doesn't exist
57
  os.makedirs("weights", exist_ok=True)
 
28
  import argparse
29
  import gradio as gr
30
  from glob import glob
 
31
  import shutil
32
  import torch
33
  import numpy as np
 
51
  parser.add_argument("--device", default="cuda:0", type=str)
52
  args = parser.parse_args()
53
 
54
+ def find_cuda():
55
+ # Check if CUDA_HOME or CUDA_PATH environment variables are set
56
+ cuda_home = os.environ.get('CUDA_HOME') or os.environ.get('CUDA_PATH')
57
+
58
+ if cuda_home and os.path.exists(cuda_home):
59
+ return cuda_home
60
+
61
+ # Search for the nvcc executable in the system's PATH
62
+ nvcc_path = shutil.which('nvcc')
63
+
64
+ if nvcc_path:
65
+ # Remove the 'bin/nvcc' part to get the CUDA installation path
66
+ cuda_path = os.path.dirname(os.path.dirname(nvcc_path))
67
+ return cuda_path
68
+
69
+ return None
70
+
71
+ cuda_path = find_cuda()
72
+
73
+ if cuda_path:
74
+ print(f"CUDA installation found at: {cuda_path}")
75
+ else:
76
+ print("CUDA installation not found")
77
+
78
+
79
+
80
  def download_models():
81
  # Create weights directory if it doesn't exist
82
  os.makedirs("weights", exist_ok=True)