sreejith8100 commited on
Commit
fabcfe8
·
verified ·
1 Parent(s): df376ec

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -23
Dockerfile CHANGED
@@ -1,23 +1,36 @@
1
- FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
2
-
3
- RUN apt-get update && apt-get install -y wget
4
- RUN useradd -m -u 1000 user
5
-
6
- USER user
7
- WORKDIR /app
8
-
9
- ENV PATH="/home/user/.local/bin:$PATH"
10
- ENV TRANSFORMERS_CACHE=/home/user/.cache/huggingface
11
- ENV TORCH_CUDA_ARCH_LIST="8.0+PTX"
12
-
13
- RUN wget https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.0.4/flash_attn-2.7.3+cu121torch2.3-cp310-cp310-linux_x86_64.whl
14
- RUN pip install ./flash_attn-2.7.3+cu121torch2.3-cp310-cp310-linux_x86_64.whl && rm flash_attn-2.7.3+cu121torch2.3-cp310-cp310-linux_x86_64.whl
15
-
16
- COPY --chown=user requirements.txt .
17
- RUN pip install --upgrade pip setuptools wheel
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
-
21
- COPY --chown=user . .
22
-
23
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Base image with PyTorch 2.4.0 + CUDA 12.1
2
+ FROM pytorch/pytorch:2.4.0-cuda12.1-cudnn8-runtime
3
+
4
+ # Create a non-root user
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+ WORKDIR /app
8
+
9
+ # Environment variables
10
+ ENV PATH="/home/user/.local/bin:$PATH"
11
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
12
+ ENV TORCH_CUDA_ARCH_LIST="8.0+PTX"
13
+ ENV MODEL_DIR=/app/models/minicpmv
14
+
15
+ # Install system dependencies
16
+ RUN apt-get update && apt-get install -y wget git && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Copy requirements and install Python dependencies
19
+ COPY --chown=user requirements.txt .
20
+ RUN pip install --upgrade pip setuptools wheel
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
+
23
+ # Pre-download MiniCPM-V-4 model at build time
24
+ RUN python -c "\
25
+ from huggingface_hub import snapshot_download; \
26
+ snapshot_download('openbmb/MiniCPM-V-4', local_dir='/app/models/minicpmv', local_dir_use_symlinks=False) \
27
+ "
28
+
29
+ # Copy application code
30
+ COPY --chown=user . .
31
+
32
+ # Expose FastAPI port
33
+ EXPOSE 7860
34
+
35
+ # Start the app
36
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]