Skip to content

Torch dependency in sagameker-core to be made optional #5457

Closed

Description

@sateeshmannar

PySDK Version

  • PySDK V2 (2.x)
  • PySDK V3 (3.x)

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.

Activity

  1. mapattacker commented on Feb 11, 2026

    @mapattacker

    Concur with this. At least have an option to have a "light" version of the SDK.

  2. nkmglobalp commented on May 28, 2026

    @nkmglobalp

    Is this still being pursued? Bundling torch in the SageMaker core unnecessarily bloats the runtime environment when torch isn't required.

  3. JoseJuan98 commented on Jun 1, 2026

    @JoseJuan98
    Contributor

    This seems to be fixed now in the sagemaker-core package, but the same issue arises in the sagemaker-serve package, could this one also be optional?

  4. mohamedzeidan2021 commented on Sep 1, 2026

    @mohamedzeidan2021
    Collaborator

    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.

    Closing this one as resolved for sagemaker-core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions