Skip to content
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

[Training] Implicit dependency of Python training API on 'torch' package #22070

Open
nfnt opened this issue Sep 12, 2024 · 3 comments
Open

[Training] Implicit dependency of Python training API on 'torch' package #22070

nfnt opened this issue Sep 12, 2024 · 3 comments
Labels
training issues related to ONNX Runtime training; typically submitted using template

Comments

@nfnt
Copy link

nfnt commented Sep 12, 2024

Describe the issue

In the onnxruntime training API for Python, some packages in onnxruntime.training.optim import torch. Due to how Python package imports work, this results in a dependency of all packages in onnxruntime.training on torch. torch package sizes can be rather large and this size is problematic in some environments. It would be great to not require this package if using parts of onnxruntime that don't need it (e.g. onnxblock).

To reproduce

In a fresh virtual env run:

pip install onnxruntime-training-cpu
python -c 'import onnxruntime.training.onnxblock'

This will fail with

ModuleNotFoundError: No module named 'torch'

Urgency

Not too urgent, I have a workaround in place that's patching the API in onnxruntime.training.__init__.py to only add the optim package if torch is available.

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.2

PyTorch Version

not using Pytorch

Execution Provider

Default CPU

Execution Provider Library Version

No response

@nfnt nfnt added the training issues related to ONNX Runtime training; typically submitted using template label Sep 12, 2024
@xadupre
Copy link
Member

xadupre commented Sep 12, 2024

cc @baijumeswani

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Oct 12, 2024
@nfnt
Copy link
Author

nfnt commented Oct 14, 2024

Is there anything I can help with to get this resolved? I can see that there were some CI failures on #22072, but I'm not sure if they are related to the proposed changes.

@github-actions github-actions bot removed the stale issues that have not been addressed in a while; categorized by a bot label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
training issues related to ONNX Runtime training; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants