question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: cannot import name 'AutoModel' from 'transformers'

See original GitHub issue

🐛 Bug

(Not sure that it is a bug, but it is too easy to reproduce I think)

Information

I couldn’t run python -c 'from transformers import AutoModel', instead getting the error on the titile.

To reproduce

Steps to reproduce the behavior:

  1. $ sudo docker run -it --rm python:3.6 bash
  2. # pip install tensorflow==2.0 transformers==2.8.0
  3. # python -c 'from transformers import AutoModel'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'AutoModel'

Initially I got this error with transformers-cli download :

# transformers-cli download t5-large
Traceback (most recent call last):
  File "/usr/local/bin/transformers-cli", line 32, in <module>
    service.run()
  File "/usr/local/lib/python3.6/site-packages/transformers/commands/download.py", line 29, in run
    from transformers import AutoModel, AutoTokenizer
ImportError: cannot import name 'AutoModel'

Expected behavior

no import error.

Environment info

  • transformers version: 2.8.0
  • Platform: Linux-4.15.0-99-generic-x86_64-with-debian-10.3
  • Python version: 3.6.10
  • PyTorch version (GPU?): not installed (NA)
  • Tensorflow version (GPU?): 2.0.0 (False)
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?: no

Also tested on 3.6@Ubuntu 18.04, 3.8@Docker(python:3.8). The Docker backend is Ubuntu 18.04.

Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
julien-ccommented, May 8, 2020

AutoModel is the equivalent of TFAutoModel but for PyTorch model classes. If you don’t have pytorch installed this is expected.

Use TFAutoModel instead =)

1reaction
kennylajaracommented, Jul 13, 2021

EDIT: Well… This issue has been solved by updating dependencies but now it produces another issue. I will post the link to the reproducible issue in a minute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name 'AutoModelWithLMHead ...
This is literally all the code that I am trying to run: from transformers import ...
Read more >
How to resolve the hugging face error ImportError: cannot ...
I was trying to use the ViTT transfomer. I got the following error with code: from pathlib import Path import torchvision from typing...
Read more >
cannot import name 'AutoModel' from 'transformers'
{代码...}
Read more >
cannot import name 'TFAutoModel' from 'transformers'
ImportError : cannot import name 'TFAutoModel' from 'transformers'. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On May 29, ......
Read more >
importerror: cannot import name 'contextapi' from 'docker'
I couldn't run python -c 'from transformers import AutoModel' , instead getting the error on the titile. To reproduce. Steps to reproduce the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found