abreza commited on
Commit
00db828
1 Parent(s): 63b27a9
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -88,16 +88,12 @@ model_option = gr.Radio(options, value="dino16",
88
  label='Choose a backbone to upsample')
89
 
90
 
91
- def find_cuda_home():
92
  try:
93
- output = subprocess.check_output(['nvcc', '--version']).decode()
94
- print(output)
95
- for line in output.split('\n'):
96
- if 'Cuda compilation tools' in line:
97
- version = line.split()[-1]
98
- return f"/usr/local/cuda-{version.split('.')[0]}.{version.split('.')[1]}"
99
- except Exception as e:
100
- print(f"Error finding CUDA_HOME: {e}")
101
  return None
102
 
103
  @spaces.GPU(duration=120)
@@ -107,10 +103,11 @@ def upsample_features(image, model_option):
107
  from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
108
 
109
  print(subprocess.check_output(['ls', '/usr/local/']).decode())
110
- cuda_home = find_cuda_home()
111
- if cuda_home:
112
- print(cuda_home)
113
- os.environ['CUDA_HOME'] = cuda_home
 
114
 
115
  setup(
116
  name='featup',
 
88
  label='Choose a backbone to upsample')
89
 
90
 
91
+ def find_nvcc():
92
  try:
93
+ result = subprocess.check_output(['find', '/', '-name', 'nvcc', '2>/dev/null'], stderr=subprocess.STDOUT, text=True, shell=True)
94
+ return result.strip()
95
+ except subprocess.CalledProcessError as e:
96
+ print(f"Error occurred: {e}")
 
 
 
 
97
  return None
98
 
99
  @spaces.GPU(duration=120)
 
103
  from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
104
 
105
  print(subprocess.check_output(['ls', '/usr/local/']).decode())
106
+ nvcc_path = find_nvcc()
107
+ if nvcc_path:
108
+ print(f"CUDA 'nvcc' found at: {nvcc_path}")
109
+ else:
110
+ print("CUDA 'nvcc' not found.")
111
 
112
  setup(
113
  name='featup',