# Use NVIDIA CUDA base image FROM nvidia/cuda:11.8.0-devel-ubuntu20.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 # Install system dependencies RUN apt-get update && apt-get install -y \ python3.9 \ python3.9-dev \ python3-pip \ ffmpeg \ git \ wget \ curl \ && rm -rf /var/lib/apt/lists/* # Create symlinks for python RUN ln -s /usr/bin/python3.9 /usr/bin/python # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user # Switch to the "user" user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR $HOME/app # Upgrade pip RUN python -m pip install --no-cache-dir --upgrade pip # Copy requirements file COPY --chown=user requirements.txt . # Install other Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Install PyTorch with CUDA support first RUN pip install --no-cache-dir \ torch==2.0.1+cu118 \ torchvision==0.15.2+cu118 \ torchaudio==2.0.2+cu118 \ -f https://download.pytorch.org/whl/torch_stable.html # Copy the application code COPY --chown=user . . # Expose the port EXPOSE 7860 # Run the application CMD ["python", "unified_socket_server.py", "--host", "0.0.0.0", "--port", "7860"]