caffe 安装

#1 sudo 安装caffe

sudo apt-get install git
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 libatlas-base-dev
sudo apt-get install python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

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

problem: can’t find hdf5

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial

2、安装caffe,没有root权限,Ubuntu

Ubuntu
https://github.com/yosinski/caffe/blob/jason_public/doc/linux-no-root-install-log.md
protobuf 2.50
安装包https://github.com/google/protobuf/releases?after=v2.6.1
//snappy
http://pkgs.fedoraproject.org/repo/pkgs/snappy/
Install leveldb

git clone https://github.com/google/leveldb.git
[~/temp/leveldb-1.15.0] $ make
cd /home/gaomingda/caffe_dev/leveldb/out-shared/
$ cp -av libleveldb.* $HOME/local/lib/
cd /home/gaomingda/caffe_dev/leveldb/out-static/
$ cp -av libleveldb.* $HOME/local/lib/
[~/temp/leveldb-1.15.0] $ cp -av include/leveldb $HOME/local/include/

install hdf5
https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.14/src/

Install OpenBlas

$ cd ~/temp/
$ git clone git://github.com/xianyi/OpenBLAS
$ cd OpenBlas
$ make FC=gfortran
#显示没有安装gfortran 
$ make PREFIX=$HOME/local install
#安装gfortran,no-root
https://www.scivision.co/install-linuxbrew/

安装OpenCV3
conda install -c menpo opencv3=3.2.0
取消注释caffe/Makefile.config中
OPENCV_VERSION := 3
然后终端

export LD_LIBRARY_PATH=/home/hossein/anaconda2/lib:$LD_LIBRARY_PATH

或者
Instead of globally modifying LD_LIBRARY_PATH, we can add the following line to the Makefile.config (for example after the lines that define ANACONDA_HOME and PYTHON_INCLUDE [lines 76-79 I believe]):

LDFLAGS += -Wl,-rpath,$(ANACONDA_HOME)/lib
This will basically tell the Caffe library at runtime where to look for libraries

ImportError: No module named caffe.proto
可能原因:这种情况一般是没有把caffe中的和python相关的内容的路径添加到python的编译路径中。
解决办法:执行命令

export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH  

#在.100机子无权限编译

In file included from .build_release/src/caffe/proto/caffe.pb.cc:4:0:
.build_release/src/caffe/proto/caffe.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^
.build_release/src/caffe/proto/caffe.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^
.build_release/src/caffe/proto/caffe.pb.h:14:2: error: #error your headers.
 #error your headers.

anaconda和local安装 的protobuf冲突

#查看版本
which protoc
protoc --version
#尝试卸载anaconda的

conda uninstall protobuf

#不好使
#conda安装protobuf-2.5
conda install -c stephentu protobuf
**install protobuf 2.6.1
conda install -c anaconda protobuf=2.6.1
指定版本
conda install -y --channel https://conda.anaconda.org/conda-forge
gflags
glog
numpy
protobuf=3.2.0
发现不是anaconda的问题,而是HOME/local必须安装protobuf-2.50 卸载,先进入安装包,然后make uninstall

sudo权限安装的https://www.howtoinstall.co/en/ubuntu/trusty/protobuf-compiler?action=remove

2、

/home/gaomingda/anaconda2/lib/libopencv_imgcodecs.so: undefined reference to `jpeg_stdio_dest@LIBJPEG_9.0'
collect2: error: ld returned 1 exit status
Makefile:619: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed

参考http://write.blog.csdn.net/mdeditor#!postId=78480844 OpenCV3的安装

3、 在python中导入caffe时

from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: libglog.so.0: cannot open shared object file: No such file or directory

解决方案,将 加入

LD_LIBRARY_PATH=/home/gaomingda/local/lib:$LD_LIBRARY_PATH

#在服务器matplotlib不能显示,报错
参考https://www.cnblogs.com/xuanxufeng/p/6240659.html

#二、windows

#三、caffe2 ubuntu16.04 anaconda2 安装
其中 Anaconda is installed in ~/anaconda2

# Create a conda environment (optional)
conda create -n my_caffe2_env python=2.7 && source activate my_caffe2_env

# Install required packages
# mkl isn't actually required, but is really recommended for Anaconda
conda install -y \
    future \
    gflags \
    glog \
    lmdb \
    mkl \
    mkl-include \
    numpy \
    opencv \
    protobuf \
    snappy \
    six

# Clone Caffe2
cd ~ && git clone --recursive https://github.com/caffe2/caffe2.git && cd caffe2

# Make Caffe2 in a separate folder to avoid polluting the Caffe2 source tree.
# This can be anywhere you want it
mkdir build && cd build

# Add flags to this command to control which packages you want to use. The
# options to use are at the top of CMakeLists.txt in the topmost Caffe2
# directory
# use cuda,管理员已经装好驱动
cmake -DUSE_CUDA=ON -DUSE_LEVELDB=OFF -DCMAKE_PREFIX_PATH=~/anaconda2/envs/my_caffe2_env -DCMAKE_INSTALL_PREFIX=~/anaconda2/envs/my_caffe2_env -DCMAKE_CXX_FLAGS=-D__GLIBCXX_USE_CXX11_ABI=0 ..
make install

环境变量

export PYTHONPATH=/home/gaomingda/anaconda2/envs/my_caffe2_env:$PYTHONPATH
export PYTHONPATH=$PYTHONPATH:/home/gaomingda/caffe2/build
export LD_LIBRARY_PATH=/home/gaomingda/anaconda2/envs/my_caffe2_env/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/home/gaomingda/local:$PATHONPATH
export PYTHONPATH=$PATHONPATH:/home/gaomingda/caffe2/build
export LD_LIBRARY_PATH=/home/gaomingda/local/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/home/gaomingda1/anaconda2/envs/my_caffe2_env:$PYTHONPATH
export PYTHONPATH=$PYTHONPATH:/home/gaomingda1/pytorch/build
export LD_LIBRARY_PATH=/home/gaomingda1/anaconda2/envs/my_caffe2_env/lib:$LD_LIBRARY_PATH

本地

export PYTHONPATH=/usr/local:$PATHONPATH
export PYTHONPATH=$PATHONPATH:/home/gaomingda/pytorch/build
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

jupyter notebook 映射到本地

ssh -L localhost:8000:localhost:8888 gaomingda@202.195.239.99

其中8000为本地端口, 在本地浏览器中搜索 localhost:8000, 输入终端的密码

#六、Ubuntu wget 正在连接 失败:拒绝连接
http://blog.csdn.net/asiawong/article/details/78558120
#七 、卸载nvidia驱动
sudo apt-get remove --purge nvidia*
或者 sudo /usr/bin/nvidia-uninstall
安装nvidia
参考https://blog.csdn.net/full_speed_turbo/article/details/76339296

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-375 # 根据提示安装相应的版本
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev```

出现问题

##########问题
sudo ldconfig
/sbin/ldconfig.real: /usr/lib/nvidia-384/libEGL.so.1 is not a symbolic link

/sbin/ldconfig.real: /usr/lib32/nvidia-384/libEGL.so.1 is not a symbolic link
##########解决
sudo mv /usr/lib/nvidia-384/libEGL.so.1 /usr/lib/nvidia-384/libEGL.so.1.org
sudo mv /usr/lib32/nvidia-384/libEGL.so.1 /usr/lib32/nvidia-384/libEGL.so.1.org
sudo ln -s /usr/lib/nvidia-384/libEGL.so.384.111 /usr/lib/nvidia-384/libEGL.so.1
sudo ln -s /usr/lib32/nvidia-384/libEGL.so.384.11 /usr/lib32/nvidia-384/libEGL.so.1

**3、安装cuda**

**4、安装cudnn-8.0-linux-x64-v5.1.tgz**

先解压,解压后为cuda文件夹

cd cuda
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.5
sudo ln -s libcudnn.so.5.1.10 libcudnn.so.5 #生成软衔接
sudo ln -s libcudnn.so.5 libcudnn.so #生成软链接
sudo ldconfig

**无权限安装nccl2**
git clone https://github.com/NVIDIA/nccl.git
cd nccl
make -j32 src.build CUDA_HOME=/home/gaomingda/local/cuda-9.0 NVCC_GENCODE="-gencode=arch=compute_70,code=sm_70"
make -j32 install CUDA_HOME=/home/gaomingda/local/cuda-9.0 prefix=<path to install> # /$HOME/local
#添加环境路径
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/XXX/local/lib/

没有更多推荐了,返回首页