Ubuntu18.04にViZDoom+RTX2080対応Chainerの構築

強化学習でしばしば用いられるViZDoomというゲーム環境のセットアップと,これを深層学習で捌くためのGPU-Chainer環境の構築メモ.
GPUnvidiaのRTX2080を使っており,CUDA10.1/cuDNN7.6.4を対象.


# for ViZDoom

sudo apt update
sudo apt install build-essential
sudo apt install zlib1g-dev libsdl2-dev libjpeg-dev
sudo apt install nasm tar libbz2-dev libgtk2.0-dev cmake git
sudo apt install libfluidsynth-dev libgme-dev
sudo apt install libopenal-dev timidity libwildmidi-dev unzip
sudo apt install libmpg123-dev libsndfile1-dev libgtk-3-dev chrpath
sudo apt install libboost-all-dev

# for Python
sudo apt install libssl-dev
sudo apt install libreadline-dev libsqlite3-dev wget curl llvm
sudo apt install libncurses5-dev xz-utils tk-dev libxml2-dev
sudo apt install libxmlsec1-dev libffi-dev liblzma-dev

# for pyenv
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
echo export PYENV_ROOT=$HOME/.pyenv >> ~/.profile

[ここで一回リロード]
echo export PATH=$PYENV_ROOT/bin:$PATH >> ~/.profile

[ここで一回リロード]
echo eval "$(pyenv init -)" >> ~/.profile

# setup user python
pyenv install 3.7.4
pyenv global 3.7.4

[ここで一回リロード]
pip install --upgrade pip
pip install numpy
pip install vizdoom


ここまででViZDoomのセットアップ完了
続いてGPU使用可能なChainerのセットアップ


# for cuda

cd ~/
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub

sudo apt update
sudo apt install cuda

echo export PATH=/usr/local/cuda-10.1/bin:$PATH >> ~/.profile
echo export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64:$LD_LIBRARY_PATH >> ~/.profile

 

# for cuDNN

# 一旦exitして,gui環境から https://developer.nvidia.com/rdp/cudnn-download にアクセス
# 対象のruntime/dev/docをダウンロード
# scpでリモートに送信

scp ./libcudnn7_7.6.4.38-1+cuda10.1_amd64.deb user@host:~/
scp ./libcudnn7-dev_7.6.4.38-1+cuda10.1_amd64.deb user@host:~/
scp ./libcudnn7-doc_7.6.4.38-1+cuda10.1_amd64.deb user@host:~/

# ふたたびリモートで作業
sudo dpkg -i libcudnn7_7.6.4.38-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.4.38-1+cuda10.1_amd64.deb
sudo dpkg -i libcudnn7-doc_7.6.4.38-1+cuda10.1_amd64.deb

pip install cupy
pip install chainer

 

# 他のライブラリ(自分用)

pip install matplotlib

pip install pillow

pip install cma

 

sudo reboot