Installation procedure of Chainer 1.6 on Ubuntu 14.04

It is sometimes time consuming task to install Chainer, because installing Cuda has some caveats. Therefore I write my own install log of Chainer with Cuda.

I’ve installed Chainer on AWS. Os is Ubuntu Linux, the version is 14.04. Chainer works on both of Python 2 and Python 3. I choosed python 3. (Note, if you want to import models from Caffe’s modelzoo, you have to choose Python 2.)

sudo apt-get update
sudo apt-get install gcc g++ python3-pip python-dev libhdf5-dev
sudo apt-get install linux-image-extra-`uname -r`

wget http://us.download.nvidia.com/XFree86/Linux-x86_64/346.96/NVIDIA-Linux-x86_64-346.96.run
wget http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x *.run

./NVIDIA-Linux-x86_64-346.96.run
# (install NVidia driver here)

wget -q http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run
chmod +x cuda_7.0.28_linux.run
./cuda_7.0.28_linux.run
# (install Cuda. I don't install NVidia driver here. It may work, but I don't believe the bundled driver. )

echo "export PATH=~/.local/bin:$PATH:/usr/local/cuda-7.0/bin" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64" >> ~/.bashrc
source ~/.bashrc

pip3 install cython --user # may not be needed Chainer 1.6.0 or later.
pip3 install numpy --user
pip3 install h5py --user
CUDA_PATH=/usr/local/cuda-7.0 pip3 install chainer --user -vvvv

Basically, copy and paste will work. Though you have to choose some options while installation of NVIDIA Linux driver and Cuda.

Installing NVIDIA driver is necessary?

If you have enough money, you can use the AMI which NVidia driver is already installed. Unfortunately, the AMI is not avairable for EC2 spot instances. I don’t have enough money, that’s why I’m installing NVidia driver manually.

Another problems around NVIDIA driver is that Cuda bundled driver is a bit old. Maybe it’s OK, but I encountered an awful problem when I installed Cuda for GeForce GTX 970. So I don’t believe bundled drivers.

Some notifications

  • Don’t forget to install linux-image-extra. If you forget, you cannot install the NVidia driver since drm.ko is not found.
  • Don’t forget to install g++. If you forget, you can still install Chainer, but GPU mode won’t work.
  • Note that installing order is important. Cuda must be installed before start of installation of Chainer.
  • -vvvv option for pip is useful when you encountered a trouble.
  • Some pip options are somtimes useful. remember --force-reinstall, --no-cache-dir and --ignore-installed.
このエントリーをはてなブックマークに追加

Latest articles