ImportError: cannot import name 'AutoModelForTokenClassification'
Author: ganeshkharad2
Pull request: no

# was trying to use below model but got import error for AutoModelForTokenClassification


from transformers import AutoTokenizer, AutoModelForTokenClassification

tokenizer = AutoTokenizer.from_pretrained("dbmdz/electra-large-discriminator-finetuned-conll03-english")

model = AutoModelForTokenClassification.from_pretrained("dbmdz/electra-large-discriminator-finetuned-conll03-english")

Comments:
Hi, what is your transformers version? Can you run `transformers-cli env` and paste the result here?

Here is the output for  transformers-cli env

2020-09-24 16:56:51.133770: W
tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not
load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1:
cannot open shared object file: No such file or directory
2020-09-24 16:56:51.133813: I
tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart
dlerror if you do not have a GPU set up on your machine.
WARNING:tensorflow:From
/home/gnaeshkharad/allenv/t5env/lib/python3.6/site-packages/transformers/commands/env.py:36:
is_gpu_available (from tensorflow.python.framework.test_util) is deprecated
and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2020-09-24 16:56:53.097782: I
tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary
is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the
following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate
compiler flags.
2020-09-24 16:56:53.134585: I
tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency:
2099940000 Hz
2020-09-24 16:56:53.135040: I
tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5ffa320
initialized for platform Host (this does not guarantee that XLA will be
used). Devices:
2020-09-24 16:56:53.135065: I
tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device
(0): Host, Default Version
2020-09-24 16:56:53.137882: W
tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not
load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open
shared object file: No such file or directory
2020-09-24 16:56:53.137898: W
tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit:
UNKNOWN ERROR (303)
2020-09-24 16:56:53.137915: I
tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does
not appear to be running on this host (4F4W0X2):
/proc/driver/nvidia/version does not exist

Copy-and-paste the text below in your GitHub issue and FILL OUT the two
last points.

- `transformers` version: 3.2.0
- Platform: Linux-5.4.0-47-generic-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.6.0 (False)
- Tensorflow version (GPU?): 2.3.0 (False)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

On Thu, Sep 24, 2020 at 4:12 PM Lysandre Debut <notifications@github.com>
wrote:

> Hi, what is your transformers version? Can you run transformers-cli env
> and paste the result here?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/7361#issuecomment-698265526>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AEZTBOR3ILZVKYMSCLZLXBTSHMPC5ANCNFSM4RYD7THQ>
> .
>


Could you run:

```
import transformers                                                                                                                                                                            
transformers.is_torch_available() 
```

Does this command returns `True` 🤔

Got False

I have found the issue its in my environment...
My bad..Thanks for your time!!

Great, thanks @stefan-it!

> from transformers import AutoTokenizer, AutoModelForTokenClassification

Hi, i also meet this issue, transformers.is_torch_available()  gives me true, but i still can't import AutoModelForTokenClassification

> > from transformers import AutoTokenizer, AutoModelForTokenClassification
> 
> Hi, i also meet this issue, transformers.is_torch_available() gives me true, but i still can't import AutoModelForTokenClassification

update transformers will be fine


> Could you run:
> 
> ```
> import transformers                                                                                                                                                                            
> transformers.is_torch_available() 
> ```
> 
> Does this command returns `True` 🤔

Hi @stefan-it, the follwoing code snippet returns true but shows the same import error.

import transformers                                                                                                                                                                            
transformers.is_torch_available() 

if the above code returns false, used the code below to install torch

pip install torch

It after torch installation, the issue can be resolved.