gen3c / start.sh
elungky's picture
Configure Space to run GEN3C FastAPI inference server
8d604f9
raw
history blame
1.31 kB
#!/bin/bash
set -eux # Keep this for debugging and seeing command execution
export CUDA_VISIBLE_DEVICES="0"
export CUDA_HOME="/usr/local/cuda" # Robust CUDA_HOME for Docker environment
export PYTHONPATH="/app" # Set Python path to the app root
echo "Starting GEN3C FastAPI inference server..."
# Set environment variables as per GEN3C guide
# Assuming 'checkpoints' folder is directly under '/app'
export GEN3C_CKPT_PATH="/app/checkpoints"
export GEN3C_GPU_COUNT=1 # Explicitly use 1 GPU for A100 instance
# Navigate to the 'gui' directory where server.py resides, if necessary
# The current directory is /app, and server.py is at /app/gui/api/server.py
# So we need to ensure the path is correct from /app
# Or, you can CD into the directory: cd gui
# For now, let's keep the path explicit.
# Start the FastAPI server
# Using 'uvicorn' directly is often preferred over 'fastapi dev' for deployment,
# as 'fastapi dev' is more for development with auto-reload.
# 'uvicorn' is typically installed with 'fastapi[standard]' or 'uvicorn[standard]'
# The format is 'uvicorn <module>:<app_instance>'
# So if server.py has 'app = FastAPI()', it's 'gui.api.server:app'
# We need to bind to 0.0.0.0 and port 7860 for HF Spaces
exec uvicorn gui.api.server:app --host 0.0.0.0 --port 7860 --proxy-headers