Spaces:
Build error
Build error
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +70 -0
Dockerfile
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
|
| 2 |
+
|
| 3 |
+
# Set environment variables
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
ENV PYTHONUNBUFFERED=1
|
| 6 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 7 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 8 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib
|
| 9 |
+
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
|
| 10 |
+
|
| 11 |
+
# Create necessary directories with proper permissions
|
| 12 |
+
RUN mkdir -p /app/.cache/huggingface/transformers && \
|
| 13 |
+
mkdir -p /tmp/matplotlib && \
|
| 14 |
+
chmod -R 777 /app && \
|
| 15 |
+
chmod -R 777 /tmp/matplotlib
|
| 16 |
+
|
| 17 |
+
# Install system dependencies
|
| 18 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 19 |
+
build-essential \
|
| 20 |
+
git \
|
| 21 |
+
curl \
|
| 22 |
+
ca-certificates \
|
| 23 |
+
python3-pip \
|
| 24 |
+
python3-dev \
|
| 25 |
+
python3-setuptools \
|
| 26 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
+
|
| 28 |
+
# Create a working directory
|
| 29 |
+
WORKDIR /app
|
| 30 |
+
|
| 31 |
+
# Add a script to check GPU status at startup
|
| 32 |
+
RUN echo '#!/bin/bash \n\
|
| 33 |
+
echo "Checking NVIDIA GPU status..." \n\
|
| 34 |
+
if ! command -v nvidia-smi &> /dev/null; then \n\
|
| 35 |
+
echo "WARNING: nvidia-smi command not found. NVIDIA driver might not be installed." \n\
|
| 36 |
+
else \n\
|
| 37 |
+
echo "NVIDIA driver found. Running nvidia-smi:" \n\
|
| 38 |
+
nvidia-smi \n\
|
| 39 |
+
fi \n\
|
| 40 |
+
echo "Environment variables for GPU:" \n\
|
| 41 |
+
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}" \n\
|
| 42 |
+
echo "NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}" \n\
|
| 43 |
+
exec "$@"' > /entrypoint.sh && \
|
| 44 |
+
chmod +x /entrypoint.sh
|
| 45 |
+
|
| 46 |
+
# Copy requirements file
|
| 47 |
+
COPY requirements_internvl2_llama3.txt ./requirements.txt
|
| 48 |
+
|
| 49 |
+
# Upgrade pip and install dependencies
|
| 50 |
+
RUN pip3 install --no-cache-dir --upgrade pip && \
|
| 51 |
+
# Install torch and torchvision first
|
| 52 |
+
pip3 install --no-cache-dir torch==2.0.1 torchvision==0.15.2 && \
|
| 53 |
+
# Install core dependencies
|
| 54 |
+
pip3 install --no-cache-dir -r requirements.txt
|
| 55 |
+
|
| 56 |
+
# Copy the application files
|
| 57 |
+
COPY app_internvl2_llama3.py ./app.py
|
| 58 |
+
|
| 59 |
+
# Make sure the runtime directories exist and have proper permissions
|
| 60 |
+
RUN mkdir -p .cache/huggingface/transformers && \
|
| 61 |
+
chmod -R 777 .cache
|
| 62 |
+
|
| 63 |
+
# Make port 7860 available for the app
|
| 64 |
+
EXPOSE 7860
|
| 65 |
+
|
| 66 |
+
# Use our entrypoint script to check GPU status before starting the app
|
| 67 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
| 68 |
+
|
| 69 |
+
# Start the application
|
| 70 |
+
CMD ["python3", "app.py"]
|