abreza commited on
Commit
ae51641
·
1 Parent(s): 8a51f4e
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -88,20 +88,28 @@ model_option = gr.Radio(options, value="dino16",
88
  label='Choose a backbone to upsample')
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  @spaces.GPU(duration=120)
92
  def upsample_features(image, model_option):
93
  with torch.no_grad():
94
  from setuptools import setup, find_packages
95
  from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
96
 
97
- cuda_available = torch.cuda.is_available()
98
- cuda_version = torch.version.cuda
99
-
100
- if cuda_available:
101
- print(f"CUDA is available. CUDA Version: {cuda_version}")
102
- print(f"CUDA Device Name: {torch.cuda.get_device_name(0)}")
103
- else:
104
- print("CUDA is not available.")
105
 
106
  setup(
107
  name='featup',
 
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)
104
  def upsample_features(image, model_option):
105
  with torch.no_grad():
106
  from setuptools import setup, find_packages
107
  from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
108
 
109
+ cuda_home = find_cuda_home()
110
+ if cuda_home:
111
+ print(cuda_home)
112
+ os.environ['CUDA_HOME'] = cuda_home
 
 
 
 
113
 
114
  setup(
115
  name='featup',