# Optional: use Hugging Face Space SDK = docker (set `sdk: docker` in README.md). # # IMPORTANT: # - If your Space is on CPU hardware, `torch.cuda.is_available()` will be False no matter what. # - If your Space is on GPU hardware, you must use a CUDA-enabled base image (below), # otherwise CUDA won't be visible inside the container. FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ GRADIO_SERVER_NAME=0.0.0.0 \ NVIDIA_VISIBLE_DEVICES=all \ NVIDIA_DRIVER_CAPABILITIES=compute,utility # Python + basic deps RUN apt-get update && apt-get install -y --no-install-recommends \ python3.11 python3.11-venv python3-pip \ git ca-certificates \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN python3.11 -m pip install --upgrade pip && python3.11 -m pip install -r requirements.txt # CUDA-enabled PyTorch (so `torch.cuda.is_available()` is True on GPU Spaces) RUN python3.11 -m pip install --no-cache-dir \ torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 COPY . . EXPOSE 7860 CMD ["python3.11", "app.py"]