Spaces:
Runtime error
Runtime error
cyborg-ai-git
commited on
Commit
Β·
990e99a
1
Parent(s):
68ca12e
add gpu
Browse files- README.md +5 -5
- ai-comic-factory +0 -1
- app.py +5 -7
- requirements.txt +0 -3
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
|
|
1 |
---
|
2 |
+
title: Zero Gpu Demo
|
3 |
+
emoji: π’
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: green
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.7.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: apache-2.0
|
ai-comic-factory
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
Subproject commit 11cdf4a219763f65eb38eb8f692a0f94eb973b43
|
|
|
|
app.py
CHANGED
@@ -5,8 +5,6 @@ import subprocess
|
|
5 |
import torch
|
6 |
import gradio as gr
|
7 |
|
8 |
-
|
9 |
-
|
10 |
CUSTOM_CSS = """
|
11 |
#output_box textarea {
|
12 |
font-family: IBM Plex Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
@@ -18,7 +16,7 @@ print(zero.device) # <-- 'cpu' π€
|
|
18 |
|
19 |
@spaces.GPU
|
20 |
def run_gpu() -> str:
|
21 |
-
print(zero.device) # <-- 'cuda:0'
|
22 |
output: str = ""
|
23 |
try:
|
24 |
output = subprocess.check_output(["nvidia-smi"], text=True)
|
@@ -36,19 +34,19 @@ def run(check: bool) -> str:
|
|
36 |
comment = (
|
37 |
datetime.datetime.now().replace(microsecond=0).isoformat().replace("T", " ")
|
38 |
)
|
39 |
-
return f"# {comment}"
|
40 |
|
41 |
output = gr.Textbox(
|
42 |
label="Command Output", max_lines=32, elem_id="output_box", value=run(False)
|
43 |
)
|
44 |
|
45 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
46 |
-
|
47 |
|
48 |
output.render()
|
49 |
|
50 |
-
check = gr.Checkbox(label="Run")
|
51 |
|
52 |
check.change(run, inputs=[check], outputs=output, every=1)
|
53 |
|
54 |
-
demo.queue().launch(show_api=
|
|
|
5 |
import torch
|
6 |
import gradio as gr
|
7 |
|
|
|
|
|
8 |
CUSTOM_CSS = """
|
9 |
#output_box textarea {
|
10 |
font-family: IBM Plex Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
|
16 |
|
17 |
@spaces.GPU
|
18 |
def run_gpu() -> str:
|
19 |
+
print(zero.device) # <-- 'cuda:0' π€
|
20 |
output: str = ""
|
21 |
try:
|
22 |
output = subprocess.check_output(["nvidia-smi"], text=True)
|
|
|
34 |
comment = (
|
35 |
datetime.datetime.now().replace(microsecond=0).isoformat().replace("T", " ")
|
36 |
)
|
37 |
+
return f"# {comment}\n\nThis is running on CPU\n\nClick on 'Run on GPU' below to move to GPU instantly and run nvidia-smi"
|
38 |
|
39 |
output = gr.Textbox(
|
40 |
label="Command Output", max_lines=32, elem_id="output_box", value=run(False)
|
41 |
)
|
42 |
|
43 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
44 |
+
gr.Markdown("#### `zero-gpu`: how to run on serverless GPU for free on Spaces π₯")
|
45 |
|
46 |
output.render()
|
47 |
|
48 |
+
check = gr.Checkbox(label="Run on GPU")
|
49 |
|
50 |
check.change(run, inputs=[check], outputs=output, every=1)
|
51 |
|
52 |
+
demo.queue().launch(show_api=False)
|
requirements.txt
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
torch
|
2 |
-
torchvision
|
3 |
-
torchaudio
|
|
|
|
|
|
|
|