GTX1070+ubuntu1610+tensorflow-gpu安装

#系统启动时提示nouveauerror: unkown chipset

# nouveau无法识别GTX1080

-禁用nouveau

vi /etc/modprobe.d/blacklist.conf

#添加:

blacklist nouveau

sudo update-initramfs -u

sudo reboot

#准备系统环境

sudo apt-get install build-essential wget

#安装gcc g++ 4.8

sudo apt-get install gcc-4.8gcc-4.8-multilib g++-4.8 g++-4.8-multilib

sudo update-alternatives --install/usr/bin/gcc gcc /usr/bin/gcc-5 60

sudo update-alternatives --install/usr/bin/gcc gcc /usr/bin/gcc-4.8 50

sudo update-alternatives --install/usr/bin/g++ g++ /usr/bin/g++-5 60

sudo update-alternatives --install/usr/bin/g++ g++ /usr/bin/g++-4.8 50

#切换gcc g++版本

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

#移除gcc g++ 4.8

# sudo update-alternatives --remove gcc/usr/bin/gcc-4.8

# sudo update-alternatives --remove g++/usr/bin/g++-4.8

# CUDA 8.0RC

#https://developer.nvidia.com/cuda-release-candidate-download

#安装cuda toolkit

#切换到gcc-4.8

sudo dpkg -icuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64.deb

sudo apt-get update

sudo apt-get install cuda

#配置环境变量

echo "exportCUDA_HOME=/usr/local/cuda" >> ~/.bashrc

echo "exportPATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc

echo "exportLD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> ~/.bashrc

#安装cuDNN

tar -xf cudnn-8.0-linux-x64-v5.0-ga.tgz

sudo cp -f cuda/lib64/*.*/usr/local/cuda/lib64/

sudo cp -f cuda/include/*.*/usr/local/cuda/include/

#注意:GeForce GTX1080 Developers must re-install the latest driver from www.nvidia.com/driversafter installing any of these CUDA Toolkits.

#注意:gcc-4.8无法编译nvidia driver

#注意:安装驱动时需要允许dkms

#切换到gcc-5

sudo sh NVIDIA-Linux-x86_64-*.run

#卸载驱动:sudonvidia-uninstall

#测试

cd/usr/local/cuda/samples/1_Utilities/deviceQuery

sudo make

./deviceQuery

# modprobe: ERROR: could not insert'nvidia_361_uvm': Invalid argument

#这是因为cuda8.0自带了361版本的nvidia driver,需要将其卸载

sudo apt-getremove nvidia-361

The following packages will be REMOVED:

cuda cuda-8-0 cuda-demo-suite-8-0cuda-drivers cuda-runtime-8-0 nvidia-361 nvidia-361-dev

0 upgraded, 0 newly installed, 7 to removeand 76 not upgraded.

After this operation, 312 MB disk spacewill be freed.

Do you want to

continue? [Y/n] y(别怕,没问题)

sudo reboot(重启显示有问题,可能无法进入桌面)

Crtl+Alt+F1

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

sudo apt update

sudo apt install nvidia-367 nvidia-settingsnvidia-prime

sudo reboot

现在能正常进入桌面了

# Tensorflow 0.9.0 build from source

#安装bazel

sudo apt-get install openjdk-8-jdk

echo "debhttp://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee/etc/apt/sources.list.d/bazel.list

curlhttps://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add-

sudo apt-get update

sudo apt-get install bazel

#编译tensorflow

sudo apt-get install python-numpy swigpython-dev

mkdir ~/github && cd ~/github

git clone --recurse-submoduleshttps://github.com/tensorflow/tensorflow

cd ~/github/tensorflow &&./configure

---------------------------------------

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

Do you wish to build TensorFlow with GoogleCloud Platform support? [y/N] n

No Google Cloud Platform support will beenabled for TensorFlow

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

GPU support will be enabled for TensorFlow

Please specify which gcc nvcc should use asthe host compiler. [Default is /usr/bin/gcc]:

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

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

Please specify the Cudnn version you wantto use. [Leave empty to use system default]: 5 (not 5.0)

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

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

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

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

[Default is: "3.5,5.2"]:

Setting up Cuda include

Setting up Cuda lib64

Setting up Cuda bin

Setting up Cuda nvvm

Setting up CUPTI include

Setting up CUPTI lib64

Configuration finished

---------------------------------------

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/tmp/tensorflow_pkg/tensorflow-…

#测试

python -c "import tensorflow"

# ImportError: cannot import name

pywrap_tensorflow:需要重启

sudo reboot

# Theano & keras

sudo apt-get install python-numpypython-scipy python-dev python-pip python-nose libopenblas-dev git

sudo pip install Theano

sudo pip install keras

#配置Theano

echo "[global]" > ~/.theanorc

echo "floatX = float32" >>~/.theanorc

echo "device = gpu0" >>~/.theanorc

echo "[nvcc]" >>~/.theanorc

echo "fastmath = True" >>~/.theanorc

#测试

python -c "import keras"

# matplotlib

sudo apt-get build-dep python-matplotlib

# E: You must put some 'source' URIs inyour sources.list

sudo vi /etc/apt/sources.list

#去掉所有deb-src前面的#号

sudo apt-get update

sudo pip install matplotlib

# h5py

sudo apt-get install libhdf5-dev

sudo apt-get install cython

sudo pip install h5py

# Docker

# Update apt sources

sudo apt-get update

sudo apt-get install apt-transport-httpsca-certificates

sudo apt-key adv --keyserverhkp://p80.pool.sks-keyservers.net:80 --recv-keys58118E89F3A912897C070ADBF76221572C52609D

sudo vi /etc/apt/sources.list.d/docker.list

#添加(14.04):

deb https://apt.dockerproject.org/repoubuntu-trusty main

#添加(16.04):

deb https://apt.dockerproject.org/repoubuntu-xenial main

sudo apt-get update

sudo apt-get install docker-engine

sudo service docker start

# add user group

sudo groupadd docker

sudo usermod -aG docker [your username]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,362评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,330评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,247评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,560评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,580评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,569评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,929评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,587评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,840评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,596评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,678评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,366评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,945评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,929评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,165评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,271评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,403评论 2 342

推荐阅读更多精彩内容