Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +76 -0
Dockerfile
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 basic dependencies specifically for InternViT
|
33 |
+
RUN pip3 install --no-cache-dir \
|
34 |
+
transformers==4.37.2 \
|
35 |
+
timm==0.9.11 \
|
36 |
+
accelerate==0.30.0 \
|
37 |
+
safetensors==0.4.1 \
|
38 |
+
einops
|
39 |
+
|
40 |
+
# Copy the application file
|
41 |
+
COPY no_flash_attn_test.py /app/app.py
|
42 |
+
|
43 |
+
# Add a simple script to check GPU status
|
44 |
+
RUN echo '#!/bin/bash \n\
|
45 |
+
echo "Starting diagnostics..." \n\
|
46 |
+
echo "===== System Information =====" \n\
|
47 |
+
python3 -c "import sys; print(f\"Python version: {sys.version}\")" \n\
|
48 |
+
python3 -c "import torch; print(f\"PyTorch version: {torch.__version__}\")" \n\
|
49 |
+
echo "\n===== CUDA Information =====" \n\
|
50 |
+
python3 -c "import torch; print(f\"CUDA available: {torch.cuda.is_available()}\")" \n\
|
51 |
+
if [ $(python3 -c "import torch; print(torch.cuda.is_available())") = "True" ]; then \n\
|
52 |
+
python3 -c "import torch; print(f\"CUDA version: {torch.version.cuda}\")" \n\
|
53 |
+
python3 -c "import torch; print(f\"GPU count: {torch.cuda.device_count()}\")" \n\
|
54 |
+
python3 -c "import torch; for i in range(torch.cuda.device_count()): print(f\"GPU {i}: {torch.cuda.get_device_name(i)}\")" \n\
|
55 |
+
python3 -c "import torch; print(f\"Total GPU memory: {torch.cuda.get_device_properties(0).total_memory / 1024 / 1024 / 1024:.2f} GB\")" \n\
|
56 |
+
fi \n\
|
57 |
+
echo "\n===== Package Information =====" \n\
|
58 |
+
pip3 list | grep -E "transformers|einops|torch|timm|accelerate|safetensors" \n\
|
59 |
+
echo "\n===== NVIDIA System Information =====" \n\
|
60 |
+
if command -v nvidia-smi &> /dev/null; then \n\
|
61 |
+
nvidia-smi \n\
|
62 |
+
else \n\
|
63 |
+
echo "nvidia-smi not found" \n\
|
64 |
+
fi \n\
|
65 |
+
echo "\n===== Starting Application =====" \n\
|
66 |
+
exec "$@"' > /entrypoint.sh && \
|
67 |
+
chmod +x /entrypoint.sh
|
68 |
+
|
69 |
+
# Expose port 7860 for Gradio
|
70 |
+
EXPOSE 7860
|
71 |
+
|
72 |
+
# Use our entrypoint script
|
73 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
74 |
+
|
75 |
+
# Start the application
|
76 |
+
CMD ["python3", "app.py"]
|