0、安裝Anaconda3
下載Anaconda3-4.3.1-Linux-x86_64.sh
chmod a+x Anaconda3-4.3.1-Linux-x86_64.sh
./Anaconda3-4.3.1-Linux-x86_64.sh(默認安裝到~目錄,同時會替換原有的python2)
vim ~/.bashrc
export PATH=~/anaconda3/bin/:$PATH
一、下載Nvidia驅(qū)動
去該地址下載驅(qū)動:www.nvidia.com/Download/index.aspx
使用lspci確認顯卡型號:lspci? | grep NVIDIA
01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 745] (rev a2)
下載即可,在~/Downloads/NVIDIA-Linux-x86_64-384.59.run可以找到下載的文件。
1、關閉x-server, sudo service lightdm stop
(提示:會關閉圖形界面,請使用ssh或者ctrl+alt+F1,我使用SSH)
2、cd ~/Downloads/ && sudo ./NVIDIA-Linux-x86_64-384.59.run
3、各種yes,然后安裝成功。
4、sudo service lightdm start 打開圖形界面。
5、執(zhí)行nvidia-setting可以查看相關信息。
三、Q&A
1、注意圖形化界面,使用sudo service lightdm stop/start
2、nouveau驅(qū)動問題:有的使用modprobe的blacklist,我試了沒成功,所以直接使用nvidia驅(qū)動替換。即 sudo apt-get install nvidia-current,然后重啟,發(fā)現(xiàn)nouveau驅(qū)動不再加載。
四、下載CUDA
去該地址https://developer.nvidia.com/cuda-downloads下載安裝即可。
我選deb(network)因為linux下載使用瀏覽器比較慢(我ssh的機器系統(tǒng)是Kali)。
在~/Downloads/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb,執(zhí)行上圖中的1,2,3即可安裝。
下面就是等待出錯了。。。(很不幸沒有出錯,但是調(diào)用deviceQuery出錯了。。。。)
安裝的目錄一般是/usr/local/cuda,在cuda/extras/demo_suite/下sudo? ./deviceQuery 提示如下:
./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 745"
CUDA Driver Version / Runtime Version? ? ? ? ? 8.0 / 8.0
CUDA Capability Major/Minor version number:? ? 5.0
Total amount of global memory:? ? ? ? ? ? ? ? 4041 MBytes (4237164544 bytes)
( 3) Multiprocessors, (128) CUDA Cores/MP:? ? 384 CUDA Cores
GPU Max Clock rate:? ? ? ? ? ? ? ? ? ? ? ? ? ? 1032 MHz (1.03 GHz)
Memory Clock rate:? ? ? ? ? ? ? ? ? ? ? ? ? ? 900 Mhz
Memory Bus Width:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 128-bit
L2 Cache Size:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2097152 bytes
Maximum Texture Dimension Size (x,y,z)? ? ? ? 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers? 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers? 2D=(16384, 16384), 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 1 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 745
Result = PASS
五、Q&A
執(zhí)行deviceQuery出現(xiàn)(心都碎了,這是第二次裝一堆問題,第一次的時候6的不行):
./deviceQueryStarting...
CUDADeviceQuery(RuntimeAPI)version(CUDARTstaticlinking)
FATAL:Modulenvidia_uvmnotfound.
cudaGetDeviceCount returned30
->unknown error
Result=FAIL
果斷谷歌:發(fā)現(xiàn)應該是nvidia-uvm.ko的問題,dmesg提示的問題如下。
nvidia_uvm: Unknown symbol nvUvmInterfaceGetBigPageSize (err 0)
解決方法:sudo update-alternatives--config x86_64-linux-gnu_gl_conf
執(zhí)行上面的命令,選在一個。我的如圖:(估計是install nvidia-current引入的)
然后sudo modprobe nivdia-uvm提示ok,在執(zhí)行deviceQuery就OK了。
六 、CUDA編程
以下鏈接是共享的百度網(wǎng)盤,隨便網(wǎng)上找的CUDA編程的一點資料。
鏈接: http://pan.baidu.com/s/1slBazlN 密碼: rsmm
七、安裝cudnn??? (裝了6.0不好用。。。。。)
下載:cudnn-8.0-linux-x64-v5.1.tgz
cd /usr/local
sudo tar -zxvf /tmp/cudnn-8.0-linux-x64-v5.1.tgz?
八、環(huán)境變量設置
vim ~/.bashrc,添加如下
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
九安裝Tensorflow(在線安裝)
sudo apt-get install libcupti-dev
Installing with Anaconda
Take the following steps to install TensorFlow in an Anaconda environment:
Follow the instructions on theAnaconda download siteto download and install Anaconda.
Create a conda environment namedtensorflowto run a version? ? of Python by invoking the following command:
$conda create -n tensorflow
Activate the conda environment by issuing the following command:
$source activate tensorflow(tensorflow)$? # Your prompt should change
Issue a command of the following format to install
TensorFlow inside your conda environment:
(tensorflow)$pip install --ignore-installed --upgradetfBinaryURL
wheretfBinaryURLis theURL of the TensorFlow Python package. For example, the following command installs the CPU-only version of TensorFlow for Python 2.7:
(tensorflow)$pip install --ignore-installed --upgrade \
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.w
我的是python3.6所以tfBinaryURL:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp36-cp36m-linux_x86_64.whl
所以執(zhí)行pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp36-cp36m-linux_x86_64.whl
等到執(zhí)行結束即可。
十、測試
執(zhí)行ipython,輸入以下:
import? tensorflow as tf
hello=tf.constant('Hello, TensorFlow!')
sess=tf.Session()
print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:
Hello, TensorFlow!
十一、安裝成功。
第一次寫東西,文筆low了點。。。。。。