Skip to content

Instantly share code, notes, and snippets.

@pzelasko
Last active February 25, 2022 05:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save pzelasko/c5c84a27a9107c27c40ff3d43a28526b to your computer and use it in GitHub Desktop.
Save pzelasko/c5c84a27a9107c27c40ff3d43a28526b to your computer and use it in GitHub Desktop.
Steps needed to install K2 from scratch
#!/usr/bin/env bash
# Common steps
conda create -n k2 python=3.8
conda activate k2
conda install -c nvidia cudnn=7.6.5 cudatoolkit=10.2
conda install -c pytorch pytorch torchaudio
pip install cmake
mkdir build
pushd build
CONDA_ROOT="$(conda config --show root_prefix | cut -f2 -d' ')"
CONDA_ENV_DIR="$CONDA_ROOT/envs/k2"
# Note: somebody reported that they needed to pass an extra argument here:
# -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT (where CUDA_ROOT points to the CUDA
# installation used by PyTorch)
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_COMPILER=$(which nvcc) \
-DPYTHON_EXECUTABLE=$(which python) \
-DCUDNN_LIBRARY_PATH=$CONDA_ENV_DIR/lib/libcudnn.so \
-DCUDNN_INCLUDE_PATH=$CONDA_ENV_DIR/include/ \
..
make -j24 _k2
popd
# When updating and rebuilding K2, before executing these steps, run:
# rm -rf dist/
scripts/build_pip.sh
pip install dist/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment