主機(jī)配置:
CPU:E3 1230 V5+
GPU:EVGA GTX1080 8G SC ACX 3.0
內(nèi)存:DDR4 2133 8G 兩根
主板:技嘉X150M-PRO-ECC
選擇Ubuntu 16 LTS茬祷,因?yàn)樗且粋€(gè)長(zhǎng)期支持版本,而且我的硬件比較新,可能驅(qū)動(dòng)方面在支持和兼容性上面可能會(huì)更好
另外選擇這塊主板一個(gè)原因是M.2的SSD接口梯醒,結(jié)果兼容性問(wèn)題很嚴(yán)重葵蒂,網(wǎng)上很多都在吐槽二次啟動(dòng)問(wèn)題触机,沒(méi)想到中標(biāo)了颠猴,最后放棄了M.2洛巢,老老實(shí)實(shí)用SATA3.0瞻惋。
概覽
- 安裝Ubuntu 16.0.4
- 配置系統(tǒng)編譯環(huán)境
- 編譯安裝TensorFlow
安裝Ubuntu 16.0.4
由于本人是兩塊硬盤厦滤,準(zhǔn)備安裝雙系統(tǒng)。先在第一塊硬盤裝好win10歼狼,然后把下載好的Ubuntu ISO 文件燒寫到U盤掏导,修改系統(tǒng)BIOS,把U盤啟動(dòng)順序設(shè)置到第一然后重啟羽峰,重啟完成后根據(jù)安裝提示一步一步往下走就行趟咆,在選擇系統(tǒng)語(yǔ)言的步驟最好選擇英文,少折騰梅屉。
可能會(huì)遇到的問(wèn)題:
- 安裝完成重啟后黑屏
- 安裝完成后登錄無(wú)法進(jìn)入桌面
安裝完成重啟后黑屏
由于我是雙系統(tǒng)值纱,在開(kāi)機(jī)后顯示引導(dǎo)菜單時(shí)候按e按鈕進(jìn)入編輯grub,找到quiet splash履植,修改為 quiet splash nomodeset计雌,就是在末尾添加nomodeset,然后按F10鍵引導(dǎo)玫霎。如果進(jìn)入到登錄界面凿滤,按住ctrl+alt+f1,進(jìn)入命令行登錄庶近,輸入用戶名密碼后翁脆,編輯sudo vi /etc/default/grub 文件,找到如下行:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
修改為:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"
保存后鼻种,重啟
sudo reboot
安裝ubuntu16.0.4后無(wú)法進(jìn)入桌面
不要急反番,按住ctrl+alt+f1,進(jìn)入命令行登錄叉钥,然后第一件事罢缸,更新source,大局域網(wǎng)投队,你懂的:)
sudo vi /etc/apt/sources.list
如果你不習(xí)慣枫疆,或者是linux小白,可以用nano編輯器來(lái)修改:
sudo nano /etc/apt/sources.list
添加mirrors.163.com的源敷鸦,ubuntu 16的代號(hào) xenial
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
我個(gè)人感覺(jué)電信寬帶用163的鏡像源會(huì)更快一點(diǎn)息楔,如果是教育網(wǎng)寝贡,可以用中科大的源。
修改完成后保存值依,apt update圃泡,然后upgrade
sudo apt-get update
sudo apt-get upgrade
然后升級(jí)內(nèi)核(安裝好后是4.4,建議升級(jí)到4.6.7)愿险,此步驟可以跳過(guò)
先看看內(nèi)核版本:
uname -r
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.7/linux-headers-4.6.7-040607_4.6.7-040607.201608160432_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.7/linux-headers-4.6.7-040607-generic_4.6.7-040607.201608160432_amd64.deb
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.6.7/linux-image-4.6.7-040607-generic_4.6.7-040607.201608160432_amd64.deb
sudo dpkg -i linux-*.deb sudo update-grub
sudo reboot now
重啟完成后開(kāi)始安裝顯卡驅(qū)動(dòng)了颇蜡。(我這個(gè)地方是gtx1080的顯卡,選擇nvidia-367驅(qū)動(dòng))
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
sudo reboot
完成后重啟拯啦,應(yīng)該能進(jìn)入桌面了澡匪,電腦分辨率也正常了。(我的帶魚屏2560X1080)
配置系統(tǒng)編譯環(huán)境
下載安裝CUDA 8.0.44(Nvidia下載 或者 百度網(wǎng)盤下載)
sudo sh cuda_8.0.44_linux.run
開(kāi)始安裝后會(huì)不斷詢問(wèn)安裝內(nèi)容褒链,請(qǐng)一定要注意
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.**?
(y)es/(n)o/(q)uit: n
這個(gè)步驟一定要選擇no唁情,否者前面最新的顯卡驅(qū)動(dòng)就白裝了(如果實(shí)在不小心踩了這個(gè)坑,沒(méi)關(guān)系甫匹,把前面步驟的顯卡驅(qū)動(dòng)重新裝一次甸鸟,安裝前先卸載)
完成后注意看提示,如果有問(wèn)題可以參考這篇blog(我沒(méi)遇到)
配置環(huán)境變量:
nano ~/.bashrc
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
如果在桌面的Terminal配置環(huán)境變量兵迅,完成后exit下抢韭,再進(jìn)入讓環(huán)境變量生效,如果在系統(tǒng)命令行模式恍箭,可以手動(dòng)執(zhí)行以下上面的export兩行命令刻恭。
完成后開(kāi)始安裝Cudnn 5.1,官方下載地址 或者 百度網(wǎng)盤地址
下載完成后扯夭,解壓復(fù)制到目錄(如果CUDA8.0是默認(rèn)安裝路徑鳍贾,這個(gè)地方就不用修改路徑了)
tar xvf 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*
好了,現(xiàn)在輸入命令看看是否正常顯示顯卡信息:
nvidia-smi
然后進(jìn)入剛剛CUDA安裝的sample目錄交洗,默認(rèn)是~/下骑科,然后make,編譯完成后輸入
./NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release/deviceQuery
應(yīng)該會(huì)正常顯示詳細(xì)設(shè)備信息:
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 1080"
CUDA Driver Version / Runtime Version 8.0 / 8.0
CUDA Capability Major/Minor version number: 6.1
Total amount of global memory: 8110 MBytes (8504279040 bytes)
(20) Multiprocessors, (128) CUDA Cores/MP: 2560 CUDA Cores
GPU Max Clock rate: 1848 MHz (1.85 GHz)
Memory Clock rate: 5005 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 2097152 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 1080
Result = PASS
編譯安裝TensorFlow
好了构拳,現(xiàn)在開(kāi)始安裝TensorFlow的編譯環(huán)境了咆爽,如果不想自己編譯,這里下載我編譯好的whl
本文篇幅有點(diǎn)長(zhǎng)置森,所以Bazel安裝配置可以看官方手冊(cè)斗埂,點(diǎn)這里傳送
官方下載有點(diǎn)慢,可以到這里下載 bazel 0.3.1版本
繼續(xù)安裝
如果你是python 2.7
sudo apt-get install python-numpy swig python-dev python-wheel python-pip
或者是3.x
sudo apt-get install python3-numpy swig python3-dev python3-wheel python3-pip
拉取TensorFlow代碼:
git clone https://github.com/tensorflow/tensorflow
切到最新的 r0.11分支
git checkout r0.11
開(kāi)始配置:
$./configure
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] N
No 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
Please specify the location where cuDNN 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"]: 6.1
...
...
...
配置完成后凫海,編譯GPU版本whl蜜笤。不想編譯的同學(xué)可以到這里下載我編譯好的whl
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-0.11.0rc0-py2-none-any.whl
到這里就全部完成了,完成后可以跑一下google的測(cè)試集驗(yàn)證下盐碱,點(diǎn)這里傳送
大家安裝如果有任何疑問(wèn)可以給我留言:)