2017年1月5日 星期四

[Tensorflow] 安裝 Tensorflow r 0.12 + CUDA 8.0 + cudnn v 5.1

[前情提要]

重新安裝回去 Tensorflow  r 0.12 + CUDA 8.0 + CuDNN v 5.1 是因為遇到了下面的問題

原本的環境是 Tensorflow r 0.10 + CUDA 7.5(最穩定) + CuDNN v 5.1.3 + Ubuntu 16.04 LTS

執行 NVIDIA 官網上面訓練Google inception v3 的影像分類器之後得到以下的相同問題
NVIDIA- SPEED UP TRAINING WITH GPU-ACCELERATED TENSORFLOW


發現上面遇到的問題必須使用較新的Tensorflow r 0.11 版本

運行之後,發現貌似 r 0.11 只支援 CUDA 8.0
# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7 # Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Install from sources" below. 
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl

---- 官方 r 0.11 的安裝


後來查證了 wiki 上 CUDA 的條目資訊

發現 CUDA 8.0 是能夠支援我現在所使用的GPU ( NVIDIA GeForce GTX 660 )

因此,為了執行後續其他的專案

保險起見,我還是先把 Tensorflow  r 0.12 + CUDA 8.0 + CuDNN v5 安裝起來

[前置作業]
解除安裝

解除安裝舊的 Tensorflow、CUDA toolkit、CuDNN

可以參考這篇 Removing nvidia cuda toolkit and installing new one

移除資料夾的方法可以參考這篇 rm – 刪除檔案及目錄指令
(特別注意:使用 rm 的時候請注意刪除的是什麼)

安裝

CUDA toolkit 8.0

先下載下來 CUDA toolkit 8.0

載完之後會有教使用者如何安裝的指令

Installation Instructions:
Run `sudo sh cuda_8.0.44_linux.run`
Follow the command-line prompts

CuDNN v5

一樣也是下載下來,再將 CuDNN 中的資料拷貝到 CUDA 的路徑中

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*

環境變數設定
按照以下的文字輸入進 .bashrc 檔(依據自己安裝的路徑進行調整)

export CUDA_HOME=/usr/local/cuda-8.0

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

PATH="/usr/local/cuda-8.0/bin:$PATH";export PATH

設定完之後,請在 bash shell 中鍵入

source .bashrc

讓bashrc中的路徑設定進行更新

[配置]
進入tensorflow所在的資料夾,執行configure檔,例如以下的範例

$ ./configurePlease 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 GPU support? [y/N] y GPU support will be enabled for TensorFlow Please specify which gcc nvcc should use 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"]: 3.0

Setting up Cuda includeSetting up Cuda libSetting up Cuda binSetting up Cuda nvvmSetting up CUPTI includeSetting up CUPTI lib64Configuration finished

[常見錯誤]

心理準備

基本上安裝的時候會出現很多問題,Google 是你/妳最忠實的朋友,有問題就問它!


路徑位置

圖片檔經過轉換之後的TFRecord file 還有 訓練模型的 路徑位置請務必確認


GPU 記憶體大小

由於 GPU 內部的記憶體大小有限,所以一次處理過多的圖片會有記憶體爆炸的問題

所以可以先從較低的 batch_size 往上調,目前手邊的機器使用的是NVIDIA GTX 660

內部記憶體只有2G,我就遇到 ResourceExhaustError 這個錯誤,後來就從 batch_size  = 1開始往上調



沒有留言:

張貼留言

/* 載入prettify的autoloader */ /* 載入JQuery */