ImportError: /lib64/libm.so.6: version ‘GLIBC_2.27’ not found

If you have this issue, it is very likely that you used conda install to install k2.

The conda package is compiled using Ubuntu 18.04. If your system is too old, you will get such an issue.

The most straightforward way to fix it is to Install from source.

error: Downloading https://github.com/pybind/pybind11/archive/v2.6.0.tar.gz failed

If you have no access to the Internet, you will get such an issue when installing k2 from source.

Please try to find a machine that has access to the Internet, download pybind11, and copy the downloaded file to the machine you use to compile k2.

The commands you need are as follows:

# assume that you place the downloaded file in the /tmp directory
cd /tmp
wget https://github.com/pybind/pybind11/archive/v2.6.0.tar.gz

and then change https://github.com/k2-fsa/k2/blob/master/cmake/pybind11.cmake#L23:

# set(pybind11_URL  "https://github.com/pybind/pybind11/archive/v2.6.0.tar.gz")
set(pybind11_URL  "file:///tmp/v2.6.0.tar.gz")

Error: invalid device function

If you get the following error while running k2:

[F] /xxx/k2/k2-latest/k2/csrc/eval.h:147:void k2::EvalDevice(cudaStream_t,
int32_t, LambdaT&) [with LambdaT = __nv_dl_wrapper_t<__nv_dl_tag<k2::Array1<int>
(*)(std::shared_ptr<k2::Context>, int, int, int), k2::Range<int>, 1>, int*,
int, int>; cudaStream_t = CUstream_st*; int32_t = int] Check failed:
e == cudaSuccess (98 vs. 0)  Error: invalid device function.

you have probably installed k2 from source. However, you are NOT running k2 on the same machine as the one you used to build k2 and the two machines have different types of GPUs.

The fix is to pass -DK2_BUILD_FOR_ALL_ARCHS=ON to cmake.

If you have followed For developers to install k2, you need to change

cmake -DCMAKE_BUILD_TYPE=Release ..



If you have followed Install from source to install k2, you need to change

git clone https://github.com/k2-fsa/k2.git
cd k2
python3 setup.py install


git clone https://github.com/k2-fsa/k2.git
cd k2
python3 setup.py install

#error C++14 or later compatible compiler is required to use ATen

If you encounter this error, it means you need to update your GCC.

What if it throws the same error after updating GCC?

The solution is to setup the following environment variables after updating GCC:

# Please change gcc_dir accordingly

export CC=$gcc_dir/bin/gcc
export CXX=$gcc_dir/bin/g++
export LIBRARY_PATH=$gcc_dir/lib64:$LIBRARY_PATH
export LD_LIBRARY_PATH=$gcc_dir/lib64:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$gcc_dir/include
export CPLUS_INCLUDE_PATH=$gcc_dir/include


After setting the above environment variables, please run:

rm -rf

before you start to re-build k2.

relocation R_X86_64_PC32 against symbol `_PyRuntime’ can not be used when making a shared object; recompile with -fPIC

The error indicates that your Python is statically linked. Please pass --enable-shared to ./configure when you compile Python from source.

See also https://github.com/k2-fsa/k2/issues/1225

ImportError: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

Please see https://github.com/k2-fsa/k2/issues/1011. You need to set the environment variable LD_LIBRARY_PATH.

/usr/bin/ld: cannot find -lPYTHON_LIBRARY-NOTFOUND

Please see https://github.com/k2-fsa/k2/issues/1038.