Spaces:
Running
Running
alethanhson
commited on
Commit
·
69f1be1
1
Parent(s):
0728e3f
free
Browse files- Dockerfile +1 -1
- app.py +1 -33
- docker-compose.yml +23 -0
Dockerfile
CHANGED
|
@@ -10,4 +10,4 @@ COPY --chown=user ./requirements.txt requirements.txt
|
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 11 |
|
| 12 |
COPY --chown=user . /app
|
| 13 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 10 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 11 |
|
| 12 |
COPY --chown=user . /app
|
| 13 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
|
@@ -58,39 +58,7 @@ async def startup_event():
|
|
| 58 |
logger.warning("GPU not available. Using CPU, performance may be slow!")
|
| 59 |
|
| 60 |
try:
|
| 61 |
-
|
| 62 |
-
logger.info("Attempting to load CSM 1B model...")
|
| 63 |
-
|
| 64 |
-
# Import extra tools that might be needed
|
| 65 |
-
from huggingface_hub import hf_hub_download
|
| 66 |
-
import json
|
| 67 |
-
import os
|
| 68 |
-
|
| 69 |
-
# Try to use an alternative loading method if the direct method fails
|
| 70 |
-
try:
|
| 71 |
-
# First attempt with default loading
|
| 72 |
-
generator = load_csm_1b(device=device)
|
| 73 |
-
except TypeError as e:
|
| 74 |
-
if "missing 1 required positional argument: 'config'" in str(e):
|
| 75 |
-
logger.info("Model requires config. Attempting to load with configuration...")
|
| 76 |
-
|
| 77 |
-
# Try to load the configuration first
|
| 78 |
-
try:
|
| 79 |
-
# The model_path can be model_id or path
|
| 80 |
-
model_id = "sesame/csm-1b"
|
| 81 |
-
# Try to download and load the config
|
| 82 |
-
config_file = hf_hub_download(repo_id=model_id, filename="config.json")
|
| 83 |
-
with open(config_file, 'r') as f:
|
| 84 |
-
config = json.load(f)
|
| 85 |
-
|
| 86 |
-
# Now try loading with config
|
| 87 |
-
generator = load_csm_1b(device=device, config=config)
|
| 88 |
-
except Exception as config_error:
|
| 89 |
-
logger.error(f"Failed to load configuration: {str(config_error)}")
|
| 90 |
-
raise
|
| 91 |
-
else:
|
| 92 |
-
raise
|
| 93 |
-
|
| 94 |
logger.info(f"Model loaded successfully on device: {device}")
|
| 95 |
except Exception as e:
|
| 96 |
logger.error(f"Could not load model: {str(e)}")
|
|
|
|
| 58 |
logger.warning("GPU not available. Using CPU, performance may be slow!")
|
| 59 |
|
| 60 |
try:
|
| 61 |
+
generator = load_csm_1b(device="cuda")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
logger.info(f"Model loaded successfully on device: {device}")
|
| 63 |
except Exception as e:
|
| 64 |
logger.error(f"Could not load model: {str(e)}")
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
csm:
|
| 3 |
+
build:
|
| 4 |
+
context: .
|
| 5 |
+
args:
|
| 6 |
+
- BUILDKIT_INLINE_CACHE=1
|
| 7 |
+
ports:
|
| 8 |
+
- '7860:7860'
|
| 9 |
+
volumes:
|
| 10 |
+
- ./data:/app/data
|
| 11 |
+
- ~/.huggingface:/root/.huggingface
|
| 12 |
+
env_file:
|
| 13 |
+
- .env
|
| 14 |
+
deploy:
|
| 15 |
+
resources:
|
| 16 |
+
reservations:
|
| 17 |
+
devices:
|
| 18 |
+
- driver: nvidia
|
| 19 |
+
count: 1
|
| 20 |
+
capabilities: [gpu]
|
| 21 |
+
environment:
|
| 22 |
+
- HUGGINGFACE_TOKEN=${HUGGINGFACE_TOKEN}
|
| 23 |
+
- PYTHONDONTWRITEBYTECODE=1
|