developer-lunark's picture
Fix Python/pip installation in CUDA image
eee63a4 verified
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
WORKDIR /app
# Fix environment variables
ENV OMP_NUM_THREADS=4
ENV MKL_NUM_THREADS=4
ENV DEBIAN_FRONTEND=noninteractive
ENV PATH="/usr/local/bin:$PATH"
# Install Python 3.11 and pip properly
RUN apt-get update && apt-get install -y \
software-properties-common \
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install -y \
python3.11 \
python3.11-venv \
python3.11-distutils \
curl \
git \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/python3.11 /usr/bin/python \
&& ln -sf /usr/bin/python3.11 /usr/bin/python3 \
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy app
COPY . .
# Create user for HF Space
RUN useradd -m -u 1000 user
USER user
# Set HF cache directory
ENV HF_HOME=/tmp/huggingface
# Expose port
EXPOSE 7860
# Run app
CMD ["python", "app.py"]