Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,14 @@ from huggingface_hub import login
|
|
| 4 |
import os
|
| 5 |
import gradio as gr
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Retrieve the token from the environment variable
|
| 8 |
token = os.getenv("HF_TOKEN") # Hugging Face token from the secret
|
| 9 |
if token:
|
|
|
|
| 4 |
import os
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
# Check for GPU availability and set device accordingly
|
| 8 |
+
if torch.cuda.is_available():
|
| 9 |
+
device = "cuda"
|
| 10 |
+
print("GPU is available")
|
| 11 |
+
else:
|
| 12 |
+
device = "cpu"
|
| 13 |
+
print("GPU is not available, using CPU")
|
| 14 |
+
|
| 15 |
# Retrieve the token from the environment variable
|
| 16 |
token = os.getenv("HF_TOKEN") # Hugging Face token from the secret
|
| 17 |
if token:
|