Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +69 -0
Dockerfile
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
# Create and install requirements
|
28 |
+
RUN echo "transformers==4.37.2\n\
|
29 |
+
accelerate==0.30.0\n\
|
30 |
+
safetensors==0.4.1\n\
|
31 |
+
einops\n\
|
32 |
+
gradio==3.38.0\n\
|
33 |
+
numpy\n\
|
34 |
+
Pillow\n\
|
35 |
+
torch>=2.0.0" > requirements.txt
|
36 |
+
|
37 |
+
# Install Python dependencies
|
38 |
+
RUN pip3 install --no-cache-dir --upgrade pip && \
|
39 |
+
pip3 install --no-cache-dir -r requirements.txt
|
40 |
+
|
41 |
+
# Copy the application file
|
42 |
+
COPY app.py /app/app.py
|
43 |
+
|
44 |
+
# Add diagnostic script for startup
|
45 |
+
RUN echo '#!/bin/bash \n\
|
46 |
+
echo "Starting diagnostics..." \n\
|
47 |
+
echo "===== System Information =====" \n\
|
48 |
+
python3 -c "import sys; print(f\"Python version: {sys.version}\")" \n\
|
49 |
+
python3 -c "import torch; print(f\"PyTorch version: {torch.__version__}\")" \n\
|
50 |
+
echo "\n===== CUDA Information =====" \n\
|
51 |
+
python3 -c "import torch; print(f\"CUDA available: {torch.cuda.is_available()}\")" \n\
|
52 |
+
if [ $(python3 -c "import torch; print(torch.cuda.is_available())") = "True" ]; then \n\
|
53 |
+
python3 -c "import torch; print(f\"CUDA version: {torch.version.cuda}\")" \n\
|
54 |
+
python3 -c "import torch; print(f\"GPU count: {torch.cuda.device_count()}\")" \n\
|
55 |
+
python3 -c "import torch; for i in range(torch.cuda.device_count()): print(f\"GPU {i}: {torch.cuda.get_device_name(i)}\")" \n\
|
56 |
+
python3 -c "import torch; print(f\"Total GPU memory: {torch.cuda.get_device_properties(0).total_memory / 1024 / 1024 / 1024:.2f} GB\")" \n\
|
57 |
+
fi \n\
|
58 |
+
echo "\n===== Starting Application =====" \n\
|
59 |
+
exec "$@"' > /entrypoint.sh && \
|
60 |
+
chmod +x /entrypoint.sh
|
61 |
+
|
62 |
+
# Expose port 7860 for Gradio
|
63 |
+
EXPOSE 7860
|
64 |
+
|
65 |
+
# Use entrypoint script
|
66 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
67 |
+
|
68 |
+
# Start the application
|
69 |
+
CMD ["python3", "app.py"]
|