-
Notifications
You must be signed in to change notification settings - Fork 29k
[minor] Protect against broken/missing torchvision installations and do not hard-fail at timm/torchvision import (many text models don't need any timm/torchvision as hard dependencies) #38065
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
Comments
cc @qubvel @rwightman when I try this I get |
Yeah, HF currently hard-fails when either torchvision can'be imported (e.g. because of ABI issues / or incompatible PyTorch) or when torchvision isn't installed at all. |
Hmmm, that's probably because an outdated/incompatible version of From the traceback:
It seems like timm is installed but can't be imported. That's one of the issues with our guards - we only check package exists without actually importing it. I would say it's an environment misconfiguration, but we can think about how to handle it. @vadimkantorov you should not actually update only torch, torchvision should be updated accordingly, or removed |
Certainly. But unfortunately it's kind of easy to get broken installation of torchvision when upgrading torch manually :(
If I remember well, it also failed when I removed
Yeah, I think guarding aginst torchvision/timm failing to import would be helpful - given that now so many usages are language-only... |
Are both timm and torchvision removed from env?
…On Mon, May 12, 2025, 10:16 a.m. Vadim Kantorov ***@***.***> wrote:
*vadimkantorov* left a comment (huggingface/transformers#38065)
<#38065 (comment)>
Hmmm, that's probably because an outdated/incompatible version of
torchvision
Certainly
I would say it's an environment misconfiguration, but we can think about
how to handle it.
If I remember well, it also failed when I removed torchvision completely
—
Reply to this email directly, view it on GitHub
<#38065 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLQICHE4VR4NXU4EFYLWAD26DJO5AVCNFSM6AAAAAB43FIOIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZTGM2TINZTGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Also, transformers import fails when no torchvision is installed at all. I think it should be no-error, especially if I'm working with text models only. timm/friends should not be imported at all...
System Info
Google Colab, uses pytorch 2.6.0 for now
Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Go to colab which currently still has pytorch 2.6.0, then uninstall pytorch and install new pytorch (without torchvision):
Currently (nothing to do with vision) fails when the setup has broken installation of torchvision (can happen if the torchvision isn't actually used and has a version not matching torch)
Expected behavior
no hard-fail at import time, maybe a hard-fail when these ops/modules from torchvision are actually needed at runtime
The text was updated successfully, but these errors were encountered: