Huiwenshi commited on
Commit
50ce844
1 Parent(s): 7e3f404

Upload app_hg.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app_hg.py +30 -30
app_hg.py CHANGED
@@ -39,36 +39,36 @@ import sys
39
  import subprocess
40
  from glob import glob
41
 
42
- @spaces.GPU
43
- def check_env():
44
- print(glob("/usr/local/cuda/*"))
45
- print(torch.cuda.is_available())
46
- print(os.environ.get('CUDA_HOME', None))
47
- os.environ['CUDA_HOME'] = '/usr/local/cuda'
48
- # Optionally, update PATH and LD_LIBRARY_PATH if needed
49
- os.environ['PATH'] = os.environ['CUDA_HOME'] + '/bin:' + os.environ['PATH']
50
- os.environ['LD_LIBRARY_PATH'] = os.environ['CUDA_HOME'] + '/lib64:' + os.environ.get('LD_LIBRARY_PATH', '')
51
-
52
- check_env()
53
-
54
- # def install_cuda_toolkit():
55
- # # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
56
- # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
57
- # CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
58
- # subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
59
- # subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
60
- # subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
61
-
62
- # os.environ["CUDA_HOME"] = "/usr/local/cuda"
63
- # os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
64
- # os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
65
- # os.environ["CUDA_HOME"],
66
- # "" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
67
- # )
68
- # # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
69
- # os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
70
-
71
- # install_cuda_toolkit()
72
 
73
 
74
  from infer import seed_everything, save_gif
 
39
  import subprocess
40
  from glob import glob
41
 
42
+ # @spaces.GPU
43
+ # def check_env():
44
+ # print(glob("/usr/local/cuda/*"))
45
+ # print(torch.cuda.is_available())
46
+ # print(os.environ.get('CUDA_HOME', None))
47
+ # os.environ['CUDA_HOME'] = '/usr/local/cuda'
48
+ # # Optionally, update PATH and LD_LIBRARY_PATH if needed
49
+ # os.environ['PATH'] = os.environ['CUDA_HOME'] + '/bin:' + os.environ['PATH']
50
+ # os.environ['LD_LIBRARY_PATH'] = os.environ['CUDA_HOME'] + '/lib64:' + os.environ.get('LD_LIBRARY_PATH', '')
51
+
52
+ # check_env()
53
+
54
+ def install_cuda_toolkit():
55
+ # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
56
+ CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
57
+ CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
58
+ subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
59
+ subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
60
+ subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
61
+
62
+ os.environ["CUDA_HOME"] = "/usr/local/cuda"
63
+ os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
64
+ os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
65
+ os.environ["CUDA_HOME"],
66
+ "" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
67
+ )
68
+ # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
69
+ os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
70
+
71
+ install_cuda_toolkit()
72
 
73
 
74
  from infer import seed_everything, save_gif