This repository was archived by the owner on Aug 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 888
Issues/fix docker dependencies #2340
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ | |
| python$PYTHON_VERSION-venv \ | ||
| openjdk-17-jdk \ | ||
| curl \ | ||
| git \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Make the virtual environment and "activating" it by adding it first to the path. | ||
|
|
@@ -62,26 +63,29 @@ RUN export USE_CUDA=1 | |
|
|
||
| ARG CUDA_VERSION="" | ||
|
|
||
| RUN TORCH_VER=$(curl --silent --location https://pypi.org/pypi/torch/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && \ | ||
| TORCH_VISION_VER=$(curl --silent --location https://pypi.org/pypi/torchvision/json | python -c "import sys, json, pkg_resources; releases = json.load(sys.stdin)['releases']; print(sorted(releases, key=pkg_resources.parse_version)[-1])") && \ | ||
| RUN git clone --depth 1 https://github.com/pytorch/serve.git | ||
|
|
||
| WORKDIR "serve" | ||
|
|
||
| RUN \ | ||
| if echo "$BASE_IMAGE" | grep -q "cuda:"; then \ | ||
| # Install CUDA version specific binary when CUDA version is specified as a build arg | ||
| if [ "$CUDA_VERSION" ]; then \ | ||
| python -m pip install --no-cache-dir torch==$TORCH_VER+$CUDA_VERSION torchvision==$TORCH_VISION_VER+$CUDA_VERSION -f https://download.pytorch.org/whl/torch_stable.html; \ | ||
| # Install the binary with the latest CUDA version support | ||
| python ./ts_scripts/install_dependencies.py --cuda $CUDA_VERSION; \ | ||
| # Install the binary with the latest CPU image on a CUDA base image | ||
| else \ | ||
| python -m pip install --no-cache-dir torch torchvision; \ | ||
| python ./ts_scripts/install_dependencies.py; \ | ||
| fi; \ | ||
| python -m pip install --no-cache-dir -r https://raw.githubusercontent.com/pytorch/serve/master/requirements/common.txt; \ | ||
| # Install the CPU binary | ||
| else \ | ||
| python -m pip install --no-cache-dir torch==$TORCH_VER+cpu torchvision==$TORCH_VISION_VER+cpu -f https://download.pytorch.org/whl/torch_stable.html; \ | ||
| python ./ts_scripts/install_dependencies.py; \ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| fi | ||
|
|
||
| RUN python -m pip install --no-cache-dir captum torchtext torchserve torch-model-archiver pyyaml | ||
| # Make sure latest version of torchserve is uploaded before running this | ||
| RUN python -m pip install --no-cache-dir torchserve torch-model-archiver torch-workflow-archiver | ||
|
|
||
| # Final image for production | ||
| FROM ${BASE_IMAGE} AS runtime-image | ||
| FROM ${BASE_IMAGE} AS runtime-image | ||
| # Re-state ARG PYTHON_VERSION to make it active in this build-stage (uses default define at the top) | ||
| ARG PYTHON_VERSION | ||
| ENV PYTHONUNBUFFERED TRUE | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To solve common_gpu.txt installation, you only need ref
https://github.com/pytorch/serve/blob/master/docker/Dockerfile#L75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lxning There is a problem with the CPU image too. It doesn't have pynvml , torchaudio, torchtext