-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Layered Dockerfile for smaller size and faster image pulling #22377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| FROM python:3.12.9-slim AS builder | ||
|
|
||
| WORKDIR /tmp | ||
|
|
||
| # Install packages in a temporary directory | ||
| RUN pip install --no-cache-dir vllm==0.10.0 -t /tmp/python-packages | ||
|
|
||
| # Separate the nvidia packages (2.7 GB) into cudnn (1 GB), cublas (600 MB), and all else (1.2 GB) | ||
| # rm -rf needed at the end to remove the now-empty dirs after mv | ||
| RUN mkdir -p /chunk-nvidia/chunk-cudnn && \ | ||
| mkdir -p /chunk-nvidia/chunk-cublas && \ | ||
| mkdir -p /chunk-nvidia/other && \ | ||
| mv /tmp/python-packages/nvidia/cudnn /chunk-nvidia/chunk-cudnn && \ | ||
| mv /tmp/python-packages/nvidia/cublas /chunk-nvidia/chunk-cublas && \ | ||
| mv /tmp/python-packages/nvidia/* /chunk-nvidia/other && \ | ||
| rm -rf /chunk-nvidia/other/cudnn /chunk-nvidia/other/cublas | ||
|
|
||
| # Separate the torch packages (1.7 GB) | ||
| RUN mkdir -p /chunk-torch && \ | ||
| mv /tmp/python-packages/torch /chunk-torch/ | ||
|
|
||
| # Separate the vllm packages (800 MB) | ||
| RUN mkdir -p /chunk-vllm && \ | ||
| mv /tmp/python-packages/vllm /chunk-vllm/ | ||
|
|
||
| # Move the rest of the packages (1.8 GB) | ||
| # rm -rf needed at the end to remove the now-empty dirs after mv | ||
| RUN mkdir -p /chunk-other && \ | ||
| mv /tmp/python-packages/* /chunk-other/ && \ | ||
| rm -rf /chunk-other/nvidia /chunk-other/torch /chunk-other/vllm | ||
|
|
||
| # This is the final image | ||
| FROM python:3.12.9-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy each chunk into the final image into cohesive wholes | ||
| # each of these will be pulled concurrently during docker pull | ||
| COPY --from=builder /chunk-nvidia/chunk-cudnn/cudnn /usr/local/lib/python3.12/site-packages/nvidia/cudnn | ||
| COPY --from=builder /chunk-nvidia/chunk-cublas/cublas /usr/local/lib/python3.12/site-packages/nvidia/cublas | ||
| COPY --from=builder /chunk-nvidia/other /usr/local/lib/python3.12/site-packages/nvidia/ | ||
| COPY --from=builder /chunk-torch /usr/local/lib/python3.12/site-packages/ | ||
| COPY --from=builder /chunk-vllm /usr/local/lib/python3.12/site-packages/ | ||
| COPY --from=builder /chunk-other /usr/local/lib/python3.12/site-packages/ | ||
|
|
||
| # Install FlashInfer | ||
| RUN pip install "https://download.pytorch.org/whl/cu128/flashinfer/flashinfer_python-0.2.6.post1%2Bcu128torch2.7-cp39-abi3-linux_x86_64.whl" | ||
|
aoyshi marked this conversation as resolved.
Outdated
|
||
|
|
||
| ENV MODEL_PATH "/app/models/custom_model" | ||
|
|
||
| # Install GCC | ||
| RUN apt-get update && apt-get install -y build-essential | ||
|
aoyshi marked this conversation as resolved.
Outdated
|
||
|
|
||
| ENTRYPOINT ["sh", "-c", "python3 -m vllm.entrypoints.openai.api_server --model $MODEL_PATH $VLLM_ARGS"] | ||
|
aoyshi marked this conversation as resolved.
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.