-
Notifications
You must be signed in to change notification settings - Fork 25.9k
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
Can't create transformer pipeline because pytorch failed to be detected #31454
Comments
cc @ydshieh |
I can no longer reproduce this after restarting my notebook kernel. I suppose that the pytorch detection relies on some system environment which requires notebook kernel to restart to pickup. Feel free to close this. |
It seems that _torch_available is a global variable and set at initialization time: https://github.com/huggingface/transformers/blob/02300273e220932a449a47ebbe453e7789be454b/src/transformers/utils/import_utils.py#L180C1-L180C17 So it won't be re-evaluated in the same notebook kernel when it was re-evaluated (until I restart my kernel). One improvement I can think of is to reevaluate this variable in is_torch_available() but I don't know if that breaks other things or not. |
Does this mean that |
In general, for notebook (well, I usually use Google Colab), if there is/are some installation(s), it is recommended to restart the kernel.
We make use of I am open to a PR that improve stuff (the mentioned issue) but keep things fast (regarding what I mentioned above) |
@amyeroberts torch is installed in the notebook kernel ("!pip install ...") and I re-executed the block to import transformer multiple times (with no avail). |
@dannikay Just to be clear, this means that transformers was already imported, torch installed, then the cell to import transformers re-executed? As @ydshieh notes above, we have a cache which means If you or anyone else wants to submit a PR which would make this more dynamic whilst maintaining speed, we'd be very happy to review! |
@amyeroberts correct. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
System Info
Ubuntu 22.04
Python 3.12.3
Who can help?
@Narsil @zucchini-nlp
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
I do not expect the above error since pytorch has been installed in my system.
The text was updated successfully, but these errors were encountered: