虚拟机ubuntu18安装caffe
文章目录1.环境2.update 最新系统3.卸载amazon4.安装截图工具5.安装git version工具1.环境参考:VMware Workstation 15 Pro安装ubuntu系统VMware Workstation 15 ProUbuntu18.04.22.update 最新系统sudo apt-get updatesudo apt-get upgradesudo...
文章目录
参考
1.环境
参考:VMware Workstation 15 Pro安装ubuntu系统
VMware Workstation 15 Pro
Ubuntu18.04.2
2.update 最新系统
Ubuntu 18.04 LTS 更换国内源——解决终端下载速度慢的问题
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
问题:Set the RESUME variable to override this
参考:https://www.linode.com/community/questions/17283/apt-get-update-and-upgrade-question-on-ubuntu-18
sudo vim /etc/initramfs-tools/conf.d/resume #Also you will need to update /etc/initramfs-tools/conf.d/resume
#添加内容:RESUME=UUID=<Your UUID>
sudo update-initramfs -u -k all #Now rebuild your initramfs
sudo reboot
3.ubuntu18 1920x1080分辨率永久设置
#1. 新建 $ sudo vim /etc/X11/xorg.conf #如果没有安装vim,可以使用“sudo gedit /etc/X11/xorg.conf”)
#粘贴以下内容:
Section "Monitor"
Identifier "Configured Monitor"
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
Option "PreferredMode" "1920x1080_60.00"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
EndSection
Section "Device"
Identifier "Configured Video Device"
EndSection
#2、保存。重启后就变成1920x1080了。!
4.卸载amazon
$ sudo apt-get remove unity-webapps-common #ubuntu16
$ sudo apt-get remove ubuntu-web-launchers #ubuntu 18
5.安装截图工具
$ sudo apt-get install shutter
6.安装git version工具
#判断系统有没有安装git工具
git –version
#如果提示没有,用如下命令安装:
sudo apt-get install git
#check git 安装是否成功:
git –version #有版本号提示即表示成功安装
7.gvim安装
#先安装vim基本包(没有gui图形界面)
sudo apt-get install vim
#再安装gvim包(有独立的gui图形界面)
sudo apt-get install vim-gtk
sudo apt-get install libcanberra-gtk-module #不安装此包,会提示Gtk-Message: Failed to load module "canberra-gtk-module"
8.安装caffe预编译版本
***重点:默认python为2.7,如下需要3.x版本,请按如下方法修改系统默认python版本
#using these commands can help you:
check the version of python3
python3 --version
alias: alias python=python3
alias pip=pip3
re-login: . ~/.bashrc
check the python version again: python --version
参考python3.6caffe安装:https://www.jianshu.com/p/5afdb561ce94
9.caffe源码安装:
cd ~
mkdir work
cd work
git clone https://github.com/BVLC/caffe.git
cd caffe
sudo cp Makefile.config.example Makefile.config
sudo vi Makefile.config
#修改取消注释
CPU_ONLY := 1
USE_OPENCV := 1
OPENCV_VERSION := 3
MATLAB_DIR := /usr/local/MATLAB/R2018a
make all -j8 #报错,需要安装make
sudo apt-get install make
sudo apt-get install make-guile
sudo apt-get install g++
sudo apt-get install libprotobuf-dev
sudo apt-get install protobuf-c-compiler protobuf-compiler
sudo apt-get install libboost-all-dev #--no-install-recommends
sudo apt-get install libgflags-dev
sudo apt-get install libgoogle-glog-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libhdf5-serial-dev
sudo vi Makefile.config
#将
#OPENCV_VERSION := 3
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
#修改成如下
OPENCV_VERSION := 3
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
sudo apt-get install libopencv-dev
sudo apt-get install libleveldb-dev
sudo apt-get install liblmdb-dev
sudo apt-get install libsnappy-dev
#sudo apt-get install libopenblas-dev
make all -j8
编译成功
如果还不成功,出现如下报错信息
...
build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)
...
做如下修改:
sudo vi Makefile.config
#将
# USE_PKG_CONFIG := 1
#修改成如下
USE_PKG_CONFIG := 1
#然后重新编译即可
make clean
make all -j8
10. make test
make test -j8
make runtest -j8
make runtest -j8
F1029 14:49:11.855605 16126 db_leveldb.cpp:16] Check failed: status.ok() Failed to open leveldb IO error: /LOCK: Permission denied
#解决方法:主要是被另一个线程占用
make runtest
11. make pycaffe
ubuntu16安装caffe,配置python,matlab接口
sudo apt-get install python-numpy
make pycaffe
make pytest
File "caffe/draw.py", line 22, in <module>
import pydot
ImportError: No module named pydot
#参考:https://www.jianshu.com/p/2bf741d99bec
sudo -H pip install pydot
sudo apt install graphviz
12. make matcaffe
参考:http://www.manongjc.com/article/53635.html
参考:http://www.ishenping.com/ArtInfo/1984802.html
make matcaffe
make mattest
问题参考:https://blog.csdn.net/shaoxiaohu1/article/details/51411301
类似libopencv问题: libopencv*.so.* 找不问题,可以如下方法解决
cd /usr/local/Matlab/R2018a/sys/os/glnxa64/
sudo rm libcudart.so.xxx #如果没有,则不需要执行此步,直接执行下一步
sudo ln -s /usr/local/cuda-10.0/lib64/libcudart.so.xxx .
#缺少其它so,解决问题类似
#列如
sudo ln -s /usr/local/cuda-10.0/lib64/libcublas.so.xxx .
问题:Invalid MEX-file ‘/home/tt03/work/caffe/matlab/+caffe/private/caffe_.mexa64’: libopencv_highgui.so.3.4: cannot open shared object file: No such file or
directory.
类似libopencv问题: libopencv*.so.* 找不问题,可以如下方法解决
cd /usr/local/Matlab/R2018a/bin/glnxa64/
sudo rm libcudart.so.xxx #如果没有,则不需要执行此步,直接执行下一步
sudo ln -s /usr/local/lib/libopencv*.so.xxx .
#缺少其它so,解决问题类似
#列如
sudo ln -s /usr/local/lib/libopencv_highgui.so.xxx .
13. Caffe测试
#测试Caffe是否正常
cd caffe
vim examples/mnist/lenet_solver.prototxt
#将
solver_mode: GPU
#修改成如下
solver_mode: CPU
sh data/mnist/get_mnist.sh
sh examples/mnist/create_mnist.sh
sh examples/mnist/train_lenet.sh
14.设置caffe环境变量
sudo echo export PYTHONPATH="/path/to/caffe/python":$PYTHONPATH >> ~/.bashrc
source ~/.bashrc
#测试
python
>>>>import caffe
>>>>exit() #推出测试
#ImportError: No module named skimage.io 报错信息
sudo apt-get install python-skimage
#ImportError: No module named google.protobuf.internal 报错信息
sudo apt-get install python-protobuf
#环境准备完成!!!!
python3环境
sudo echo export PYTHONPATH="/path/to/caffe/python":$PYTHONPATH >> ~/.bashrc
source ~/.bashrc
#测试
python
>>>>import caffe
>>>>exit() #推出测试
#ImportError: No module named numpy 报错信息
pip3 apt-get install numpy
#ImportError: No module named skimage.io 报错信息
sudo apt-get install scikit-image
#ImportError: No module named google.protobuf.internal 报错信息
sudo apt-get install python-protobuf
#环境准备完成!!!!
caffe安装python
官网参考
cd path-to-caffe/python
for req in $(cat requirements.txt); do pip install $req; done
#不推荐如下方式
mkdir build
cd build
sudo apt install cmake
cmake ..
make all
make install
make runtest
#遇到报错时参考第一种方法解决
基于Anaconda编译caffe+pycaffe+matcaffe in Ubuntu[不用sudo权限]
参考:https://www.cnblogs.com/notesbyY/p/11594435.html
更多推荐
所有评论(0)