32
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu 16.04.3にCUDA 8.0とcuDNN 6.0をインストールして、TensorFlow GPUの環境を作成する

Last updated at Posted at 2017-10-17

TensorFlow GPUの環境を作成する

  • 計算機環境
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

1. NVIDIAドライバーを入れる

  • 古いドライバの削除
$ dpkg -l | grep nvidia
$ dpkg -l | grep cuda
$ sudo apt-get --purge remove nvidia-*
$ sudo apt-get --purge remove cuda-*
  • NVIDIAドライバーをインストール
$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt-get update
$ apt-cache search 'nvidia-[0-9]+$'
$ sudo apt install nvidia-384
$ reboot

2. CUDA 8.0を入れる

$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda-8-0

3. cuDNN v6.0を入れる

  • cuDNN Download から Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0 をダウンロードする
$ tar xfvz cudnn-8.0-linux-x64-v6.0.tgz
$ sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include/
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64/
$ sudo chmod a+r /usr/local/cuda-8.0/lib64/libcudnn*
  • .bashrc などでパスの設定を行う
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

4. TensorFlow GPUを入れる

  • インストール
$ sudo apt-get install libcupti-dev
$ sudo pip install tensorflow-gpu
  • 確認
$ python -c "import tensorflow"

###(2018/01/25 追記)

最新の TensorFlow 1.4.1 に Python 3.6 向けのパッケージがないらしい

$ python -c "import tensorflow"
/usr/local/pyenv/versions/3.6.4/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 
of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)

対策としては下記の通り(参考

  • 公式対応を待つ
  • 警告を無視して使う
  • 1.3.0 を使う
$ sudo pip install tensorflow-gpu==1.3.0
32
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?