-
-
Save desh2608/4521051ef30872aeb89555ce620c3bf8 to your computer and use it in GitHub Desktop.
Steps needed to install K2 from scratch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Do not run the commented lines | |
# First git clone k2 and cd to inside it. | |
# Common steps | |
conda create -n k2 python=3.8 | |
conda activate k2 | |
# Install PyTorch and Torchaudio | |
pip install torch==1.8.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html | |
pip install cmake | |
# mkdir build | |
# pushd build | |
# CONDA_ROOT="$(conda config --show root_prefix | cut -f2 -d' ')" | |
# CONDA_ENV_DIR="$CONDA_ROOT/envs/k2" | |
# Suppose you want to install it with CUDA 11.1 and CUDNN 8.0 | |
# See /cm/shared/apps for other options | |
CUDNN_LIBRARY_PATH=/cm/shared/apps/cudnn/8.0.2_cuda11.0/lib64 | |
CUDNN_INCLUDE_PATH=/cm/shared/apps/cudnn/8.0.2_cuda11.0/include | |
CUDA_TOOLKIT_DIR=/cm/shared/apps/cuda11.1 | |
cmake \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_CUDA_COMPILER=$(which nvcc) \ | |
-DPYTHON_EXECUTABLE=$(which python) \ | |
-DCUDNN_LIBRARY_PATH=$CUDNN_LIBRARY_PATH/libcudnn.so \ | |
-DCUDNN_INCLUDE_PATH=$CUDNN_INCLUDE_PATH \ | |
-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_DIR \ | |
.. | |
# make -j24 _k2 | |
# popd | |
# When updating and rebuilding K2, before executing these steps, run: | |
# rm -rf dist/ | |
K2_CMAKE_ARGS="-DCUDNN_LIBRARY_PATH=$CUDNN_LIBRARY_PATH/libcudnn.so -DCUDNN_INCLUDE_PATH=$CUDNN_INCLUDE_PATH -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_DIR" | |
scripts/build_pip.sh | |
pip install dist/* | |
# Other tools that may be required to install | |
# kaldifeat | |
export KALDIFEAT_CMAKE_ARGS="-DCUDNN_LIBRARY_PATH=$CUDNN_LIBRARY_PATH/libcudnn.so -DCUDNN_INCLUDE_PATH=$CUDNN_INCLUDE_PATH -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_DIR" | |
pip install --verbose kaldifeat | |
# optimized_transducer | |
export OT_CMAKE_ARGS="-DCUDNN_LIBRARY_PATH=$CUDNN_LIBRARY_PATH/libcudnn.so -DCUDNN_INCLUDE_PATH=$CUDNN_INCLUDE_PATH -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_DIR" | |
pip install --verbose optimized_transducer | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment