Install from source

Before installing sherpa, you have to install PyTorch and k2. If you want to install a CUDA version of sherpa, please install a CUDA version of PyTorch and k2.

Supported operating systems, Python versions, PyTorch versions, and CUDA versions are listed as follows:

  • Supported operating systems

  • Supported python versions

  • Supported pytorch versions

  • Supported cuda versions


If you install a CUDA version of PyTorch, please also install cuDNN. Otherwise, you will get CMake configuration errors later.

Install PyTorch

Please refer to to install PyTorch.

Install k2

Please refer to to install k2. You have to install k2 >= v1.16.

Install sherpa

git clone
cd sherpa

# Install the dependencies
pip install -r ./requirements.txt

# Install the C++ extension.
# Use one of the following methods:
# (1)
python3 install --verbose
# (2)
# pip install --verbose k2-sherpa

# To uninstall the C++ extension, use
# pip uninstall k2-sherpa


You can use either python3 install --verbose or pip install --verbose k2-sherpa to install the C++ extension.

python3 install always installs the latest version.


Refer to How to fix Caffe2: Cannot find cuDNN library if you encouter this problem during installation.


pip install -r ./requirements.txt won’t install all dependencies of sherpa. You have to install PyTorch and k2 before you install sherpa.

To check that you have installed sherpa successfully, run

python3 -c "import sherpa; print(sherpa.__version__)"

It should print the version of sherpa.


You have installed sherpa successfully. Let us start to play with it.

The following shows you a YouTube video, demonstrating streaming ASR with sherpa.


If you have no access to YouTube, please visit the following link from bilibili

Read more to see how to use sherpa for streaming ASR and non-streaming ASR.