You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Torch dependency in sagameker-core to be made optional #5457
Describe the bug
Can torch dependency be made optional? Torch feature is NOT used by all users and adding it as a dependency brings in a lot of additional transitive dependencies resulting in any custom image built w/sagemaker-core to be bloated. Can this be made optional?
To reproduce
pip install sagemaker-core==2.3.0
Expected behavior
Sagemaker-core install should not install torch by default
Screenshots or logs
NA
System information
A description of your system. Please provide:
SageMaker Python SDK version: 3.3.0
Framework name (eg. PyTorch) or algorithm (eg. KMeans): Torch
Framework version: NA
Python version: 3.1.13
CPU or GPU: CPU
Custom Docker image (Y/N): Y
Additional context
We are trying to keep our custom images as lean as possible and avoid includng packages that are not used in our env.
Reacted by R. Cooper Snyder, Manu, gbeasleytombola, James Frye, Adam Ivison, David Watkins, Xiaoyong Jin, Jonathan Boidol, Jake Teo, luca-dimatteo-al and 4 more
The original request — making torch optional in sagemaker-core — is done. As of #5713 (shipped in SDK 3.10.1), torch is no longer a mandatory dependency of sagemaker-core; it's an optional extra installed via sagemaker-core[torch]. A default pip install sagemaker-core no longer pulls in torch.
@JoseJuan98 good catch that sagemaker-serve still bundles torch (along with mlflow, tritonclient, onnx, onnxruntime). That's a separate package and a broader dependency-slimming effort — could you open a new issue scoped to sagemaker-serve so it can be tracked and prioritized on its own? Making torch optional there is more involved than a pyproject change since serve imports it in several code paths.
Activity
mapattacker commentedon Feb 11, 2026
Concur with this. At least have an option to have a "light" version of the SDK.
nkmglobalp commentedon May 28, 2026
Is this still being pursued? Bundling torch in the SageMaker core unnecessarily bloats the runtime environment when torch isn't required.
JoseJuan98 commentedon Jun 1, 2026
This seems to be fixed now in the
sagemaker-corepackage, but the same issue arises in thesagemaker-servepackage, could this one also be optional?mohamedzeidan2021 commentedon Sep 1, 2026
The original request — making
torchoptional insagemaker-core— is done. As of #5713 (shipped in SDK 3.10.1),torchis no longer a mandatory dependency ofsagemaker-core; it's an optional extra installed viasagemaker-core[torch]. A defaultpip install sagemaker-coreno longer pulls intorch.@JoseJuan98 good catch that
sagemaker-servestill bundlestorch(along withmlflow,tritonclient,onnx,onnxruntime). That's a separate package and a broader dependency-slimming effort — could you open a new issue scoped tosagemaker-serveso it can be tracked and prioritized on its own? Makingtorchoptional there is more involved than apyprojectchange since serve imports it in several code paths.Closing this one as resolved for
sagemaker-core.