# Base image with CUDA support FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04 # Set environment variables ENV PYTHONUNBUFFERED=1 \ DEBIAN_FRONTEND=noninteractive \ CUDA_HOME=/usr/local/cuda \ PATH=/usr/local/cuda/bin:$PATH \ LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ python3-pip \ python3-dev \ build-essential \ curl \ ffmpeg \ libsndfile1 \ && rm -rf /var/lib/apt/lists/* # Upgrade pip and install build tools RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel # Install PyTorch separately first RUN pip3 install --no-cache-dir \ torch==2.4.1 \ torchaudio==2.4.1 \ torchvision==0.19.1 \ --extra-index-url https://download.pytorch.org/whl/cu121 # Set up working directory WORKDIR /app # Copy requirements first to leverage Docker cache COPY requirements.txt . # Modify requirements to remove PyTorch packages RUN sed -i '/^torch==/d; /^torchaudio==/d; /^torchvision==/d; /^torchdata==/d' requirements.txt # Install remaining Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Copy the rest of your application COPY . . # Verify GPU setup RUN python3 -c "import torch; assert torch.cuda.is_available(), 'CUDA not available'" # Expose port EXPOSE 8000 # Start the application CMD ["python3", "server.py"]