Jetson Nano配置與使用(6)Xshell6下caffe安裝

Jetson Nano配置與使用(6)Xshell6下caffe安裝

安裝caffe前需要做些準備工作,而且整個過程也比較久,中間有可能會出現各種問題,務必要仔細認真一步一步操作。首先參照之前的文章,使用Xshell6連接好Jetson Nano,然後開始以下內容。

1.修改hosts文件

由於是本地編譯安裝,使用到了git clone命令,正常情況下,速度慢的可憐,在沒有梯子的情況下,只能修改下hosts文件來自我安慰了,相比原來,速度也是提升了不少,此處留下了激動的淚水。廢話少說,幹!
(1)找到本地的hosts文件,並打開,

dnano@dnano-desktop:~$ sudo vi /etc/hosts

(2)在文件的末尾添加以下內容,順便將 ports.ubuntu.com也添加了,

 192.30.255.112 https://github.com
 192.30.255.113 https://github.com
 151.101.76.249 github.global.ssl.fastly.net
 91.189.88.151 ports.ubuntu.com
 91.189.88.150 ports.ubuntu.com

(3)重啓網絡,生效修改後的hosts文件,

dnano@dnano-desktop:~$ sudo /etc/init.d/networking restart

2.安裝依賴

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
 
sudo apt-get install --no-install-recommends libboost-all-dev
 
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
 
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
 
sudo apt-get install git cmake build-essential

3.安裝caffe

(1)使用git將源碼克隆到本地,時間視網速情況,

git clone https://github.com/BVLC/caffe.git

(2)根據caffe提供的示例文件Makefile.config.example生成Makefile.config,

cd caffe
sudo cp Makefile.config.example Makefile.config

(3)修改Makefile.config文件,

【1】將以下內容前的註釋符號去掉,分別位於第5行、23行、92行;
5 USE_CUDNN := 1
23 OPENCV_VERSION := 3
9 WITH_PYTHON_LAYER := 1

【2】將第39行 CUDA_ARCH中的20、21內容去掉;
 39 CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
 40                 -gencode arch=compute_35,code=sm_35 \
 41                 -gencode arch=compute_50,code=sm_50 \
 42                 -gencode arch=compute_52,code=sm_52 \
 43                 -gencode arch=compute_60,code=sm_60 \
 44                 -gencode arch=compute_61,code=sm_61 \
 45                 -gencode arch=compute_61,code=compute_61

【3】將95、96行修改爲以下內容;
95 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
96 LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu/hdf5/serial

(4)修改Makefile文件,

【1】修改第181行爲以下內容;
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

【2】修改第425行爲以下內容;
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

(5)編譯,時間比較久,看集美劇,靜候美好結局,哈哈哈...

dnano@dnano-desktop:~/caffe$ sudo make

4.測試

終於編譯完了, ==從caffe文件夾返回到上一層,再打開python3==,輸入import caffe,不發生錯誤,說明安裝成功。

dnano@dnano-desktop:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> caffe.__
caffe.__class__(          caffe.__lt__(
caffe.__delattr__(        caffe.__name__
caffe.__dict__            caffe.__ne__(
caffe.__dir__(            caffe.__new__(
caffe.__doc__             caffe.__package__
caffe.__eq__(             caffe.__path__
caffe.__format__(         caffe.__reduce__(
caffe.__ge__(             caffe.__reduce_ex__(
caffe.__getattribute__(   caffe.__repr__(
caffe.__gt__(             caffe.__setattr__(
caffe.__hash__(           caffe.__sizeof__(
caffe.__init__(           caffe.__spec__
caffe.__init_subclass__(  caffe.__str__(
caffe.__le__(             caffe.__subclasshook__(
caffe.__loader__
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章