Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files123456789101112135 unmodified lines1920212223242526272829303132333435363738394041424344454647484950511 unmodified line53545556575859606162636465666768697071727374757677787980818283848586# Use the NVIDIA CUDA runtime as a base image (MATCHING PyTorch)FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04# Set environment variablesENV DEBIAN_FRONTEND=noninteractive# Create a non-root userRUN useradd -m -u 1000 user# Install system dependencies as rootRUN apt-get update && apt-get install -y --no-install-recommends \git \cmake \5 unmodified linespython3.9 \python3-pip \python3.9-dev \python3.9-venv \&& rm -rf /var/lib/apt/lists/*# Set Python 3.9 as the default python and pip versionsRUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1# Switch to non-root userUSER user# Create virtual environmentRUN python -m venv /home/user/venvENV VIRTUAL_ENV=/home/user/venvENV PATH="$VIRTUAL_ENV/bin:$PATH"# Explicitly set CUDA and PyTorch environment variablesENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6"ENV FORCE_CUDA=1# Correct CUDA paths to ensure visibilityENV CUDA_HOME=/usr/local/cudaENV PATH=${CUDA_HOME}/bin:${PATH}ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}# Set home to the user's home directoryENV HOME=/home/user \PYTHONPATH=$HOME/app \PYTHONUNBUFFERED=1 \GRADIO_ALLOW_FLAGGING=never \GRADIO_NUM_PORTS=1 \1 unmodified lineGRADIO_THEME=huggingface \SYSTEM=spaces# Set working directoryWORKDIR $HOME/app# Upgrade pip and install numpy<2 firstRUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir "numpy<2"# 🔥 Install PyTorch inside and outside virtualenv to prevent CUDA issuesRUN pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 && \python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA Available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0))"# Clone the repositoryRUN git clone --recursive https://github.com/jnjaby/KEEP.git .# Copy application filesCOPY app.py .COPY requirements_HF.txt .# Install Python dependenciesRUN pip install --no-cache-dir -r requirements_HF.txtRUN pip install --no-cache-dir gradio ffmpeg-python dlib-bin basicsr# Set CUDA device settingsENV CUDA_DEVICE_ORDER=PCI_BUS_IDENV CUDA_VISIBLE_DEVICES=0# Verify CUDA after all installs (Debugging Step)RUN python -c "import torch; print('Final Check - CUDA Available:', torch.cuda.is_available())"# Command to run the applicationCMD ["python", "app.py"]12345678910115 unmodified lines17181920212223242526272829303132333435363738394041421 unmodified line4445464748495051525354555657585960616263FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04ENV DEBIAN_FRONTEND=noninteractive# Create non-root userRUN useradd -m -u 1000 user# Install system dependenciesRUN apt-get update && apt-get install -y --no-install-recommends \git \cmake \5 unmodified linespython3.9 \python3-pip \python3.9-dev \&& rm -rf /var/lib/apt/lists/*# Set Python 3.9 as defaultRUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1# Switch to non-root userUSER user# Set CUDA and environment variablesENV CUDA_HOME=/usr/local/cudaENV PATH=${CUDA_HOME}/bin:${PATH}ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6"ENV FORCE_CUDA=1ENV CUDA_DEVICE_ORDER=PCI_BUS_IDENV CUDA_VISIBLE_DEVICES=0ENV HOME=/home/user \PYTHONPATH=/home/user/app \PYTHONUNBUFFERED=1 \GRADIO_ALLOW_FLAGGING=never \GRADIO_NUM_PORTS=1 \1 unmodified lineGRADIO_THEME=huggingface \SYSTEM=spacesWORKDIR $HOME/app# Upgrade pip and install numpy, then PyTorchRUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir "numpy<2" && \pip install --no-cache-dir torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 && \python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA Available:', torch.cuda.is_available())"# Clone repository and install dependenciesRUN git clone --recursive https://github.com/jnjaby/KEEP.git .COPY app.py .COPY requirements_HF.txt .RUN pip install --no-cache-dir -r requirements_HF.txt && \pip install --no-cache-dir gradio ffmpeg-python dlib-bin basicsrCMD ["python", "app.py"]
Dockerfile+16-39