Failed to import transformers.pipelines because of the following error (look up to see its traceback): cannot import name 'PartialState' from 'accelerate'
Author: Abhranta
Pull request: no

### System Info

I am trying to import Segment Anything Model (SAM) using transformers pipeline. But this gives the following error :
"
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'PartialState' from 'accelerate' (/opt/conda/lib/python3.10/site-packages/accelerate/__init__.py)"

What i am trying to do : 
"
from transformers import pipeline
generator = pipeline("mask-generation", model="facebook/sam-vit-huge", device=0)
"


     

### 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

import this line:

from transformers import pipeline
generator = pipeline("mask-generation", model="facebook/sam-vit-huge", device=0)
     

### Expected behavior

The model should import as per this notebook in official tutorials: 
https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb

Comments:
Hi @Abhranta, 

So that we can best try and help you, could you provide information about the running environment: run `transformers-cli env` in the terminal and copy-paste the output? 

Hello I am also having this issue hopefully we are having the same root issue. I am new to python and ML. Here is the output from my `transformers-cli env`:

```
PS C:\projects\poc-chatbot> transformers-cli env
Traceback (most recent call last):
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\Scripts\transformers-cli.exe\__main__.py", line 4, in <module>
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\commands\transformers_cli.py", line 25, in <module>
    from .run import RunCommand
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\commands\run.py", line 17, in <module>
    from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\pipelines\__init__.py", line 44, in <module>
    from .audio_classification import AudioClassificationPipeline
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\pipelines\audio_classification.py", line 21, in <module>
    from .base import PIPELINE_INIT_ARGS, Pipeline
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\pipelines\base.py", line 36, in <module>
    from ..modelcard import ModelCard
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\modelcard.py", line 48, in <module>
    from .training_args import ParallelMode
  File "C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\training_args.py", line 67, in <module>
    from accelerate import PartialState
ImportError: cannot import name 'PartialState' from 'accelerate' (C:\Users\Mitch\AppData\Local\Programs\Python\Python310\lib\site-packages\accelerate\__init__.py)
```

Hi @MitchellMonaghan, @Abhranta,

Could you try upgrading the installed version of accelerate in your env: `pip install -U accelerate`? 

Thanks this resolved this error thanks. It upgraded the accelerate package from.

```
Installing collected packages: accelerate
  Attempting uninstall: accelerate
    Found existing installation: accelerate 0.15.0.dev0
    Uninstalling accelerate-0.15.0.dev0:
      Successfully uninstalled accelerate-0.15.0.dev0
Successfully installed accelerate-0.19.0
``` 

This Error suddenly pops up in kaggle. Any IDEA!!!!!!!!
I already tried installing accelerate, transformers and datasets as the first line to execute in each notebooks.

ImportError                               Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/transformers/utils/import_utils.py:1172, in _LazyModule._get_module(self, module_name)
   1171 try:
-> 1172     return importlib.import_module("." + module_name, self.__name__)
   1173 except Exception as e:

File /opt/conda/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File /opt/conda/lib/python3.10/site-packages/transformers/pipelines/__init__.py:44
     35 from ..utils import (
     36     HUGGINGFACE_CO_RESOLVE_ENDPOINT,
     37     is_kenlm_available,
   (...)
     42     logging,
     43 )
---> 44 from .audio_classification import AudioClassificationPipeline
     45 from .automatic_speech_recognition import AutomaticSpeechRecognitionPipeline

File /opt/conda/lib/python3.10/site-packages/transformers/pipelines/audio_classification.py:21
     20 from ..utils import add_end_docstrings, is_torch_available, logging
---> 21 from .base import PIPELINE_INIT_ARGS, Pipeline
     24 if is_torch_available():

File /opt/conda/lib/python3.10/site-packages/transformers/pipelines/base.py:36
     35 from ..image_processing_utils import BaseImageProcessor
---> 36 from ..modelcard import ModelCard
     37 from ..models.auto.configuration_auto import AutoConfig

File /opt/conda/lib/python3.10/site-packages/transformers/modelcard.py:48
     32 from .models.auto.modeling_auto import (
     33     MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES,
     34     MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,
   (...)
     46     MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMES,
     47 )
---> 48 from .training_args import ParallelMode
     49 from .utils import (
     50     MODEL_CARD_NAME,
     51     cached_file,
   (...)
     57     logging,
     58 )

File /opt/conda/lib/python3.10/site-packages/transformers/training_args.py:67
     66 if is_accelerate_available():
---> 67     from accelerate import PartialState
     68     from accelerate.utils import DistributedType

ImportError: cannot import name 'PartialState' from 'accelerate' (/opt/conda/lib/python3.10/site-packages/accelerate/__init__.py)

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
File <timed exec>:2

File <frozen importlib._bootstrap>:1075, in _handle_fromlist(module, fromlist, import_, recursive)

File /opt/conda/lib/python3.10/site-packages/transformers/utils/import_utils.py:1162, in _LazyModule.__getattr__(self, name)
   1160     value = self._get_module(name)
   1161 elif name in self._class_to_module.keys():
-> 1162     module = self._get_module(self._class_to_module[name])
   1163     value = getattr(module, name)
   1164 else:

File /opt/conda/lib/python3.10/site-packages/transformers/utils/import_utils.py:1174, in _LazyModule._get_module(self, module_name)
   1172     return importlib.import_module("." + module_name, self.__name__)
   1173 except Exception as e:
-> 1174     raise RuntimeError(
   1175         f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
   1176         f" traceback):\n{e}"
   1177     ) from e

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'PartialState' from 'accelerate' (/opt/conda/lib/python3.10/site-packages/accelerate/__init__.py)

Hi @RayGone, 

Could you share the versions of accelerate, transformers and datasets installed and the steps taken / code being run? Have you tried restarting the running notebook session then running the installs? 


A week ago now I ran a code and it works fine, now I come to execute it when I import this trainer and TrainingArguments :
 `from transformers import Trainer, TrainingArguments`
I get the following error : 
![image](https://github.com/huggingface/transformers/assets/112518457/0d6bb4c7-9c99-4eea-9238-d6e5ab527d2f)

any help please
by the way i am using kaggle notebook.

> Hi @RayGone,
> 
> Could you share the versions of accelerate, transformers and datasets installed and the steps taken / code being run? Have you tried restarting the running notebook session then running the installs?

This is the [kaggle notebook](https://www.kaggle.com/code/reganmaharjan/bert-2-albert-transfer-learning-nepsa) that i am running.

This is the output of installing transformers. (Previously I didn't have to install transformers and datasets; they were already installed)
Requirement already satisfied: transformers[accelerate] in /opt/conda/lib/python3.10/site-packages (4.29.2)

P.S. Have made notebook public now.
@amyeroberts 

> Hi 
 transformers version :  4.29.2
accelerate version :  0.12.0

I don't know actually what is the issue

You need a more recent version of Accelerate @AzzedineAftiss: `pip install --upgrade accelerate`.

> You need a more recent version of Accelerate @AzzedineAftiss: `pip install --upgrade accelerate`.

@sgugger @amyeroberts 
Thanks guys for the help 
That  fixes the issue.

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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Thank you 🤗 so much for the amazing work, making it so easy to try and learn about the best models in the world. 🙏 

---

Ref: https://huggingface.co/blog/falcon

Got the same error as this issue while running the Falcon tutorial by HuggingFace on Kaggle. Came across this thread via a Google search (not from an LLM yet 😉) and had to make the following changes to get the Falcon tutorial to work on Kaggle notebooks:

```bash
pip install -q --upgrade accelerate einops xformers
```

- The `accelerate` needs to be upgraded as mentioned in this thread.
- Additional packages in `einops` and `xformers` needs to be installed as well.

My Notebook on Kaggle: https://www.kaggle.com/bkowshik/llms-models-falcon

_NOTE: Had to rerun a couple of times given memory issues on Kaggle, so one needs to keep_ 🤞 


```
Write a poem about India

A land of mystic and ancient lore,
where sacred rivers flow and mountains soar.
In India, the sun is in a brilliant glow,
cascading the hues that paint the sky like a magical show.

From Kanyakumari to Kashmir,
the beauty of India never fails to garner.
Its rich cultural heritage with its myriad hues,
and a kaleidoscope of colors, India is blessed.

Tigers roam in the dense forests,
cascading sound of the Ganges, and its gentle whispers.
The intricate handloom woven sarees in red,
a symphony of colors in India's head.

The holy pilgrimage of the sacred mountains,
the golden glow of Diwali, a festival of lights.
India is the land of the brave and true,
a melting pot of religions, cultures and hues!
```

---

@sgugger @amyeroberts Should we can close this issue then?

<details><summary>Complete logs with warning messages printed as part of the output for reference.</summary>
<p>

```
Downloading (…)okenizer_config.json: 100%
220/220 [00:00<00:00, 14.6kB/s]
Downloading (…)/main/tokenizer.json:
2.73M/? [00:00<00:00, 6.12MB/s]
Downloading (…)cial_tokens_map.json: 100%
281/281 [00:00<00:00, 22.8kB/s]
/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl6StatusC1EN10tensorflow5error4CodeESt17basic_string_viewIcSt11char_traitsIcEENS_14SourceLocationE']
  warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZTVN10tensorflow13GcsFileSystemE']
  warnings.warn(f"file system plugins are not loaded: {e}")
Downloading (…)lve/main/config.json: 100%
667/667 [00:00<00:00, 33.3kB/s]
Downloading (…)/configuration_RW.py:
2.61k/? [00:00<00:00, 165kB/s]
A new version of the following files was downloaded from https://huggingface.co/tiiuae/falcon-7b-instruct:
- configuration_RW.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
Downloading (…)main/modelling_RW.py:
47.5k/? [00:00<00:00, 2.70MB/s]
A new version of the following files was downloaded from https://huggingface.co/tiiuae/falcon-7b-instruct:
- modelling_RW.py
. Make sure to double-check they do not contain any added malicious code. To avoid downloading new versions of the code file, you can pin a revision.
Downloading (…)model.bin.index.json:
16.9k/? [00:00<00:00, 850kB/s]
Downloading shards: 100%
2/2 [01:13<00:00, 34.78s/it]
Downloading (…)l-00001-of-00002.bin: 100%
9.95G/9.95G [00:49<00:00, 278MB/s]
Downloading (…)l-00002-of-00002.bin: 100%
4.48G/4.48G [00:24<00:00, 169MB/s]
Loading checkpoint shards: 100%
2/2 [01:15<00:00, 35.25s/it]
Downloading (…)neration_config.json: 100%
111/111 [00:00<00:00, 5.67kB/s]
The model 'RWForCausalLM' is not supported for text-generation. Supported models are ['BartForCausalLM', 'BertLMHeadModel', 'BertGenerationDecoder', 'BigBirdForCausalLM', 'BigBirdPegasusForCausalLM', 'BioGptForCausalLM', 'BlenderbotForCausalLM', 'BlenderbotSmallForCausalLM', 'BloomForCausalLM', 'CamembertForCausalLM', 'CodeGenForCausalLM', 'CpmAntForCausalLM', 'CTRLLMHeadModel', 'Data2VecTextForCausalLM', 'ElectraForCausalLM', 'ErnieForCausalLM', 'GitForCausalLM', 'GPT2LMHeadModel', 'GPT2LMHeadModel', 'GPTBigCodeForCausalLM', 'GPTNeoForCausalLM', 'GPTNeoXForCausalLM', 'GPTNeoXJapaneseForCausalLM', 'GPTJForCausalLM', 'LlamaForCausalLM', 'MarianForCausalLM', 'MBartForCausalLM', 'MegaForCausalLM', 'MegatronBertForCausalLM', 'MvpForCausalLM', 'OpenLlamaForCausalLM', 'OpenAIGPTLMHeadModel', 'OPTForCausalLM', 'PegasusForCausalLM', 'PLBartForCausalLM', 'ProphetNetForCausalLM', 'QDQBertLMHeadModel', 'ReformerModelWithLMHead', 'RemBertForCausalLM', 'RobertaForCausalLM', 'RobertaPreLayerNormForCausalLM', 'RoCBertForCausalLM', 'RoFormerForCausalLM', 'RwkvForCausalLM', 'Speech2Text2ForCausalLM', 'TransfoXLLMHeadModel', 'TrOCRForCausalLM', 'XGLMForCausalLM', 'XLMWithLMHeadModel', 'XLMProphetNetForCausalLM', 'XLMRobertaForCausalLM', 'XLMRobertaXLForCausalLM', 'XLNetLMHeadModel', 'XmodForCausalLM'].
```
</p>
</details> 


hi @amyeroberts, can you help me with this?
i am trying to import pipline from transformers in Kaggle Notebook. but i get the following error:
![image](https://github.com/huggingface/transformers/assets/61336360/bd0f2d99-d672-406c-bb30-4d185c1cd058)
![image](https://github.com/huggingface/transformers/assets/61336360/7e29cbae-41a3-4e3a-b473-c75b0486c5a4)



Thanks @bkowshik it worked!

@sgugger @amyeroberts  as annoying as it is, but pipeline in kaggle is not working as seen in [screenshot](https://github.com/huggingface/transformers/issues/23340#issuecomment-1609261696) above. 

It didn't work even when i did this:
`!pip install transformers tokenizers datasets huggingface_hub --upgrade -q`
`!pip install accelerator --upgrade -q`

@RayGone Have posted details of the fix here: https://github.com/huggingface/transformers/issues/23340#issuecomment-1606719159

> @RayGone Have posted details of the fix here: https://github.com/huggingface/transformers/issues/23340#issuecomment-1606719159

Thanks, will try that.
Didn't try that because i wasn't using xformers directly. But i guess its used by some other dependecy. 

I know this is not the exact place for this issue. but somebody help me or direct me to correct place.

I'm getting this error:
`RuntimeError: Unrecognized array dtype object. 
Nested types and image/audio types are not supported yet.`

This happens when i call `model.prepare_tf_dataset`.
The whole code is basically what is given in the text-classification section of NLP course.
@bkowshik @sgugger @amyeroberts 

cc @Rocketknight1 

If you're using Kaggle, make sure that the environment variable is not pinned, this fixed it for me:

![image](https://github.com/huggingface/transformers/assets/56939432/ba489c35-6386-4136-924c-bd842379cd6f)


> Hi @MitchellMonaghan, @Abhranta,
> 
> Could you try upgrading the installed version of accelerate in your env: `pip install -U accelerate`?

Worked for me.

@Abhranta 
Can you please take a look at my case ?


```console
➜  transformers-cli env
2023-08-07 20:40:36.749893: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9346] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-08-07 20:40:36.749932: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-08-07 20:40:36.749940: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-08-07 20:40:36.754844: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/distribution.py:259: ReparameterizationType.__init__ (from tensorflow.python.ops.distributions.distribution) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/bernoulli.py:165: RegisterKL.__init__ (from tensorflow.python.ops.distributions.kullback_leibler) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
Traceback (most recent call last):
  File "~/.local/bin/transformers-cli", line 33, in <module>
    sys.exit(load_entry_point('transformers==4.31.0', 'console_scripts', 'transformers-cli')())
  File "~/.local/bin/transformers-cli", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "~/.local/lib/python3.10/site-packages/transformers/commands/transformers_cli.py", line 25, in <module>
    from .run import RunCommand
  File "~/.local/lib/python3.10/site-packages/transformers/commands/run.py", line 17, in <module>
    from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline
  File "~/.local/lib/python3.10/site-packages/transformers/pipelines/__init__.py", line 69, in <module>
    from .table_question_answering import TableQuestionAnsweringArgumentHandler, TableQuestionAnsweringPipeline
  File "~/.local/lib/python3.10/site-packages/transformers/pipelines/table_question_answering.py", line 26, in <module>
    import tensorflow_probability as tfp
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/__init__.py", line 20, in <module>
    from tensorflow_probability import substrates
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/substrates/__init__.py", line 17, in <module>
    from tensorflow_probability.python.internal import all_util
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/__init__.py", line 138, in <module>
    dir(globals()[pkg_name])  # Forces loading the package from its lazy loader.
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/lazy_loader.py", line 57, in __dir__
    module = self._load()
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/lazy_loader.py", line 40, in _load
    module = importlib.import_module(self.__name__)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/__init__.py", line 31, in <module>
    from tensorflow_probability.python.experimental import bayesopt
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/__init__.py", line 17, in <module>
    from tensorflow_probability.python.experimental.bayesopt import acquisition
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/acquisition/__init__.py", line 17, in <module>
    from tensorflow_probability.python.experimental.bayesopt.acquisition.acquisition_function import AcquisitionFunction
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/acquisition/acquisition_function.py", line 22, in <module>
    from tensorflow_probability.python.internal import prefer_static as ps
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/prefer_static.py", line 361, in <module>
    ones_like = _copy_docstring(tf.ones_like, _ones_like)
  File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/prefer_static.py", line 84, in _copy_docstring
    raise ValueError(
ValueError: Arg specs do not match: original=FullArgSpec(args=['input', 'dtype', 'name', 'layout'], varargs=None, varkw=None, defaults=(None, None, None), kwonlyargs=[], kwonlydefaults=None, annotations={}), new=FullArgSpec(args=['input', 'dtype', 'name'], varargs=None, varkw=None, defaults=(None, None), kwonlyargs=[], kwonlydefaults=None, annotations={}), fn=<function ones_like_v2 at 0x7fba7beb8a60>
```

> @Abhranta Can you please take a look at my case ?
> 
> ```
> ➜  transformers-cli env
> 2023-08-07 20:40:36.749893: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9346] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
> 2023-08-07 20:40:36.749932: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
> 2023-08-07 20:40:36.749940: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
> 2023-08-07 20:40:36.754844: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
> To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
> WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/distribution.py:259: ReparameterizationType.__init__ (from tensorflow.python.ops.distributions.distribution) is deprecated and will be removed after 2019-01-01.
> Instructions for updating:
> The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
> WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/bernoulli.py:165: RegisterKL.__init__ (from tensorflow.python.ops.distributions.kullback_leibler) is deprecated and will be removed after 2019-01-01.
> Instructions for updating:
> The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
> Traceback (most recent call last):
>   File "~/.local/bin/transformers-cli", line 33, in <module>
>     sys.exit(load_entry_point('transformers==4.31.0', 'console_scripts', 'transformers-cli')())
>   File "~/.local/bin/transformers-cli", line 25, in importlib_load_entry_point
>     return next(matches).load()
>   File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
>     module = import_module(match.group('module'))
>   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
>     return _bootstrap._gcd_import(name[level:], package, level)
>   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "~/.local/lib/python3.10/site-packages/transformers/commands/transformers_cli.py", line 25, in <module>
>     from .run import RunCommand
>   File "~/.local/lib/python3.10/site-packages/transformers/commands/run.py", line 17, in <module>
>     from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline
>   File "~/.local/lib/python3.10/site-packages/transformers/pipelines/__init__.py", line 69, in <module>
>     from .table_question_answering import TableQuestionAnsweringArgumentHandler, TableQuestionAnsweringPipeline
>   File "~/.local/lib/python3.10/site-packages/transformers/pipelines/table_question_answering.py", line 26, in <module>
>     import tensorflow_probability as tfp
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/__init__.py", line 20, in <module>
>     from tensorflow_probability import substrates
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/substrates/__init__.py", line 17, in <module>
>     from tensorflow_probability.python.internal import all_util
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/__init__.py", line 138, in <module>
>     dir(globals()[pkg_name])  # Forces loading the package from its lazy loader.
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/lazy_loader.py", line 57, in __dir__
>     module = self._load()
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/lazy_loader.py", line 40, in _load
>     module = importlib.import_module(self.__name__)
>   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
>     return _bootstrap._gcd_import(name[level:], package, level)
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/__init__.py", line 31, in <module>
>     from tensorflow_probability.python.experimental import bayesopt
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/__init__.py", line 17, in <module>
>     from tensorflow_probability.python.experimental.bayesopt import acquisition
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/acquisition/__init__.py", line 17, in <module>
>     from tensorflow_probability.python.experimental.bayesopt.acquisition.acquisition_function import AcquisitionFunction
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/experimental/bayesopt/acquisition/acquisition_function.py", line 22, in <module>
>     from tensorflow_probability.python.internal import prefer_static as ps
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/prefer_static.py", line 361, in <module>
>     ones_like = _copy_docstring(tf.ones_like, _ones_like)
>   File "~/.local/lib/python3.10/site-packages/tensorflow_probability/python/internal/prefer_static.py", line 84, in _copy_docstring
>     raise ValueError(
> ValueError: Arg specs do not match: original=FullArgSpec(args=['input', 'dtype', 'name', 'layout'], varargs=None, varkw=None, defaults=(None, None, None), kwonlyargs=[], kwonlydefaults=None, annotations={}), new=FullArgSpec(args=['input', 'dtype', 'name'], varargs=None, varkw=None, defaults=(None, None), kwonlyargs=[], kwonlydefaults=None, annotations={}), fn=<function ones_like_v2 at 0x7fba7beb8a60>
> ```

Sorry, problem solved by manually build [tensorflow-probability](https://github.com/tensorflow/probability).

```console
➜  ~ transformers-cli env
2023-08-07 21:04:43.751890: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9346] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-08-07 21:04:43.751926: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-08-07 21:04:43.751932: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/distribution.py:259: ReparameterizationType.__init__ (from tensorflow.python.ops.distributions.distribution) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/tensorflow/python/ops/distributions/bernoulli.py:165: RegisterKL.__init__ (from tensorflow.python.ops.distributions.kullback_leibler) is deprecated and will be removed after 2019-01-01.
Instructions for updating:
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
WARNING:tensorflow:From ~/.local/lib/python3.10/site-packages/transformers/commands/env.py:100: 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.

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.31.0
- Platform: Linux-6.2.0-26-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.16.4
- Safetensors version: 0.3.1
- Accelerate version: 0.21.0
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.1.0a0+gitaaa989c (True)
- Tensorflow version (GPU?): 2.15.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.7.1 (gpu)
- Jax version: 0.4.14
- JaxLib version: 0.4.14
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

➜  ~ 
```

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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Hi, I am getting this issue while importing Trainer

`RuntimeError: Failed to import transformers.trainer because of the following error (look up to see its traceback):
Can't instantiate abstract class MPS_Accelerator with abstract methods supported_dtypes
`
Running transformers-cli env gives the following output:

`Traceback (most recent call last):
  File "/Users/shashankgupta/.conda/envs/deepspeed/bin/transformers-cli", line 5, in <module>
    from transformers.commands.transformers_cli import main
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/commands/transformers_cli.py", line 25, in <module>
    from .run import RunCommand
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/commands/run.py", line 17, in <module>
    from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/pipelines/__init__.py", line 46, in <module>
    from .audio_classification import AudioClassificationPipeline
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/pipelines/audio_classification.py", line 21, in <module>
    from .base import PIPELINE_INIT_ARGS, Pipeline
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/pipelines/base.py", line 34, in <module>
    from ..modelcard import ModelCard
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/modelcard.py", line 48, in <module>
    from .training_args import ParallelMode
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/transformers/training_args.py", line 69, in <module>
    from accelerate.state import AcceleratorState, PartialState
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/__init__.py", line 3, in <module>
    from .accelerator import Accelerator
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/accelerator.py", line 35, in <module>
    from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/checkpointing.py", line 24, in <module>
    from .utils import (
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/utils/__init__.py", line 136, in <module>
    from .launch import (
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/utils/launch.py", line 33, in <module>
    from ..utils.other import is_port_in_use, merge_dicts
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/accelerate/utils/other.py", line 32, in <module>
    from deepspeed import DeepSpeedEngine
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/__init__.py", line 21, in <module>
    from . import ops
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/ops/__init__.py", line 6, in <module>
    from . import adam
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/ops/adam/__init__.py", line 6, in <module>
    from .cpu_adam import DeepSpeedCPUAdam
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/ops/adam/cpu_adam.py", line 8, in <module>
    from deepspeed.utils import logger
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/utils/__init__.py", line 10, in <module>
    from .groups import *
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/utils/groups.py", line 28, in <module>
    from deepspeed import comm as dist
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/comm/__init__.py", line 7, in <module>
    from .comm import *
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/comm/comm.py", line 34, in <module>
    from deepspeed.utils import timer, get_caller_func
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/utils/timer.py", line 31, in <module>
    class CudaEventTimer(object):
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/utils/timer.py", line 33, in CudaEventTimer
    def __init__(self, start_event: get_accelerator().Event, end_event: get_accelerator().Event):
  File "/Users/shashankgupta/.conda/envs/deepspeed/lib/python3.8/site-packages/deepspeed/accelerator/real_accelerator.py", line 155, in get_accelerator
    ds_accelerator = MPS_Accelerator()
TypeError: Can't instantiate abstract class MPS_Accelerator with abstract methods supported_dtypes
`

Versions I am using: 

```
accelerate         0.22.0
einops             0.6.1
torch              2.0.1
transformers       4.33.0

```

Hi @shashank140195, could you open a new issue? Please make sure the errors are properly formatted in multi-line markdown code formatting i.e. between a pair of three backticks ` ``` Traceback goes here ``` `

Hi, I am getting this error while executing the file. I have tried all the possible solution but not to get the solution as of now. If anyone knows please help me out of this.

Traceback (most recent call last):
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1184, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "importlib\__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\__init__.py", line 62, in <module>
    from .document_question_answering import DocumentQuestionAnsweringPipeline
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\document_question_answering.py", line 29, in <module>
    from .question_answering import select_starts_ends
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\question_answering.py", line 9, in <module>
    from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\data\__init__.py", line 15, in <module>
    from .data_collator import (
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\data\data_collator.py", line 24, in <module>
    from ..models.bert import BertTokenizer, BertTokenizerFast
ImportError: cannot import name 'BertTokenizerFast' from 'transformers.models.bert' (C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\models\bert\__init__.py)


The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
  File "v2n.py", line 54, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\__init__.py", line 1, in <module>
    from .transcribe import load_model
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\transcribe.py", line 10, in <module>
    from .asr import load_model
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\asr.py", line 9, in <module>
    from transformers import Pipeline
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1174, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1186, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'BertTokenizerFast' from 'transformers.models.bert' (C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\models\bert\__init__.py)

hey @kknagi could you share which transformers version you are using?

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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Hi I also have a similar issue but not with accelerate but numpy

```RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'AutoModelForImageToImage' from 'transformers.models.auto.modeling_auto' (/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/models/auto/modeling_auto.py)
```

transformers-cli env gives:
```2023-12-11 13:51:14.425923: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-11 13:51:15.375941: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1382, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "/opt/conda/envs/prototype/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/models/auto/image_processing_auto.py", line 26, in <module>
    from ...image_processing_utils import ImageProcessingMixin
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/image_processing_utils.py", line 28, in <module>
    from .image_transforms import center_crop, normalize, rescale
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/image_transforms.py", line 47, in <module>
    import tensorflow as tf
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/__init__.py", line 38, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python.feature_column import feature_column_lib as feature_column
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/feature_column/feature_column_lib.py", line 18, in <module>
    from tensorflow.python.feature_column.feature_column import *
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/feature_column/feature_column.py", line 143, in <module>
    from tensorflow.python.layers import base
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/layers/base.py", line 16, in <module>
    from tensorflow.python.keras.legacy_tf_layers import base
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/keras/__init__.py", line 25, in <module>
    from tensorflow.python.keras import models
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/keras/models.py", line 22, in <module>
    from tensorflow.python.keras.engine import functional
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/keras/engine/functional.py", line 32, in <module>
    from tensorflow.python.keras.engine import training as training_lib
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 53, in <module>
    from tensorflow.python.keras.saving import hdf5_format
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 37, in <module>
    import h5py
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/h5py/__init__.py", line 46, in <module>
    from ._conv import register_converters as _register_converters
  File "h5py/h5t.pxd", line 14, in init h5py._conv
  File "h5py/h5t.pyx", line 293, in init h5py.h5t
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/prototype/bin/transformers-cli", line 5, in <module>
    from transformers.commands.transformers_cli import main
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/commands/transformers_cli.py", line 24, in <module>
    from .pt_to_tf import PTtoTFCommand
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/commands/pt_to_tf.py", line 24, in <module>
    from .. import (
  File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1373, in __getattr__
    value = getattr(module, name)
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1372, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/opt/conda/envs/prototype/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1384, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.models.auto.image_processing_auto because of the following error (look up to see its traceback):
module 'numpy' has no attribute 'typeDict
```

Numpy is at its latest version 1.24.4

Hi @Abhranta, as the cause is something different, could you open a new issue? In the issue, can you include the version of tensorflow being used, as error appears to be triggered inside TF.

> Hi, I am getting this error while executing the file. I have tried all the possible solution but not to get the solution as of now. If anyone knows please help me out of this.
> 
> Traceback (most recent call last):
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1184, in _get_module
>     return importlib.import_module("." + module_name, self.__name__)
>   File "importlib\__init__.py", line 126, in import_module
>   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\__init__.py", line 62, in <module>
>     from .document_question_answering import DocumentQuestionAnsweringPipeline
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\document_question_answering.py", line 29, in <module>
>     from .question_answering import select_starts_ends
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\pipelines\question_answering.py", line 9, in <module>
>     from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\data\__init__.py", line 15, in <module>
>     from .data_collator import (
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\data\data_collator.py", line 24, in <module>
>     from ..models.bert import BertTokenizer, BertTokenizerFast
> ImportError: cannot import name 'BertTokenizerFast' from 'transformers.models.bert' (C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\models\bert\__init__.py)
> 
> 
> The above exception was the direct cause of the following exception:
> 
>  Traceback (most recent call last):
>   File "v2n.py", line 54, in <module>
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\__init__.py", line 1, in <module>
>     from .transcribe import load_model
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\transcribe.py", line 10, in <module>
>     from .asr import load_model
>   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
>   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
>   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
>   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
>   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\whisperx\asr.py", line 9, in <module>
>     from transformers import Pipeline
>   File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1174, in __getattr__
>     module = self._get_module(self._class_to_module[name])
>   File "C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\utils\import_utils.py", line 1186, in _get_module
>     raise RuntimeError(
> RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
> cannot import name 'BertTokenizerFast' from 'transformers.models.bert' (C:\Users\kapil\AppData\Local\Temp\_MEI637282\transformers\models\bert\__init__.py)

Got the solutions brother?

 i have installed the latest version of transformers and accelerate but still facing this issue:
 
 Traceback (most recent call last):
  File "loadingmodel.py", line 238, in <module>
    from transformers import pipeline
  File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
  File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1354, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1366, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'pipeline' from 'transformers'

> i have installed the latest version of transformers and accelerate but still facing this issue:
> 
> Traceback (most recent call last): File "loadingmodel.py", line 238, in from transformers import pipeline File "", line 1039, in _handle_fromlist File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1354, in **getattr** module = self._get_module(self._class_to_module[name]) File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1366, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): cannot import name 'pipeline' from 'transformers'

Hi, it works for me though. Can you try installing the transformers from the source?

`pip install git+https://github.com/huggingface/transformers`

Can't reproduce this in anyway with `transformers==4.37` or dev

> > i have installed the latest version of transformers and accelerate but still facing this issue:
> > Traceback (most recent call last): File "loadingmodel.py", line 238, in from transformers import pipeline File "", line 1039, in _handle_fromlist File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1354, in **getattr** module = self._get_module(self._class_to_module[name]) File "/home/ubuntu/Mistral/.envv/lib/python3.8/site-packages/transformers/utils/import_utils.py", line 1366, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): cannot import name 'pipeline' from 'transformers'
> 
> Hi, it works for me though. Can you try installing the transformers from the source?
> 
> `pip install git+https://github.com/huggingface/transformers`

i tried this but it didn't work

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
/opt/conda/lib/python3.10/site-packages/_XLAC.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZNK5torch4lazy17LazyGraphExecutor16ShouldSyncTensorEN3c1013intrusive_ptrINS0_10LazyTensorENS2_6detail34intrusive_target_default_null_typeIS4_EEEE

Anyone faced this issue? 

have you installed the latest version??
i faced this issue, but with the latest version you will not get this error.

Hello, I am also having this same issue.  I am trying to run  'from transformers import AutoTokenizer, AutoModel, pipeline', and it gives the following error:
![992864538c5081cd81edda35c67ecfb](https://github.com/huggingface/transformers/assets/85532653/0e0ddb89-6fb2-472e-a9a9-0a9f8f6b4984)
Here is the output from my transformers-cli env:

![8762f45c00838487160c9d2f067cf5f](https://github.com/huggingface/transformers/assets/85532653/71581c2b-017c-49f7-b98a-5368b6ad58a8)



contact me on this no i got same issue i have solution 919616714403

`pip install protobuf==3.23`

> ### System Info
> I am trying to import Segment Anything Model (SAM) using transformers pipeline. But this gives the following error : " RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): cannot import name 'PartialState' from 'accelerate' (/opt/conda/lib/python3.10/site-packages/accelerate/**init**.py)"
> 
> What i am trying to do : " from transformers import pipeline generator = pipeline("mask-generation", model="facebook/sam-vit-huge", device=0) "
> 
> ### 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
> import this line:
> 
> from transformers import pipeline generator = pipeline("mask-generation", model="facebook/sam-vit-huge", device=0)
> 
> ### Expected behavior
> The model should import as per this notebook in official tutorials: https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb

I think you should update or pip install another tensorflow version for your notebook!

![Image](https://github.com/user-attachments/assets/637b74b6-020f-4105-90b1-cf2b397a2d38)

![Image](https://github.com/user-attachments/assets/2082e054-671c-4718-8d01-2d5d4b209c1e)

pls help, i doing all how in this gude https://www.youtube.com/watch?v=7noh48reHak  but on ma pc it dont work.