Spaces:
Running
on
L40S
Running
on
L40S
Upload app_hg.py with huggingface_hub
Browse files
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 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|