Spaces:
Runtime error
Runtime error
ljy266987
commited on
Commit
•
9d8bdfd
1
Parent(s):
9540f3e
try
Browse files
app.py
CHANGED
@@ -13,9 +13,21 @@ import subprocess
|
|
13 |
result = subprocess.run(
|
14 |
['nvidia-smi'], text=True
|
15 |
)
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
import torch
|
|
|
|
|
18 |
|
|
|
|
|
|
|
|
|
|
|
19 |
# 检查CUDA是否可用
|
20 |
if torch.cuda.is_available():
|
21 |
print("CUDA is available. Listing available GPUs:")
|
@@ -31,19 +43,6 @@ else:
|
|
31 |
|
32 |
##
|
33 |
|
34 |
-
import spaces
|
35 |
-
from threading import Thread
|
36 |
-
from typing import Iterator
|
37 |
-
|
38 |
-
import gradio as gr
|
39 |
-
import torch
|
40 |
-
from modelscope import AutoModelForCausalLM, AutoTokenizer
|
41 |
-
from transformers import TextIteratorStreamer
|
42 |
-
|
43 |
-
MAX_MAX_NEW_TOKENS = 2048
|
44 |
-
DEFAULT_MAX_NEW_TOKENS = 1024
|
45 |
-
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
46 |
-
|
47 |
|
48 |
if not torch.cuda.is_available():
|
49 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|
|
|
13 |
result = subprocess.run(
|
14 |
['nvidia-smi'], text=True
|
15 |
)
|
16 |
+
|
17 |
+
import spaces
|
18 |
+
from threading import Thread
|
19 |
+
from typing import Iterator
|
20 |
+
|
21 |
+
import gradio as gr
|
22 |
import torch
|
23 |
+
from modelscope import AutoModelForCausalLM, AutoTokenizer
|
24 |
+
from transformers import TextIteratorStreamer
|
25 |
|
26 |
+
MAX_MAX_NEW_TOKENS = 2048
|
27 |
+
DEFAULT_MAX_NEW_TOKENS = 1024
|
28 |
+
MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
29 |
+
|
30 |
+
##
|
31 |
# 检查CUDA是否可用
|
32 |
if torch.cuda.is_available():
|
33 |
print("CUDA is available. Listing available GPUs:")
|
|
|
43 |
|
44 |
##
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
if not torch.cuda.is_available():
|
48 |
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
|