Skip to content

Instantly share code, notes, and snippets.

@SrivastavaKshitij
Last active September 18, 2019 02:59
Show Gist options
  • Save SrivastavaKshitij/42694ab23ab5ff4be31a61da8d394ab2 to your computer and use it in GitHub Desktop.
Save SrivastavaKshitij/42694ab23ab5ff4be31a61da8d394ab2 to your computer and use it in GitHub Desktop.
Installing torch tvm inside a container

Steps to install torch tvm inside a container

Pull nvidia cuda ngc container

docker pull nvcr.io/nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04

Start docker container

docker run -e NVIDIA_VISIBLE_DEVICES=0 --gpus 0 -it --shm-size=1g --ulimit memlock=-1  --rm  -v $PWD:/workspace/work $docker_image   
apt-get update    
apt-get install -y vim git wget   
wget https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.sh    
bash cmake-3.15.3-Linux-x86_64.sh   

Install anaconda environment (recommended method to install pytorch)

wget https://repo.anaconda.com/archive/Anaconda3-2019.07-Linux-x86_64.sh
./Anaconda3-2019.07-Linux-x86_64.sh  
eval "$(/root/anaconda3/bin/conda shell.bash hook)"   
conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing   
conda install -c pytorch magma-cuda100   

Clone and Install Pytorch

git clone --recursive https://github.com/pytorch/pytorch   
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}   
cd pytorch  
python setup.py install  

Install torch tvm and dependencies

cd /
wget http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar -xf clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
export PATH=$PATH:/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/
ln -s /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/llvm-config /usr/bin/llvm-config
git clone --recursive https://github.com/pytorch/tvm.git
cd tvm/
python setup.py install --cmake

Create docker image

docker commit <container_id> <image_name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment