From pre-compiled wheels (recommended)
We provide pre-compiled wheels for the following platforms:
We recommend that you use this approach to install k2.
Hint
Please always install the latest version of k2.
Installation examples
We provide several examples below to show you how to install k2
Linux (CPU) example
Suppose that we want to install the following wheel
https://huggingface.co/csukuangfj/k2/resolve/main/cpu/k2-1.24.3.dev20230719+cpu.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
we can use one of the following methods:
# method 1
pip install torch==2.0.1+cpu -f https://download.pytorch.org/whl/torch/
pip install k2==1.24.3.dev20230719+cpu.torch2.0.1 -f https://k2-fsa.github.io/k2/cpu.html
# method 2
pip install torch==2.0.1+cpu -f https://download.pytorch.org/whl/torch/
wget https://huggingface.co/csukuangfj/k2/resolve/main/cpu/k2-1.24.3.dev20230719+cpu.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# For users from China
# 中国国内用户,如果访问不了 huggingface, 请使用
# wget https://hf-mirror.com/csukuangfj/k2/resolve/main/cpu/k2-1.24.3.dev20230719+cpu.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip install ./k2-1.24.3.dev20230719+cpu.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Hint
You can visit https://k2-fsa.github.io/k2/cpu.html to see avaiable versions of k2.
For users from China, please visit https://k2-fsa.github.io/k2/cpu-cn.html to see avaiable versions of k2.
macOS (CPU) example
Suppose we want to use the following wheel:
https://huggingface.co/csukuangfj/k2/resolve/main/macos/k2-1.24.3.dev20230720+cpu.torch2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
we can use the following methods:
# method 1
pip install torch==2.0.1
pip install k2==1.24.3.dev20230720+cpu.torch2.0.1 -f https://k2-fsa.github.io/k2/cpu.html
# method 2
pip install torch==2.0.1
wget https://huggingface.co/csukuangfj/k2/resolve/main/macos/k2-1.24.3.dev20230720+cpu.torch2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
# For users from China
# 中国国内用户,如果访问不了 huggingface, 请使用
# wget https://hf-mirror.com/csukuangfj/k2/resolve/main/macos/k2-1.24.3.dev20230720+cpu.torch2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
pip install ./k2-1.24.3.dev20230720+cpu.torch2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Hint
You can visit https://k2-fsa.github.io/k2/cpu.html to see avaiable versions of k2.
For users from China, please visit https://k2-fsa.github.io/k2/cpu-cn.html to see avaiable versions of k2.
Windows (CPU) example
Suppose we want to install the following wheel
https://huggingface.co/csukuangfj/k2/resolve/main/windows-cpu/k2-1.24.3.dev20230726+cpu.torch2.0.1-cp38-cp38-win_amd64.whl
we can use the one of the following methods:
# method 1
pip install torch==2.0.1+cpu -f https://download.pytorch.org/whl/torch/
pip install k2==1.24.3.dev20230726+cpu.torch2.0.1 -f https://k2-fsa.github.io/k2/cpu.html
# method 2
pip install torch==2.0.1+cpu -f https://download.pytorch.org/whl/torch/
wget https://huggingface.co/csukuangfj/k2/resolve/main/windows-cpu/k2-1.24.3.dev20230726+cpu.torch2.0.1-cp38-cp38-win_amd64.whl
# For users from China
# 中国国内用户,如果访问不了 huggingface, 请使用
# wget https://hf-mirror.com/csukuangfj/k2/resolve/main/windows-cpu/k2-1.24.3.dev20230726+cpu.torch2.0.1-cp38-cp38-win_amd64.whl
pip install k2-1.24.3.dev20230726+cpu.torch2.0.1-cp38-cp38-win_amd64.whl
Hint
If you want to build k2 with CUDA support on Windows, please consider compiling k2 from source.
Hint
You can visit https://k2-fsa.github.io/k2/cpu.html to see avaiable versions of k2.
For users from China, please visit https://k2-fsa.github.io/k2/cpu-cn.html to see avaiable versions of k2.
Linux (CUDA) example
Suppose we want to install
https://huggingface.co/csukuangfj/k2/resolve/main/cuda/k2-1.24.3.dev20230718+cuda11.7.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
we can use the following methods:
# method 1
pip install torch==2.0.1+cu117 -f https://download.pytorch.org/whl/torch/
pip install k2==1.24.3.dev20230718+cuda11.7.torch2.0.1 -f https://k2-fsa.github.io/k2/cuda.html
# method 2
pip install torch==2.0.1+cu117 -f https://download.pytorch.org/whl/torch/
wget https://huggingface.co/csukuangfj/k2/resolve/main/cuda/k2-1.24.3.dev20230718+cuda11.7.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
# For users from China
# 中国国内用户,如果访问不了 huggingface, 请使用
# wget https://hf-mirror.com/csukuangfj/k2/resolve/main/cuda/k2-1.24.3.dev20230718+cuda11.7.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip install ./k2-1.24.3.dev20230718+cuda11.7.torch2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Hint
You can visit https://k2-fsa.github.io/k2/cuda.html to see avaiable versions of k2.
For users from China, please visit https://k2-fsa.github.io/k2/cuda-cn.html to see avaiable versions of k2.