Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +62 -0
Dockerfile
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
|
9 |
+
|
10 |
+
# Create necessary directories with proper permissions
|
11 |
+
RUN mkdir -p /app/.cache/huggingface/transformers && \
|
12 |
+
chmod -R 777 /app
|
13 |
+
|
14 |
+
# Install system dependencies
|
15 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
16 |
+
build-essential \
|
17 |
+
git \
|
18 |
+
curl \
|
19 |
+
ca-certificates \
|
20 |
+
python3-pip \
|
21 |
+
python3-dev \
|
22 |
+
&& rm -rf /var/lib/apt/lists/*
|
23 |
+
|
24 |
+
# Create a working directory
|
25 |
+
WORKDIR /app
|
26 |
+
|
27 |
+
# Install core requirements
|
28 |
+
COPY requirements.txt .
|
29 |
+
RUN pip3 install --no-cache-dir --upgrade pip && \
|
30 |
+
pip3 install --no-cache-dir -r requirements.txt
|
31 |
+
|
32 |
+
# Install additional dependencies specifically for InternViT
|
33 |
+
RUN pip3 install --no-cache-dir transformers==4.37.2 timm==0.9.11 accelerate==0.30.0 safetensors==0.4.1 einops
|
34 |
+
|
35 |
+
# Copy the application
|
36 |
+
COPY simple_internvit_test.py .
|
37 |
+
|
38 |
+
# Add a script to check GPU status and run the app
|
39 |
+
RUN echo '#!/bin/bash \n\
|
40 |
+
echo "Checking NVIDIA GPU status..." \n\
|
41 |
+
if ! command -v nvidia-smi &> /dev/null; then \n\
|
42 |
+
echo "WARNING: nvidia-smi command not found. NVIDIA driver might not be installed." \n\
|
43 |
+
else \n\
|
44 |
+
echo "NVIDIA driver found. Running nvidia-smi:" \n\
|
45 |
+
nvidia-smi \n\
|
46 |
+
fi \n\
|
47 |
+
echo "Environment variables:" \n\
|
48 |
+
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}" \n\
|
49 |
+
echo "NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}" \n\
|
50 |
+
echo "PYTORCH_CUDA_ALLOC_CONF=${PYTORCH_CUDA_ALLOC_CONF}" \n\
|
51 |
+
echo "\nStarting app..." \n\
|
52 |
+
exec "$@"' > /entrypoint.sh && \
|
53 |
+
chmod +x /entrypoint.sh
|
54 |
+
|
55 |
+
# Expose port 7860 for Gradio
|
56 |
+
EXPOSE 7860
|
57 |
+
|
58 |
+
# Use our entrypoint script
|
59 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
60 |
+
|
61 |
+
# Start the application
|
62 |
+
CMD ["python3", "simple_internvit_test.py"]
|