Install TensorFlow in Ubuntu 16.04.1 LTS

Ubuntu 16.04.1 LTS:

Python 2.7

CUDA 8 + cuDNN 5.1.5

TensorFlow

Ubuntu System

lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 16.04.1 LTS

Release: 16.04

Codename: xenial

Graphics Card (GTX 1080)

lspci -nn |egrep "VGA|Display"

lshw -c display

CPU

cat /proc/cpuinfo

Ubuntu Software

Chrome

Firefox: set proxy -> download chrome

Gdebi

sudo apt-get update

sudo apt-get install gdebi

rightclick --> install chrome.deb through gdebi

Proxy

system-wide proxy: System > Preferences > Network Proxy

Apt-get

apt-get install software-properties-common

Apt-add-repository + Proxy : Bug

add-apt-repository behind proxy

sudo visudo

then add the following lines:

Defaults env_keep="http_proxy"

Defaults env_keep="https_proxy"

Apt-get proxy

ubuntu@ubuntu:~$ sudo vi /etc/apt/apt.conf

Acquire::http::Proxy "http://Username:Password@proxy.foo.bar.edu.au:8080";

sudo vi /etc/profile.d/http_proxy.sh

export http_proxy=http://proxyusername:proxypassword@proxyaddress:proxyport

export https_proxy=http://proxyusername:proxypassword@proxyaddress:proxyport

sudo apt-get update

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]

Hit:2 http://cn.archive.ubuntu.com/ubuntu xenial InRelease

Get:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]

Notice: "http://" must be there

Shutter [sniping / screen print tool]

sudo add-apt-repository -y ppa:shutter/ppa

sudo apt-get update

sudo apt-get install shutter

Sublime3

sudo add-apt-repository ppa:webupd8team/sublime-text-3

sudo apt-get update

sudo apt-get install sublime-text-installer

Vim, Terminator

sudo apt-get install vim

sudo apt-get install terminator

Sogou Pinyin

sudo add-apt-repository ppa:fcitx-team/nightly

sudo apt-get install libopencc1

sudo apt-get install fcitx

sudo apt-get install fcitx-libs

sudo apt-get -f install fcitx-libs-qt

sudo dpkg -i sogoupinyin_2.1.0.0082_amd64.deb

( http://pinyin.sogou.com/linux/?r=pinyin )

Update Software

sudo apt-get update

sudo apt-get dist-upgrade

sudo apt-get install --assume-yes libopencv-dev build-essential axel aria2 cmake git emacs dkms synaptic ssh libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils zip g++ zlib1g-dev unzip

Nvidia GeForce GTX 1080 Driver

Download Driver

Driver 367.57 used according to NVidia.

( http://www.nvidia.com/Download/index.aspx?lang=en-us )

sudo apt-get purge nvidia*

CTR + ALT+ F1

sudo service lightdm stop

# sudo service gdm stop

# sudo service kdm stop

sudo init 3

Install 367 NVidia Driver manually or by Apt-get

sudo service lightdm start

Install "NVIDIA-Linux-x86_64-367.57.run" manually sudo sh NVIDIA-Linux-x86_64-367.57.run

Install "nvidia-367" from apt-get

sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt-get update

sudo apt-get install nvidia-367

Check NVidia Driver

nvidia-smi

nvidia-settings -q NvidiaDriverVersion

"Software & Updates" > "Additional Drivers"

Pop-out TIPS: During this process, maybe warnings are keeping popping out.

You can fix it or turn the warning off ( https://chrisjean.com/fix-system-program-problem-detected-messages-from-ubuntu/ )

crash report related

sudo rm /var/crash/*

sudo mv ~/.config/dconf/user ~/.config/dconf/user.old.2016.11.04

nouveau related:

# black open source graphics driver nouveau

sudo vim /etc/modprobe.d/blacklist-nouveau.conf

blacklist nouveau

blacklist lbm-nouveau

options nouveau modeset=0

alias nourveau off

alias lbm-nouveau off

Reboot

sudo reboot

CUDA 8

Download CUDA 8

( https://developer.nvidia.com/cuda-downloads )

axel -n 30 http://developer.download.nvidia.com/compute/cuda/8.0/secure/prod/local_installers/cuda_8.0.44_linux.run?autho=1478230625_7478c4ccb0e76373bf3f2e94236f74b7&file=cuda_8.0.44_linux.run

Install Cuda Dependents

sudo apt-get -y install ca-certificates-java default-jre default-jre-headless fonts-dejavu-extra freeglut3 freeglut3-dev java-common libatk-wrapper-java libatk-wrapper-java-jni libdrm-dev libgl1-mesa-dev libglu1-mesa-dev libgnomevfs2-0 libgnomevfs2-common libice-dev libpthread-stubs0-dev libsctp1 libsm-dev libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxi-dev libxmu-dev libxmu-headers libxshmfence-dev libxt-dev libxxf86vm-dev lksctp-tools mesa-common-dev x11proto-core-dev x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev x11proto-xf86vidmode-dev xorg-sgml-doctools xtrans-dev libgles2-mesa-dev linux-source linux-headers-$(uname -r)

Run CUDA Installation Shell

chmod 755 cuda_*

With Interaction

sudo sh ./cuda_8.0.44_linux.run

Without Interaction

sudo sh ./cuda_8.0.44_linux.run --silent --toolkit --samples --samplespath=/usr/local/cuda-8.0/samples --override

Installation Log

cat /tmp/cuda_install_*.log

Please make sure that

- PATH includes /usr/local/cuda-8.0/bin

- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

cuDNN 5.1

( https://developer.nvidia.com/cudnn )

Register and Download "cuDNN v5.1 Library for Linux"

axel -n 30 http://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod/8.0/cudnn-8.0-linux-x64-v5.1.tgz?autho=1478240145_c01019acc6ec842f90a42bf6bcfeaae1

sudo tar -xzvf cudnn-8.0-linux-x64-v5.1.tgz

sudo cp cuda/include/cudnn.h /usr/local/cuda/include

sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64

sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Environment CUDA 8 + cuDNN 5.1

sudo vim /etc/profile.d/cuda-8.0.sh

export CUDA_HOME=/usr/local/cuda

export PATH="/usr/local/cuda/bin:$PATH"

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"

source /etc/profile.d/cuda-8.0.sh

CUDA Testing

nvcc --version

cd /usr/local/cuda-8.0/samples/1_Utilities/bandwidthTest

sudo make

./bandwidthTest

TensorFlow

Install Bazel

https://github.com/bazelbuild/bazel/releases

Download "bazel_0.3.2-linux-x86_64.deb"

https://github.com/bazelbuild/bazel/releases/download/0.3.2/bazel_0.3.2-linux-x86_64.deb

sudo dpkg -i bazel_0.3.2-linux-x86_64.deb

NOTE: Bazel 0.4 brings BUG

echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -

sudo apt-get update

sudo apt-get -y install bazel

sudo apt-get upgrade bazel

BUG:

https://github.com/tensorflow/tensorflow/issues/5143

Install Python

sudo apt-get -y install openjdk-8-jdk git python-dev python-numpy build-essential python-pip python-virtualenv swig python-wheel libcurl3-dev

Source

git clone https://github.com/tensorflow/tensorflow

cd tensorflow/

# git branch -r

# git tag

# git checkout tags/v0.11.0rc2

Configure

prcn@prcn-desktop:~/Downloads/tensorflow$ ./configure

~/Downloads/tensorflow ~/Downloads/tensorflow

Please specify the location of python. [Default is /usr/bin/python]:

Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N

No Google Cloud Platform support will be enabled for TensorFlow

Do you wish to build TensorFlow with Hadoop File System support? [y/N] y

Hadoop File System support will be enabled for TensorFlow

Found possible Python library paths:

/usr/local/lib/python2.7/dist-packages

/usr/lib/python2.7/dist-packages

Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]

/usr/local/lib/python2.7/dist-packages

Do you wish to build TensorFlow with GPU support? [y/N] y

GPU support will be enabled for TensorFlow

Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:

Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0

Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:

Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5.1.5

Please specify the location where cuDNN 5.1.5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]:

Please specify a list of comma-separated Cuda compute capabilities you want to build with.

You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.

Please note that each additional compute capability significantly increases your build time and binary size.

[Default is: "3.5,5.2"]:

Extracting Bazel installation...

..............

INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.

Build

sudo bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

sudo pip install --upgrade pip

sudo pip install /tmp/tensorflow_pkg/tensorflow-0.11.0rc2-py2-none-any.whl

Test TensorFlow

cd tensorflow/models/image/mnist

python convolutional.py

TensorFlow Examples

git clone https://github.com/aymericdamien/TensorFlow-Examples.git

cd TensorFlow-Examples

Pycharm

( https://www.jetbrains.com/pycharm/ )

Execution Configuration Environment

LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"

TensorFlow helloworld

That's ALL.

Happy with GPU supported TensorFlow ~~~

Reference:

https://www.pugetsystems.com/labs/hpc/Install-Ubuntu-16-04-or-14-04-and-CUDA-8-and-7-5-for-NVIDIA-Pascal-GPU-825/

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md

https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/

https://marcnu.github.io/2016-08-17/Tensorflow-v0.10-installed-from-scratch-Ubuntu-16.04-CUDA8.0RC-cuDNN5.1-1080GTX/

原文发布于微信公众号 - AI2ML人工智能to机器学习(mloptimization)

原文发表时间:2016-11-14

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏后台开发+音视频+ffmpeg

dpvs源码分析

dpvs是爱奇艺开源的,它是一款基于dpdk的高性能4层负载均衡器。源自于LVS和改版后的alibaba/LVS. dpvs即dpdk-lvs. 等多关于dpv...

1.4K20
来自专栏ml

caffe源码学习之Proto数据格式【1】

前言:   由于业务需要,接触caffe已经有接近半年,一直忙着阅读各种论文,重现大大小小的模型. 期间也总结过一些caffe源码学习笔记,断断续续,这次打算系...

66380
来自专栏小灰灰

RabbitMQ基础教程之Spring&JavaConfig使用篇

25670
来自专栏后端云

resize失败原因调查

对一个vm做resize,即从一个小的flavor换一个大的flavor,没有成功

17530
来自专栏aCloudDeveloper

python网络编程初级

网络编程的专利权应该属于Unix,各个平台(如windows、Linux等)、各门语言(C、C++、Python、Java等)所实现的符合自身特性的语法都大同小...

25350
来自专栏wym

Educational Codeforces Round 44 (Rated for Div. 2) B. Switches and Lamps

You are given n switches and m lamps. The i-th switch turns on some subset of th...

12020
来自专栏CreateAMind

carla 代码运行逻辑混乱的笔记1

carla 模仿学习代码 https://github.com/carla-simulator/imitation-learning,代码跳转自己查源代码即可...

18030
来自专栏coding...

Flutter 简易新闻项目目标效果对比简介代码代码地址

使用flutter快速开发 Android 和 iOS 的简易的新闻客户端 API使用的是 showapi(易源数据) 加载热门微信文章

20620
来自专栏用户2442861的专栏

cmake教程5-macro宏定义以及传递参数给源文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/haluoluo211/article/d...

55730
来自专栏蘑菇先生的技术笔记

多线程中的锁系统(四)-谈谈自旋锁

30770

扫码关注云+社区

领取腾讯云代金券