Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +91 -0
Dockerfile
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel
|
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 |
+
cmake \
|
21 |
+
python3-pip \
|
22 |
+
python3-dev \
|
23 |
+
ninja-build \
|
24 |
+
&& rm -rf /var/lib/apt/lists/*
|
25 |
+
|
26 |
+
# Create a working directory
|
27 |
+
WORKDIR /app
|
28 |
+
|
29 |
+
# Install core requirements
|
30 |
+
COPY requirements.txt .
|
31 |
+
RUN pip3 install --no-cache-dir --upgrade pip && \
|
32 |
+
pip3 install --no-cache-dir -r requirements.txt
|
33 |
+
|
34 |
+
# Install basic dependencies specifically for InternViT
|
35 |
+
RUN pip3 install --no-cache-dir \
|
36 |
+
transformers==4.37.2 \
|
37 |
+
timm==0.9.11 \
|
38 |
+
accelerate==0.30.0 \
|
39 |
+
safetensors==0.4.1 \
|
40 |
+
einops
|
41 |
+
|
42 |
+
# Install flash-attn with build tools provided by devel image
|
43 |
+
RUN pip3 install --no-cache-dir \
|
44 |
+
ninja \
|
45 |
+
packaging \
|
46 |
+
"flash-attn==1.0.9"
|
47 |
+
|
48 |
+
# Copy the application
|
49 |
+
COPY simple_internvit_test.py .
|
50 |
+
|
51 |
+
# Add GPU diagnostic script
|
52 |
+
RUN echo '#!/bin/bash \n\
|
53 |
+
echo "Starting GPU diagnostics..." \n\
|
54 |
+
echo "===== System Information =====" \n\
|
55 |
+
python3 -c "import sys; print(f\"Python version: {sys.version}\")" \n\
|
56 |
+
python3 -c "import torch; print(f\"PyTorch version: {torch.__version__}\")" \n\
|
57 |
+
echo "\n===== CUDA Information =====" \n\
|
58 |
+
python3 -c "import torch; print(f\"CUDA available: {torch.cuda.is_available()}\")" \n\
|
59 |
+
if [ $(python3 -c "import torch; print(torch.cuda.is_available())") = "True" ]; then \n\
|
60 |
+
echo "CUDA/NVCC version:" \n\
|
61 |
+
nvcc --version \n\
|
62 |
+
python3 -c "import torch; print(f\"CUDA version: {torch.version.cuda}\")" \n\
|
63 |
+
python3 -c "import torch; print(f\"GPU count: {torch.cuda.device_count()}\")" \n\
|
64 |
+
python3 -c "import torch; for i in range(torch.cuda.device_count()): print(f\"GPU {i}: {torch.cuda.get_device_name(i)}\")" \n\
|
65 |
+
python3 -c "import torch; print(f\"Allocated memory: {torch.cuda.memory_allocated() / 1024 / 1024:.2f} MB\")" \n\
|
66 |
+
python3 -c "import torch; print(f\"Reserved memory: {torch.cuda.memory_reserved() / 1024 / 1024:.2f} MB\")" \n\
|
67 |
+
fi \n\
|
68 |
+
echo "\n===== Package Information =====" \n\
|
69 |
+
pip3 list | grep -E "transformers|einops|torch|timm|flash|accelerate|safetensors" \n\
|
70 |
+
echo "\n===== Testing Simple CUDA Operation =====" \n\
|
71 |
+
python3 -c "import torch; a = torch.randn(1000, 1000).cuda(); b = torch.randn(1000, 1000).cuda(); t0 = torch.cuda.Event(enable_timing=True); t1 = torch.cuda.Event(enable_timing=True); t0.record(); c = torch.matmul(a, b); t1.record(); torch.cuda.synchronize(); print(f\"Matrix multiplication completed in {t0.elapsed_time(t1):.2f} ms\")" \n\
|
72 |
+
echo "\n===== Testing Flash Attention Import =====" \n\
|
73 |
+
python3 -c "import flash_attn; print(f\"Flash Attention version: {flash_attn.__version__}\")" \n\
|
74 |
+
echo "\n===== NVIDIA System Information =====" \n\
|
75 |
+
if command -v nvidia-smi &> /dev/null; then \n\
|
76 |
+
nvidia-smi \n\
|
77 |
+
else \n\
|
78 |
+
echo "nvidia-smi not found" \n\
|
79 |
+
fi \n\
|
80 |
+
echo "\n===== Starting Application =====" \n\
|
81 |
+
exec "$@"' > /entrypoint.sh && \
|
82 |
+
chmod +x /entrypoint.sh
|
83 |
+
|
84 |
+
# Expose port 7860 for Gradio
|
85 |
+
EXPOSE 7860
|
86 |
+
|
87 |
+
# Use our enhanced diagnostic entrypoint script
|
88 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
89 |
+
|
90 |
+
# Start the application
|
91 |
+
CMD ["python3", "simple_internvit_test.py"]
|