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

Misleading ImportError error #33604

Open
4 tasks
davidgilbertson opened this issue Sep 20, 2024 · 1 comment · May be fixed by #33622
Open
4 tasks

Misleading ImportError error #33604

davidgilbertson opened this issue Sep 20, 2024 · 1 comment · May be fixed by #33622
Labels
bug Usage General questions about the library

Comments

@davidgilbertson
Copy link

System Info

  • transformers version: 4.42.3
  • Platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
  • Python version: 3.10.12
  • Huggingface_hub version: 0.23.4
  • Safetensors version: 0.4.3
  • Accelerate version: 0.32.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.4.1+cu121 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?: No
  • Using GPU in script?: No
  • GPU type: NVIDIA GeForce RTX 3090

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

This GitHub issue is not about resolving the errors below, it's about a logical error in the code that produces the errors.

I get the following error running some code:

ImportError: This modeling file requires the following packages that were not found in your environment: flash_attn.

But I have flash_attn installed. The underlying problem is that when importing flash_attn, some other code throws an ImportError, but that error is swallowed by transformers code.

To be specific, the logical mistake is in the check_imports function. It assumes that if you get an ImportError when trying to import a package, it means that the package isn't installed.

That's probably a fine assumption most of the time, but when something's going wrong like in my case, it makes it hard to find out what because the real error is being swallowed and replaced. This is the real error, by the way:

ImportError: libcudart.so.11.0: cannot open shared object file: No such file or directory

To reiterate, this issue is not about resolving these errors, it's about fixing the code that masks useful errors (although it someone happens to know the fix, great).

Expected behavior

You should show the original error and then if you want to, also show the hand-written "missing packages" message.

@molbap
Copy link
Contributor

molbap commented Sep 20, 2024

Hi @davidgilbertson, It's true we are not handle ImportError - will propose a PR to improve that a bit.

@molbap molbap linked a pull request Sep 20, 2024 that will close this issue
@LysandreJik LysandreJik added the Usage General questions about the library label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Usage General questions about the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants