Linux下深度学习常用工具的安装
.Matlab 2015 64bit 的安裝
? (一)安裝包下載
? ? ? ?百度網(wǎng)盤: [https://pan.baidu.com/s/1gf9IeCN], 密碼:?4gj3
? (二)Vmware 使用Windows共享目錄
? ? ? ? 更改虛擬機(jī)設(shè)置時(shí)需要將系統(tǒng)關(guān)機(jī),掛起狀態(tài)不可以設(shè)置,Linux共享目錄位于/mnt/hgfs
? ? ? ??
? (三) 掛載鏡像文件
? ? ? ? ?在Terminal中輸入如下命令:
cd /mnt/hgfs/sudo mount -o loop 迅雷下載/R2015b_glnxa64.iso /media/matlab/? (四)執(zhí)行安裝
在Terminal中輸入如下命令:
cd /mediamkdir matlabsudo ./install
?? ?
? (五)破解
將crack文件夾下的libmwservices.so copy到 /usr/local/MATLAB/R2014A/bin/glnxa64
在Terminal中輸入如下命令:
cd /usr/local/MATLAB/R2015b/bin/sudo ./matlab
cd /mnt/hgfs/ 迅雷下載/Matlab\ 2015b\ Linux64\ Crack/R2015b/bin/sudo cp -r glnxa64 /usr/local/MATLAB/R2015b/bin/
? (五)運(yùn)行測(cè)試
運(yùn)行測(cè)試是否成功破解
在Terminal中輸入如下命令:
cd /usr/local/MATLAB/R2015b/bin/sudo ./matlab?2.caffe 安裝
? ? (一)配置apt-get源為國(guó)內(nèi)服務(wù)器,備份原配置文件,更新地址為清華鏡像或阿里鏡像
在Terminal中輸入如下命令:
cd /etc/aptsudo cp sources.list sources.list.bakvi sources.list # 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse# 預(yù)發(fā)布軟件源,不建議啟用# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse? ?(二)依賴包安裝
在Terminal中輸入如下命令:
sudo apt-get updatesudo apt-get install git sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compilersudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libatlas-base-devsudo apt-get install python-devsudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev? ?(三)caffe源碼下載
git clone https://github.com/bvlc/caffe.gitcd caffe/mv Makefile.config.example Makefile.config? (四)執(zhí)行編譯
修改Makefile.config,打開CPU_ONLY選項(xiàng),保存;
即第6行修改為
# CPU-only switch (uncomment to build without GPU support).CPU_ONLY := 1? ?第85行修改為
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/? ??修改Makefile文件173行
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial執(zhí)行編譯
make –j4make test -j4make runtest -j4當(dāng)返回PASSED結(jié)果時(shí)即為編譯成功
#GPU編譯錯(cuò)誤: undefined reference to `cv::imread(cv::String const&, int),即找不到OpenCVC動(dòng)態(tài)鏈接庫(kù)sudo gedit Makefile , 修改為L(zhǎng)IBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial opencv_core opencv_highgui opencv_imgproc ??3.TensorFlow安裝
? ? (一)獲取并安裝python-pip,python-dev
sudo apt-get install python-pip python-dev(二)下載TensorFlow
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl(三)安裝TensorFlow
pip install tensorflow-0.8.0-cp27-none-linux_x86_64.whl? 出現(xiàn)Successfully installed numpy-1.14.3 protobuf-3.0.0b2 tensorflow-0.8.0即說明已經(jīng)安裝成功
? 注意:如果同時(shí)安裝了python2和python3,使用pip安裝時(shí)可能會(huì)報(bào)錯(cuò),例如上述安裝包tensorflow-0.8.0-cp27-none-linux_x86_64.whl代表python2.7版本的,因此需要使用pip2 install
? 如何測(cè)試:
? 在Linux Shell中輸入python進(jìn)入交互模式
import tensorflow as tfhello = tf.constant("Hello World, TensorFlow!")sess = tf.Session()print(sess.run(hello))? 根據(jù)運(yùn)行結(jié)果? Hello World,TensorFlow!? 即可判斷成功安裝
?4.Matconvnet的編譯
(一)打開Matlab
cd /usr/local/MATLAB/R2015b/bin/sudo ./matlab(二)定位到Matconvnet目錄,執(zhí)行編譯
cd /usr/local/MATLAB/R2015b/bin/vl_setupnnvl_compilenn('verbose',1)? ?問題1? gcc,g++版本不匹配
#Warning: You are using gcc version '5.4.0-6ubuntu1~16.04.9)'.#The version of gcc is not supported. The version currently#supported with MEX is '4.7.x'. sudo apt-get install gcc-4.7sudo apt-get install g++-4.7cd /usr/bin/sudo rm gccsudo ln -s gcc-4.7 gccgcc -vsudo rm g++sudo ln -s g++-4.7 g++g++ -v5.CUDA和CUDNN的安裝(虛擬機(jī)不能使用CUDA)
CUDA是NVIDIA的編程語言平臺(tái),想使用GPU就必須要使用cuda,CUDNN是GPU加速計(jì)算深層神經(jīng)網(wǎng)絡(luò)的庫(kù)。
以安裝Cuda-9.2為例,具體版本請(qǐng)根據(jù)實(shí)際需求選擇
在NVIDIA官網(wǎng)選擇驅(qū)動(dòng)下載(https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64),如出現(xiàn)網(wǎng)絡(luò)打不開可將鏈接復(fù)制到迅雷下載
執(zhí)行如下操作:
sudo dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.debsudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pubsudo apt-get updatesudo apt-get install cudanvidia-smi問題1? 由于虛擬機(jī)不支持對(duì)主機(jī)顯卡的調(diào)用,安裝cuda后可能會(huì)導(dǎo)致重啟后無法進(jìn)入圖形界面
通過執(zhí)行 sudo apt-get purge nvidia-*??刪除原Nvidia顯卡驅(qū)動(dòng),執(zhí)行reboot即可
問題2 最新版TensorFlow-GPU版本不支持Cuda-9.2(python中執(zhí)行import tensorflow提示Tensorflow:ImportError:libcusolver.so.9.0)請(qǐng)安裝cuda-9.0
CUDN的安裝
①下載 https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.1.4/prod/9.2_20180516/cudnn-9.2-linux-x64-v7.1
②解壓文件,并拷貝到usr/local/cuda/目錄
#使用如下語句在當(dāng)前目錄解壓,解壓后生成include和lib64文件夾tar -zxvf cudnn-9.2-linux-x64-v7.1.tgz
#將lib文件和對(duì)應(yīng)頭文件拷貝到/usr/local目錄cd cuda/lib64/sudo cp lib* /usr/local/cuda/lib64/
cd ../sudo cp include/cudnn.h /usr/local/cuda/include/
③更新軟連接
cd /usr/local/cuda/lib64sudo rm -rf libcudnn.so libcudnn.so.7sudo ln -s libcudnn.so.7.1.4 libcudnn.so.7sudo ln -s libcudnn.so.7 libcudnn.so④添加環(huán)境變量
sudo gedit /etc/profile在打開的文件中加入如下兩句話
export PATH=/usr/local/cuda/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
保存后,使環(huán)境變量立即生效
source /etc/profile ⑤安裝cudnn example
全部編譯完成后,進(jìn)入 samples/bin/x86_64/linux/release, 運(yùn)行deviceQuery
cd bin/x86_64/linux/release./deviceQuery6.OpenCV的安裝和使用
①.依賴庫(kù)安裝
sudo apt-get install cmakesudo apt-get install build-essentialsudo apt-get install libgtk2.0-devsudo apt-get install libavcodec-devsudo apt-get install libavformat-devsudo apt-get install libjpeg.devsudo apt-get install libtiff4.devsudo apt-get install libswscale-devsudo apt-get install libjasper-dev②.從官網(wǎng)(https://github.com/opencv/opencv/tree/3.4.1)下載源碼,編譯安裝
cp -r opencv-2.4.13.6.zip /home/shine/Downloads/cd /home/shine/Downloads/unzip opencv-2.4.13.6.zipcd opencv-2.4.13.6/mkdir buildcd build/③.創(chuàng)建build目錄并在該目錄下生成Makefile文件,指定安裝路徑為/usr/local/(參考 https://stackoverflow.com/questions/45518317/in-source-builds-are-not-allowed-in-cmake)
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/localsudo make -j4sudo make install -j4make clean如需安裝opencv_contribute(擴(kuò)展包中的很多代碼并沒有通過大量的穩(wěn)定性測(cè)試,但是其基本功能還是可以運(yùn)行的),對(duì)命令進(jìn)行修改(需自行下載opencv_contrib),例如本例中保存路徑為~/Downloads
#如下命令指定安裝路徑以及擴(kuò)展包的路徑,請(qǐng)根據(jù)實(shí)際修改cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local? -D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib-master/modules ..
sudo make -j4
sudo make install -j4
make clean
#若出現(xiàn)No package 'gstreamer-video-1.0' found,請(qǐng)參考http://answers.opencv.org/question/95734/cmake-not-picking-gstreamer-on-ubuntu/
#若出現(xiàn)Unknown CMake command "ocv_append_source_files_cxx_compiler_options,請(qǐng)參考https://blog.csdn.net/qq_40155090/article/details/79977423
#配置過程中可能出現(xiàn)face_landmark_model.dat下載過慢導(dǎo)致的失敗,請(qǐng)使用VPN下載https://raw.githubusercontent.com/opencv/opencv_3rdparty/8afa57abc8229d611c4937165d20e2a2d9fc5a12/face_landmark_model.dat后放置于/opencv-3.4.1/.cache/data目錄
#配置成功后的截圖如下所示,May you succeed, congruations and enjoy
#執(zhí)行sudo make -j4進(jìn)行編譯時(shí)可能會(huì)遇到各種奇怪的問題(例如hdf5.cpp編譯失敗),因此需要確保opencv-master與opencv-contribute為一個(gè)版本,建議都使用github上的版本
#編譯時(shí)出現(xiàn)~Download/opencv_contrib-master/modules/xfeatures2d/src/boostdesc.cpp:653:37: fatal error: boostdesc_bgm.i: No such file or directory?compilation terminated.
#參考 https://github.com/opencv/opencv_contrib/issues/1301
http://answers.opencv.org/question/113942/cmake-failing-with-hash-mismatch/
#如果問題仍然沒有解決,嘗試下載上述缺少的文件放在~/Downloads/opencv_contrib-master/modules/xfeatures2d/src目錄下即可
#編譯時(shí)出現(xiàn)opencv2/xfeatures2d/cuda.hpp: No such file or directory
#參考https://github.com/opencv/opencv_contrib/issues/1131,執(zhí)行cmake -DBUILD_opencv_xfeatures2d=OFF ..
#編譯時(shí)出現(xiàn)opencv2/sfm/conditioning.hpp: No such file or directory
#執(zhí)行了sudo make clean;sudo make -j4;后問題解決了(無法解釋)
如何查看OpenCV版本
pkg-config --modversion opencv④.添加庫(kù)路徑?
sudo vi /etc/ld.so.conf.d/opencv.conf , 輸入/usr/local/lib , :wq保存并退出⑤.添加環(huán)境變量
sudo vi /etc/profile #在末尾輸入 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATHexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib#更新環(huán)境變量:source /etc/profilesudo vi /etc/bash.bashrc#在末尾輸入export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfigexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib#更新環(huán)境變量 source /etc/profile⑥.更新系統(tǒng)庫(kù)配置
sudo ldconfig⑦.查看是否安裝成功
pkg-config --cflags opencv pkg-config --libs opencv⑧.執(zhí)行測(cè)試程序,定位到sample目錄,執(zhí)行build_all
cd /home/shine/Downloads/opencv-2.4.13.6/samples/c./build_all.sh./find_obj若執(zhí)行build_all編譯時(shí)出現(xiàn)如下錯(cuò)誤?
compiling contours.c/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o: unrecognized relocation (0x2a) in section `.init'/usr/bin/ld: final link failed: Bad valuecollect2: error: ld returned 1 exit status可能是沒有安裝binutils,執(zhí)行
sudo apt-get install binutils./build_all.sh./find_obj7.Jupyter
①安裝
sudo pip3 install --upgrade pipsudo pip3 install jupytersudo pip install matplotlib以上命令使用python3為基礎(chǔ),因此運(yùn)行jupyter會(huì)調(diào)用python3,若要使用python2請(qǐng)使用
sudo pip install jupyter
②測(cè)試使用
jupyter notebook隨后在瀏覽器界面即可使用 http://localhost:8888/notebooks 進(jìn)行登陸
8.shadowsocks
sudo apt-get updatesudo apt-get install python-pipsudo pip install shadowsockssudo gedit /etc/shadowsocks.json配置shadowsocks,粘貼如下內(nèi)容
{"server":"xx.xx.xx.xx","server_port":xxxx,"local_address": "127.0.0.1","local_port":1080,"password":"xxxxxxxx","timeout":300,"method":"aes-256-cfb","fast_open": true,"workers": 1} sudo sslocal -c /etc/shadowsocks.json -d startsudo gedit /etc/rc.local配置開機(jī)啟動(dòng)
在exit0上一行加上/usr/local/bin/sslocal -c /etc/shadowsocks.json -d start
①火狐瀏覽器使用
打開Add-ons,搜索FoxyProxy Standard,點(diǎn)擊Add To Firefox,添加完成后點(diǎn)擊右上角圖表進(jìn)入Options,即如下圖所示
點(diǎn)擊左上角Add,其中Title可隨便定義,IP以及Port同上shadowsocks配置,默認(rèn)為127.0.0.1,1080
②谷歌瀏覽器使用
從github上下載最新的插件SwitchyOmega-Chromium-2.5.15.crx,將其拖到chrome中即可完成安裝,同理完成上述配置,點(diǎn)擊Apply Changes
可通過右上角選擇Direct或proxy選擇時(shí)候走代理通道
9.Linux下載工具aria2
推薦這個(gè)工具主要在于Linux下沒有比較好的綠色百度網(wǎng)盤下載器,由于百度對(duì)非會(huì)員進(jìn)行速度限制(默認(rèn)50Kb/s),并強(qiáng)制大文件通過百度云管家下載,具體操作如下
# aria2安裝sudo apt-get install aria2
# 安裝瀏覽器插件,推薦chrome,從github下載zip文件,打開chrome://extensions/,將文件夾中的BaiduExporter.crx拖到瀏覽器即可
# https://codeload.github.com/acgotaku/BaiduExporter/zip/master
# 將需要下載的文件保存到個(gè)人網(wǎng)盤,在界面中選擇導(dǎo)出下載,選擇其中的文本導(dǎo)出,將窗口中命令復(fù)制到命令行中運(yùn)行即可
?
#博主測(cè)試使用aria2下載速度應(yīng)該在500kb/s左右 #如果希望達(dá)到更快的速度,請(qǐng)參考 https://github.com/proxyee-down-org/proxyee-down #使用proxyee-down下載同時(shí)將分段數(shù)調(diào)到最大(windows版本請(qǐng)自行百度)10.sourceinsight
sourceinsight是windows下常用的代碼瀏覽工具,雖然使用vim+ctags也能達(dá)到類似的效果,但習(xí)慣上還是更傾向于使用sourceinsight
sourceinsight沒有l(wèi)inux的發(fā)行版本,因此要在ubuntu上運(yùn)行需要安裝wine,具體操作方式如下(需要自行下載sourceinsight安裝包,3.5版本激活碼SI3US-205035-36448):
sudo apt-get install winewine Si3583Setup.exe
參考文獻(xiàn):
1.https://www.nvidia.cn/object/caffe-installation-cn.html (如何在 NVIDIA GPU 上下載并安裝CAFFE)
轉(zhuǎn)載于:https://www.cnblogs.com/WaitingForU/p/9022217.html
總結(jié)
以上是生活随笔為你收集整理的Linux下深度学习常用工具的安装的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么YUV全为0的图像是绿色的
- 下一篇: python版本切换 for Windo