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

transformers-cli now requires PyTorch #36244

Closed
setu4993 opened this issue Feb 17, 2025 · 5 comments · Fixed by #36376
Closed

transformers-cli now requires PyTorch #36244

setu4993 opened this issue Feb 17, 2025 · 5 comments · Fixed by #36376
Labels

Comments

@setu4993
Copy link
Contributor

setu4993 commented Feb 17, 2025

System Info

N/A

Who can help?

@gante (author of #35714)

Reproduction

uv run --python 3.12 --with transformers transformers-cli --help

Expected behavior

Since #35714 (released in v4.49.0), the transformers-cli now requires PyTorch to even run a simple: transformers-cli --help command.

I am pretty sure it is originating from this line.

My question is if this is intentional or unintentional. So far, PyTorch has been an optional dependency for any functionality with CLI or the package itself.

@setu4993 setu4993 added the bug label Feb 17, 2025
@Rocketknight1
Copy link
Member

Seems real, and I don't think we should require Torch for transformers-cli. I think this is probably a testing failure more than anything, though - cc @gante, maybe we should have tests for transformers-cli that don't @require_torch so we catch things like this in future?

@scw
Copy link

scw commented Feb 24, 2025

I agree this is an issue that should be addressed — two dependencies that aren't installed without adding some extras elements, pytorch and rich, are now required to run transformers-cli. Helpfully, we get a message about PyTorch not being found and how that affects functionality, but the chat.py component isn't wrapped in a try / except to prevent import failure with the default requires list.

@machinelearningprodigy
Copy link

machinelearningprodigy commented Feb 24, 2025

I think you're running into #35714, which made PyTorch a required dependency for transformers-cli.
Even a simple transformers-cli --help now needs PyTorch to work.
You can fix this by installing PyTorch (pip install torch) or downgrading transformers to a version before v4.49.0.

@Rocketknight1
Copy link
Member

gentle ping @gante! Was that dependency intentional?

@gante
Copy link
Member

gante commented Feb 24, 2025

@Rocketknight1 not intentional, I'll add a guard (and tag the branch for a patch release)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants