I created a Chainer environment that can use CUDA and cuDNN on p2.xlarge of AWS.
I used the following version. (At the time of implementation)
version | |
---|---|
OS | Ubuntu14.04 |
pyenv | 1.0.8 |
Anaconda | 4.3.0 |
python | 3.6.2 |
CUDA | 8.0 |
cuDNN | v5.1 |
Chainer | 1.2.21 |
sudo apt-get install -y git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev
For the installation of pyenv, refer to the following. http://qiita.com/y__sama/items/5b62d31cb7e6ed50f02c
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
For the installation of Anaconda, refer to the following. http://qiita.com/y__sama/items/5b62d31cb7e6ed50f02c
pyenv install -l | grep anaconda
pyenv install anaconda3-4.3.0
pyenv rehash
pyenv global anaconda3-4.3.0
echo 'export PATH="$PYENV_ROOT/versions/anaconda3-4.3.0/bin/:$PATH"' >> ~/.bashrc
source ~/.bashrc
conda update conda
python --version
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb
sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64-deb
sudo apt-get update
sudo apt-get install cuda -y
echo 'export CUDA_HOME=/usr/local/cuda' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CUDA_HOME}/lib64' >> ~/.bashrc
echo 'export PATH=$PATH:${CUDA_HOME}/bin' >> ~/.bashrc
Obtained separately from the nvidia site.
mkdir .cudnn
tar xvzf ./cudnn-8.0-linux-x64-v5.1.tgz
mv ./cuda ./.cudnn
mv ./.cudnn/cuda ./.cudnn/5.1
sudo ln -s ~/.cudnn/5.1/include/cudnn.h /usr/local/cuda/include/cudnn.h
sudo ln -s ~/.cudnn/5.1/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
pip install chainer
mkdir mnist
wget https://raw.githubusercontent.com/pfnet/chainer/master/examples/mnist/train_mnist.py ./mnist
#GPU usage
time python ./mnist/train_mnist.py -g 0 -e 10
#GPU not used
time python ./mnist/train_mnist.py -g -1 -e 10
If there is a difference in execution time, it is successful.
Recommended Posts