1. 程式人生 > >CUDA8.0 + CUDNN5.1 + Opencv2.4 + png++0.2.9 + torch+LuaJIT 安裝以及配置問題(為MC-CNN鋪墊)

CUDA8.0 + CUDNN5.1 + Opencv2.4 + png++0.2.9 + torch+LuaJIT 安裝以及配置問題(為MC-CNN鋪墊)

前段時間博主為了專案 進行了MC-CNN程式碼的復現。其中走了很多彎路,寫出來防止以後大家踏坑。

以下的安裝配置是完全適用於GitHub的那位博主的程式碼的。

以下就是那位GitHub的網址:

https://github.com/jzbontar/mc-cnn

安裝步驟:

1.安裝CUDA 8.0

2.安裝CUDNN 5.1

3.安裝OpenCV 2.4

4.安裝png++ 0.2.9

5.安裝Torch,LuaJIT

1.安裝CUDA 8.0

CUDA分network版本與local版本,建議下載local版本,因為network版本是在安裝過程中下載的,選擇本地版較好,同時建議下載runfile版本,據說deb版本太多坑,我之前用deb版本安裝的時候也覺得不太方便....

下載完成之後,cd到該檔案所在處,根據官網提示輸入:

sudo sh cuda_8.0.61_375.26_linux.run

 

 

 

然後會讓你選擇安裝內容,個人覺得除了cuda toolkit是必須的外,其他可選可不選。

具體可以參考下圖

 

設定Cuda環境變數

輸入:sudo gedit ~/.bash_profile

然後在文末新增以下兩行:export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64"

export CUDA_HOME=/usr/local/cuda-8.0

 務必記得:

source ~/.bashrc

即儲存後立即生效。

 

2.安裝cudnn

初次下載cudnn需要在網上填寫一堆問卷,耐心填吧。(下載地址:https://developer.nvidia.com/cudnn)

 

下載好後,開啟終端依次輸入以下命令:

cd ‘cudnn檔案所在位置

tar xvzf 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*

3.安裝Opencv2.4.10

下載該指令碼,進入Ubuntu/2.4 目錄, 給所有shell指令碼加上可執行許可權

sudo chmod +x *.sh

然後安裝最新版本 (當前為2.4.910)

sudo sh ./opencv2_4_10.sh

指令碼會自動安裝依賴項,下載安裝包,編譯並安裝OpenCV。整個過程大概半小時左右。

4.PNG++安裝

我們首先安裝libpng和zlib

4.1安裝libpng和zlib

./configure
make check
sudo make install
make check
sudo ldconfig

4.2安裝png++

Issue make to test how it's doing:

$ make 

This will compile examples in the example directory. If everything goes well, try

$ make test 

(or make check which is the same as above) to run the test suite. If tests do not produce error messages then probably all is OK.
Now you can create documentation (optional). Use

$ make docs 

to run doxygen in the sources directory.
Now it is time to become root and install png++ into your system. It's OK to issue make install under ordinary user permissions if you want to install png++ into your home directory. Run the following command:

$ make install PREFIX=$HOME 

to copy png++ header files to ~/include/png++ and documentation files to ~/share/doc/png++-0.2.x. Without a PREFIX png++ installs to /usr/local.

(博主在 make docs 的出現了一個小問題,直接用sudo make install安裝它就好了)

5.Torch安裝

Torch的安裝還是有點麻煩的,如果前面沒裝好的話在後面安裝會出現一系列的bug。

然後torch的安裝主要按照官網上的步驟來就好了。

http://torch.ch/docs/getting-started.html

git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torchbash install-deps

安裝LuaJIT

./install.sh

安裝其他

$ luarocks install image
$ luarocks list

參考於:

https://blog.csdn.net/xiaozhun07/article/details/49865785

https://blog.csdn.net/TongXXhaha/article/details/77605315