linux用戶能夠經過官方ppa解決安裝GPU驅動的問題。使用以下命令添加Graphic Drivers PPA:html
sudo add-apt-repository ppa:graphics-drivers/ppa
而後更新源:python
sudo apt-get update
而後去navidia官網查看最新的驅動版本號:navidia官網:http://www.geforce.cn/drivers
好比說驅動的最新版本號爲396,則執行以下指令:linux
sudo apt-get install nvidia-396
最後安裝openGL支持:c++
sudo apt-get install mesa-common-dev
$ sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb $ sudo apt-get update $ sudo apt-get install cuda
sudo vim /etc/profile
export CUDA_HOME=/usr/local/cuda-8.0 export PATH=$CUDA_HOME/bin:$PATH export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
source /etc/profile
$ gcc --help
$ gcc --version #查看gcc版本號
解壓並將內容copy到/usr/local/cuda-8.0/include和lib64目錄中:ubuntu
cudann-8.0是目前爲止比較穩定的版本在更新tensorflow後(1.4.1- 指令: pip install --upgrade tensorflow-gpu 便可更新tensorflow)vim
在官網下載對應版本的*.tgz文件。windows
指令以下:api
下載:Anaconda2-4.3.1-Linux-x86_64.sh(https://repo.continuum.io/archive/)參考網址:https://www.cnblogs.com/willnote/p/6746499.htmlbash
bash Anaconda2-4.3.1-Linux-x86_64.sh
官方下載更新工具包的速度很慢,因此繼續添加清華大學 TUNA提供的Anaconda倉庫鏡像,在終端或cmd中輸入以下命令進行添加工具
$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ $ conda config --set show_channel_urls yes
備註:若是出現conda命令未找到,查看:https://www.cnblogs.com/chamie/p/10009193.html
在終端或cmd中輸入如下命令搜索當前可用的tensorflow版本
(能夠略掉)$ anaconda search -t conda tensorflow Using Anaconda API: https://api.anaconda.org Run 'anaconda show <USER/PACKAGE>' to get more details: Packages: Name | Version | Package Types | Platforms ------------------------- | ------ | --------------- | --------------- HCC/tensorflow | 1.0.0 | conda | linux-64 HCC/tensorflow-cpucompat | 1.0.0 | conda | linux-64 HCC/tensorflow-fma | 1.0.0 | conda | linux-64 SentientPrime/tensorflow | 0.6.0 | conda | osx-64 : TensorFlow helps the tensors flow acellera/tensorflow-cuda | 0.12.1 | conda | linux-64 anaconda/tensorflow | 1.0.1 | conda | linux-64 anaconda/tensorflow-gpu | 1.0.1 | conda | linux-64 conda-forge/tensorflow | 1.0.0 | conda | linux-64, win-64, osx-64 : TensorFlow helps the tensors flow creditx/tensorflow | 0.9.0 | conda | linux-64 : TensorFlow helps the tensors flow derickl/tensorflow | 0.12.1 | conda | osx-64 dhirschfeld/tensorflow | 0.12.0rc0 | conda | win-64 dseuss/tensorflow | | conda | osx-64 guyanhua/tensorflow | 1.0.0 | conda | linux-64 ijstokes/tensorflow | 2017.03.03.1349 | conda, ipynb | linux-64 jjh_cio_testing/tensorflow | 1.0.1 | conda | linux-64 jjh_cio_testing/tensorflow-gpu | 1.0.1 | conda | linux-64 jjh_ppc64le/tensorflow | 1.0.1 | conda | linux-ppc64le jjh_ppc64le/tensorflow-gpu | 1.0.1 | conda | linux-ppc64le jjhelmus/tensorflow | 0.12.0rc0 | conda, pypi | linux-64, osx-64 : TensorFlow helps the tensors flow jjhelmus/tensorflow-gpu | 1.0.1 | conda | linux-64 kevin-keraudren/tensorflow | 0.9.0 | conda | linux-64 lcls-rhel7/tensorflow | 0.12.1 | conda | linux-64 marta-sd/tensorflow | 1.0.1 | conda | linux-64 : TensorFlow helps the tensors flow memex/tensorflow | 0.5.0 | conda | linux-64, osx-64 : TensorFlow helps the tensors flow mhworth/tensorflow | 0.7.1 | conda | osx-64 : TensorFlow helps the tensors flow miovision/tensorflow | 0.10.0.gpu | conda | linux-64, osx-64 msarahan/tensorflow | 1.0.0rc2 | conda | linux-64 mutirri/tensorflow | 0.10.0rc0 | conda | linux-64 mwojcikowski/tensorflow | 1.0.1 | conda | linux-64 rdonnelly/tensorflow | 0.9.0 | conda | linux-64 rdonnellyr/r-tensorflow | 0.4.0 | conda | osx-64 test_org_002/tensorflow | 0.10.0rc0 | conda | Found 32 packages
選擇一個較新的CPU或GPU版本,如jjh_cio_testing/tensorflow-gpu的1.0.1版本,輸入以下命令查詢安裝命令
(能夠略掉)$ anaconda show jjh_cio_testing/tensorflow-gpu Using Anaconda API: https://api.anaconda.org Name: tensorflow-gpu Summary: Access: public Package Types: conda Versions: + 1.0.1 To install this package with conda run: conda install --channel https://conda.anaconda.org/jjh_cio_testing tensorflow-gpu
使用最後一行的提示命令進行安裝
$ conda install --channel https://conda.anaconda.org/jjh_cio_testing tensorflow-gpu==1.3.0
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /home/will/anaconda2:
The following packages will be SUPERSEDED by a higher-priority channel:
tensorflow-gpu: 1.0.1-py27_4 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free --> 1.0.1-py27_4 jjh_cio_testing
Proceed ([y]/n)?
conda會自動檢測安裝此版本的Tensorflow所依賴的庫,若是你的Anaconda缺乏這些依賴庫,會提示你安裝。由於我以前已經安裝過了,因此這裏只提示我安裝Tensorflow。輸入y並回車以後等待安裝結束便可
進入python,輸入
import tensorflow as tf
若是沒有報錯說明安裝成功。
安裝完CUDA 8 和 cuDNN 5後, 在終端輸入 sudo apt-get install libcupti-dev(參考:https://www.cnblogs.com/zengcv/p/6564517.html)
Ubuntu14.04默認安裝的Python2.7.6
先安裝Python庫
sudo apt-get install python-pip python-dev
安裝tensorflow:
(1)在線安裝
sudo pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
(2)下載安裝(因爲Ubuntu系統下,網上比較慢,能夠在windows下載。推薦這種安裝方法)
sudo pip install tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
(下載地址:https://pypi.org/project/tensorflow-gpu/1.0.1/#files)