Huiwenshi commited on
Commit
d8a4d80
1 Parent(s): c8486ac

Upload app_hg.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app_hg.py +31 -13
app_hg.py CHANGED
@@ -39,19 +39,37 @@ 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
- subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/NVlabs/nvdiffrast.git"])
52
- import nvdiffrast
53
-
54
- check_env()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  from infer import seed_everything, save_gif
57
  from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer
 
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
75
  from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer