Tensorflow/Tensorflow for Python
Tensorflow-GPU 설치 on Ubuntu16.04
딥스탯
2018. 1. 22. 12:09
Tensorflow-GPU installation on Ubuntu16.04
<출처>
https://www.tensorflow.org/install/install_linux
http://docs.nvidia.com/cuda/cuda-installation-guide-linux/#axzz4VZnqTJ2A
https://developer.nvidia.com/cudnn
<함께보기>
Tensorflow for R GPU버전 설치 on Ubuntu16.04
1 “CUDA® Toolkit 8.0” Installation
http://docs.nvidia.com/cuda/cuda-installation-guide-linux/#axzz4VZnqTJ2A
1.1 Pre-Installation actions.
1.1.1 Verify You Have a CUDA-Capable GPU
$ lspci | grep -i nvidia
22:00.0 VGA compatible controller: NVIDIA Corporation Device 1c82 (rev a1)
22:00.1 Audio device: NVIDIA Corporation Device 0fb9 (rev a1)
If your graphics card is from NVIDIA and it is listed in http://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable.
1.1.2 Verify You Have a Supported Version of Linux
$ uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
1.1.3 Verify the System Has gcc Installed
$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1.1.4 Verify the System has the Correct Kernel Headers and Development Packages Installed
$ sudo apt-get install linux-headers-$(uname -r)
1.1.5 Choose an Installation Method
I do “Package Manager Installation”
1.2 Installation
1.2.1 Disabling Nouveau
- Create a file at “/etcmodprobe.d/blacklist-nouveau.conf” with the following contents:
blacklist nouveau
options nouveau modeset=0
- Regenerate the kernel initramfs:
$ sudo update-initramfs -u
1.2.2 Download File
https://developer.nvidia.com/cuda-80-ga2-download-archive
Download local base installer
1.2.3 Installation Instructions:
$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
$ sudo apt-key add /var/cuda-repo-8.0.61-1/7fa2af80.pub
$ sudo apt-get update
$ sudo apt-get install cuda-8-0
1.3 Post-installation Actions
1.3.1 Environment Setup
$ cd ~
$ gedit .bashrc
Add the followings:
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64
2 “cuDNN v6.0” Installation
https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/Doc/cudnn_install-txt
2.1 Downloads
https://developer.nvidia.com/rdp/cudnn-download
Download followings :
Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0
- cuDNN v6.0 Runtime Library for Ubuntu16.04 (Deb)
- cuDNN v6.0 Developer Library for Ubuntu16.04 (Deb)
- cuDNN v6.0 Code Samples and User Guide for Ubuntu16.04 (Deb)
2.2 Installation
$ sudo dpkg -i libcudnn6_6.0.21-1+cuda8.0_amd64.deb
$ sudo dpkg -i libcudnn6-dev_6.0.21-1+cuda8.0_amd64.deb
$ sudo dpkg -i libcudnn6-doc_6.0.21-1+cuda8.0_amd64.deb
3 “libcupti-dev” Library Installation
$ sudo apt-get install libcupti-dev
4 Installing with native pip (for python3.5)
4.1 Installing pip3 and python3
$ sudo apt-get install python3-pip python3-dev
4.2 Upgrading pip3
$ sudo pip3 install --upgrade pip
4.3 Installing Tensorflow
$ pip3 install tensorflow-gpu
5 Run a short TensorFlow program
$ python3
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello, TensorFlow!'