fix(docker): SLS-377 install torchvision in GPU worker image#101
Merged
Conversation
The runpod/pytorch base image ships torch/torchaudio/triton but not torchvision, and `flash build` auto-excludes torchvision from the deployment tarball (SIZE_PROHIBITIVE_PACKAGES) on the assumption the base image provides it. Nothing backfilled it, so any deployed Flash app importing torchvision failed at runtime with ModuleNotFoundError. Install torchvision in the worker image, mirroring the existing numpy backfill: pin to the release paired with the base torch (2.9.1 -> 0.24.1) and use the CUDA wheel index to stay CUDA-aligned. Add a build -time import assertion so a future torch bump that breaks the pairing fails the build instead of the customer. Fixes SLS-377.
Contributor
There was a problem hiding this comment.
Pull request overview
Installs torchvision into the GPU worker Docker image to prevent runtime ModuleNotFoundError when Flash build/deploy strips torchvision from the deployment tarball and the runpod/pytorch:* base image does not provide it.
Changes:
- Add a pinned
TORCHVISION_VERSIONbuild arg with rationale and upgrade guidance alongsideTORCH_VERSION. - Install
torchvisionin the worker image from the CUDA wheel index (TORCH_INDEX_URL) to match the base image’s CUDA/torch build. - Extend the build-time verification step to import and print the installed
torchvisionversion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
KAJdev
approved these changes
Jul 10, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
A deployed Flash app importing
torchvisionfails at worker runtime withModuleNotFoundError(customer escalation SLS-377, Zendesk #41953).Root cause is a three-part gap:
flash build/deployunconditionally strips torchvision from the deployment tarball —SIZE_PROHIBITIVE_PACKAGES = {torch, torchvision, torchaudio, triton}, merged as a set union, so there is no CLI flag to force-include it. The justification is that these are "already provided by the GPU base images (runpod/pytorch:*)".runpod/pytorch:1.0.3-cu1281-torch291-ubuntu2204): torch, torchaudio, triton are present — torchvision is not.Net: stripped from tarball -> absent from base image -> never reinstalled -> import fails at runtime.
Fix
Install torchvision in the GPU worker image, mirroring the existing numpy backfill:
TORCHVISION_VERSION=0.24.1, the release paired with the base torch 2.9.1 (bump both together on a torch upgrade).import torchvisionassertion so a future torch bump that breaks the pairing fails the build, not the customer.Not fixed by un-excluding torchvision from the tarball: its wheels are CUDA/platform-specific and depend on torch (which stays excluded), so bundling risks a CUDA mismatch and a second torch. The Dockerfile is the correct layer, consistent with the numpy precedent.
Test plan
docker buildx build --platform linux/amd64 --build-arg PYTHON_VERSION=3.12 .— succeeds; torchvision resolves to0.24.1+cu128withtorch==2.9.1already satisfied (no torch re-pull).Python 3.12 OK,torch 2.9.1+cu128,torchvision 0.24.1+cu128,numpy 2.5.1.make quality-checkpasses (14/14 handler tests + lint/format/typecheck/coverage).Follow-ups (out of scope here)
SIZE_PROHIBITIVE_PACKAGEScomment inflashbuild.py("already provided by the GPU base images") is now inaccurate for torchvision and should be corrected in a flash-side PR.