k2-fsa / k2

FSA/FST algorithms, differentiable, with PyTorch compatibility.
https://k2-fsa.github.io/k2
Apache License 2.0
1.11k stars 213 forks source link

`GLIBCXX_3.4.20' not found #1174

Closed zjwang21 closed 1 year ago

zjwang21 commented 1 year ago

Installing from source

pip install torch-1.13.1+cpu-cp39-cp39-linux_x86_64.whl, git clone https://github.com/k2-fsa/k2.git cd k2 export K2_MAKE_ARGS="-j12" export K2_CMAKE_ARGS="-DK2_WITH_CUDA=OFF" python setup.py install the outputs of python -m k2.version seems right. but when I try to run my project, the following error occurs:

import k2 File "/mnt/cache/wangzhijun2/anaconda3/envs/speech/lib/python3.9/site-packages/k2-1.23.4.dev20230324+cpu.torch1.13.1-py3.9-linux-x86_64.egg/k2/__init__.py", line 23, in <module> from _k2 import DeterminizeWeightPushingType from _k2 import DeterminizeWeightPushingType ImportError: /lib64/libstdc++.so.6: versionGLIBCXX_3.4.20' not found (required by /mnt/cache/wangzhijun2/anaconda3/envs/speech/lib/python3.9/site-packages/k2-1.23.4.dev20230324+cpu.torch1.13.1-py3.9-linux-x86_64.egg/k2/lib64/libk2fsa.so) from _k2 import DeterminizeWeightPushingType `

csukuangfj commented 1 year ago

Please make sure you have uninstalled previous version of k2 installed via conda install.

The safest way is to create a new virtual environment to install k2. If the issue still exists, we can look into it.

zjwang21 commented 1 year ago

Please make sure you have uninstalled previous version of k2 installed via conda install.

The safest way is to create a new virtual environment to install k2. If the issue still exists, we can look into it.

I have tried your suggestions. I am installing k2 from sourcet rather than conda because I cannot reach the network. The issue still exists. looking forward to your suggestions.

csukuangfj commented 1 year ago

Have you created a fresh virtual environment to install k2?

Also, please use pip install to install PyTorch if you want to install k2 from source.

zjwang21 commented 1 year ago

Have you created a fresh virtual environment to install k2?

Also, please use pip install to install PyTorch if you want to install k2 from source.

Yes, I installed all the pkgs through pip, except that I create the virtual environment by conda.

csukuangfj commented 1 year ago

Did you install k2 before using conda install?

Please check that there is only one file _k2*.so on the python module search path in your environment.

zjwang21 commented 1 year ago

Did you install k2 before using conda install?

Please check that there is only one file _k2*.so on the python module search path in your environment.

I found that this error occurs when I run k2 on the slrum nodes. When I run srun -p speech --gpus-per-task 1 strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX_3.4.20 it returns nothing. Perhaps this error is caught by the lack of GLIBCXX_3.4.20. I wonder if there is a way to use GLIBCXX_3.4.19 or lower with k2, otherwise, I will have to install GLIBCXX_3.4.20.

csukuangfj commented 1 year ago

If you install k2 from source and have this issue, possible reasons are listed below:

  1. k2 was compiled on one system but you are running it on a different system.

  2. You have used conda instal to install k2 but you don't remove it before you install k2 from source.

  3. You are using GCC installed by conda to compile k2 but you use system libstdc++ to run k2.

Do you match one of the items above?

zjwang21 commented 1 year ago

Sorry for wasting your time. I use gcc 7.5.0 to install k2, but I forget to export the lib64 path of gcc 7.5.0. After that, k2 works fine. Thanks for your reply~