jcrissa commited on
Commit
8c8d3a9
·
verified ·
1 Parent(s): 21944f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -2,22 +2,30 @@ import gradio as grad
2
  import torch
3
  from unsloth import FastLanguageModel
4
  from transformers import AutoTokenizer
5
-
 
6
  import os
7
- if os.environ.get("SPACES_ZERO_GPU") is not None:
8
- import spaces
9
- else:
10
- class spaces:
11
- @staticmethod
12
- def GPU(func):
13
- def wrapper(*args, **kwargs):
14
- return func(*args, **kwargs)
15
- return wrapper
16
-
17
- @spaces.GPU
18
- def fake_gpu():
19
- pass
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  # Load your fine-tuned Phi-3 model from Hugging Face
22
  MODEL_NAME = "jcrissa/phi3-new-t2i"
23
 
 
2
  import torch
3
  from unsloth import FastLanguageModel
4
  from transformers import AutoTokenizer
5
+ import spaces
6
+ import subprocess
7
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ def install_cuda_toolkit():
10
+ # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
11
+ CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
12
+ CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
13
+ subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
14
+ subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
15
+ subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
16
+
17
+ os.environ["CUDA_HOME"] = "/usr/local/cuda"
18
+ os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
19
+ os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
20
+ os.environ["CUDA_HOME"],
21
+ "" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
22
+ )
23
+ # Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
24
+ os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
25
+
26
+ install_cuda_toolkit()
27
+
28
+ device = "cuda" if torch.cuda.is_available() else "cpu"
29
  # Load your fine-tuned Phi-3 model from Hugging Face
30
  MODEL_NAME = "jcrissa/phi3-new-t2i"
31