visual-chatgpt icon indicating copy to clipboard operation
visual-chatgpt copied to clipboard

Failed to import transformers

Open Garbage123King opened this issue 1 year ago • 25 comments

RuntimeError: Failed to import transformers.models.clipseg.modeling_clipseg because of the following error (look up to see its traceback): /usr/local/lib/python3.8/dist-packages/transformer_engine_extensions.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN2at4_ops5zeros4callEN3c108ArrayRefINS2_6SymIntEEENS2_8optionalINS2_10ScalarTypeEEENS6_INS2_6LayoutEEENS6_INS2_6DeviceEEENS6_IbEE

Garbage123King avatar Mar 12 '23 11:03 Garbage123King

The error message you're seeing suggests that there is an issue with the transformers package in your Python environment. Specifically, it seems that there may be a problem with the transformer_engine_extensions.cpython-38-x86_64-linux-gnu.so module, which is failing to import the transformers.models.clipseg.modeling_clipseg module.

Khaleelhabeeb avatar Mar 12 '23 13:03 Khaleelhabeeb

I am having the same error

transformers 4.29.2 python 3.9

Abecid avatar May 18 '23 06:05 Abecid

Hi, I solved this by pip uninstall transformer-engine

cdxeve avatar May 27 '23 13:05 cdxeve

I got the same problem. python 3.10.12 transformers 4.27.1 or 4.30.2

jarry avatar Aug 15 '23 10:08 jarry

Anyone found out why this happens?

vincenzoml avatar Aug 23 '23 15:08 vincenzoml

I have the same problem.

uasolo avatar Oct 18 '23 14:10 uasolo

me too

python 3.10 transformers 4.28


File /usr/local/lib/python3.10/dist-packages/transformer_engine/pytorch/cpp_extensions/__init__.py:6
      1 # Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
      2 #
      3 # See LICENSE for license information.
      5 """Python interface for c++ extensions"""
----> 6 from transformer_engine_extensions import *
      8 from .fused_attn import *
      9 from .gemm import *

ImportError: /usr/local/lib/python3.10/dist-packages/transformer_engine_extensions.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

venergiac-bh avatar Oct 24 '23 16:10 venergiac-bh

Anyone found out why this happens?

The reason seem obvious

>>> import torch
>>> torch.compiled_with_cxx11_abi() 
False
>>> torch.__version__
'2.1.0+cu121'

Community pytorch is always compiled and released with -D_GLIBCXX_USE_CXX11_ABI=0

However transformer_engine_extensions is compiled and released with -D_GLIBCXX_USE_CXX11_ABI=1 thus it's looking for a symbol with CXX11 ABI -- torch::jit::parseSchemaOrName(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)

I guess nvidia compiles everything with -D_GLIBCXX_USE_CXX11_ABI=1 within the NGC docker so they could work along.

But if you install pytorch from pip install then boooooom.

kevint324 avatar Oct 27 '23 09:10 kevint324

Hi, I solved this by pip uninstall transformer-engine

感谢!我也是这么解决的

eigen2017 avatar Dec 07 '23 07:12 eigen2017

Hi, I solved this by pip uninstall transformer-engine

aryamtos avatar Jan 08 '24 01:01 aryamtos

Hi, I solved this by pip uninstall transformer-engine

thanks, this work for me!

my error:

transformer_engine_extensions.cpython-38-x86_64-linux-gnu.so: undefined symbol

xuleichao avatar Jan 30 '24 10:01 xuleichao

Anyone found out why this happens?

The reason seem obvious

>>> import torch
>>> torch.compiled_with_cxx11_abi() 
False
>>> torch.__version__
'2.1.0+cu121'

Community pytorch is always compiled and released with -D_GLIBCXX_USE_CXX11_ABI=0

However transformer_engine_extensions is compiled and released with -D_GLIBCXX_USE_CXX11_ABI=1 thus it's looking for a symbol with CXX11 ABI -- torch::jit::parseSchemaOrName(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)

I guess nvidia compiles everything with -D_GLIBCXX_USE_CXX11_ABI=1 within the NGC docker so they could work along.

But if you install pytorch from pip install then boooooom.

@kevint324 hi, thanks for your answer! any solutions to this instead of uninstall transformer_engine? how should we pip install torch?

yqy2001 avatar Feb 02 '24 03:02 yqy2001

Anyone found out why this happens?

The reason seem obvious

>>> import torch
>>> torch.compiled_with_cxx11_abi() 
False
>>> torch.__version__
'2.1.0+cu121'

Community pytorch is always compiled and released with -D_GLIBCXX_USE_CXX11_ABI=0 However transformer_engine_extensions is compiled and released with -D_GLIBCXX_USE_CXX11_ABI=1 thus it's looking for a symbol with CXX11 ABI -- torch::jit::parseSchemaOrName(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) I guess nvidia compiles everything with -D_GLIBCXX_USE_CXX11_ABI=1 within the NGC docker so they could work along. But if you install pytorch from pip install then boooooom.

@kevint324 hi, thanks for your answer! any solutions to this instead of uninstall transformer_engine? how should we pip install torch?

Do NOT install torch from pip. Just pull any ngc docker and use the pytorch out of the box.

kevint324 avatar Feb 02 '24 03:02 kevint324

I managed to solve it after this: pip uninstall transformers-y And then install the transformers: pip install transformers

Got: import transformers transformers.__version__: 4.38.0.dev0

Harshpatil317 avatar Feb 05 '24 06:02 Harshpatil317

pip uninstall transformer-engine then, pip install transformers

AkshataABhat avatar Feb 20 '24 07:02 AkshataABhat

Got new error for pipeline how to rectify this :

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback): /usr/local/lib/python3.10/dist-packages/transformer_engine_extensions.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

aayushivt30 avatar Apr 22 '24 20:04 aayushivt30

Hi, I solved this by pip uninstall transformer-engine

Me too. Thanks a lot!

vegetable-yx avatar Apr 24 '24 08:04 vegetable-yx

Hi, I solved this by pip uninstall transformer-engine

pip uninstall transformer-engine then, pip install transformers

AkshataABhat avatar Apr 24 '24 09:04 AkshataABhat

Got permission error for pip uninstall transformer-engine then, pip install transformers

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/libtransformer_engine.so'

aayushivt30 avatar Apr 24 '24 10:04 aayushivt30

Got permission error for pip uninstall transformer-engine then, pip install transformers

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/libtransformer_engine.so'

The folder you are trying to install it to does not have permissions.

you should ideally create a virtual env and install there. If not install as super user using sudo.

AkshataABhat avatar Apr 24 '24 10:04 AkshataABhat

Hi, I solved this by pip uninstall transformer-engine

nice! it works

ningshixian avatar Jun 19 '24 01:06 ningshixian

Hi, I solved this by pip uninstall transformer-engine

完美,困扰我好久了,终于解决了

marvelcell avatar Jun 27 '24 08:06 marvelcell

Hi, I solved this by pip uninstall transformer-engine

完美,困扰我好久了,终于解决了

不用谢😁

cdxeve avatar Jun 27 '24 08:06 cdxeve

I got the same problem. And in my situation, it may because of the confliction between transformer-engine and accelerate library. So uninstalling one of them would solve it.

hqzhuang672 avatar Jul 15 '24 12:07 hqzhuang672

uninstall transormer_engine works. For me this problem occured when I tried to import groundingdino, which uses transformers. It may be because my superior upgraded pytorch in the image after installed the requirements.

FitzFitzFitz avatar Aug 09 '24 02:08 FitzFitzFitz