一个轻量级的深度学习框架,商用项目上面貌似用的比较多,废话不多说,看看怎么装
应为官网流程很详细,直接给出官网链接,针对一些有问题的地方给予补充(
算了,我还是写一下
)。我使用的平台式Ubuntu 16.04
,CUDA
,CUDNN
,OPENCV
都已经装好
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libgoogle-glog-dev \
libgtest-dev \
libiomp-dev \
libleveldb-dev \
liblmdb-dev \
libopencv-dev \
libopenmpi-dev \
libsnappy-dev \
libprotobuf-dev \
openmpi-bin \
openmpi-doc \
protobuf-compiler \
python-dev \
python-pip
sudo pip install \
future \
numpy \
protobuf
由于国内下载很慢,我将下好的代码上传到CSDN,后附链接
# Clone Caffe2's source code from our Github repository
git clone --recursive https://github.com/pytorch/pytorch.git && cd pytorch
git submodule update --init
# Create a directory to put Caffe2's build files in
mkdir build && cd build
# Configure Caffe2's build
# This looks for packages on your machine and figures out which functionality
# to include in the Caffe2 installation. The output of this command is very
# useful in debugging.
cmake ..
# Compile, link, and install Caffe2
sudo make install
意思是说Eigen的版本太低了
#error "Caffe2 requires Eigen to be at least 3.3.0.";
#error "Caffe2 requires Eigen to be at least 3.3.0.";
解决办法:
Eigen
版本:cat /usr/include/eigen3/Eigen/src/Core/util/Macros.h | grep VERSION
我的是这个样子,版本低于3.3.0
EIGEN_WORLD_VERSION 3
EIGEN_MAJOR_VERSION 2
EIGEN_MINOR_VERSION 92
下载最
github
上的新版本的,不要下官网上的,项目已经迁移到github
上面去了。
被墙下不了的点这个CSDN
如果下的是官网上的可能会下面的报错,应为
cuda9
需要高版本才能支持
usr/local/cuda-9.0/include/crt/common_functions.h:64:24: error: token ""__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
#define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."
^
/usr/local/cuda-9.0/include/crt/common_functions.h:64:24: note: in definition of macro '__CUDACC_VER__'
#define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/cuda-9.0/include/crt/common_functions.h:64:24: error: token ""__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
#define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."
^
/usr/local/cuda-9.0/include/crt/common_functions.h:64:24: note: in definition of macro '__CUDACC_VER__'
#define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported. Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."
然后解压,重命名为
eigen3
Eigen
cd /usr/include
sudo rm -rf eigen3/
Eigen
到原来路径sudo mv path/of/eigen3 /usr/include/
Eigen
版本: cat /usr/include/eigen3/Eigen/src/Core/util/Macros.h | grep VERSION
我的是这个样子:
EIGEN_WORLD_VERSION 3
EIGEN_MAJOR_VERSION 3
EIGEN_MINOR_VERSION 90
然后可以继续回去重新编译了
sudo make install
测试是否安装成功:
cd ~ && python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
如果
Failure
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: /home/username/pytorch/build/caffe2/python/caffe2_pybind11_state_gpu.so: undefined symbol: _Py_ZeroStruct
CRITICAL:root:Cannot load caffe2.python. Error: /home/username/pytorch/build/caffe2/python/caffe2_pybind11_state.so: undefined symbol: _Py_ZeroStruct
在
/home/username/pytorch/build/caffe2/python/
路径下执行下面命令
sudo ldconfig
再次执行测试
Success
更多问题可以去github上查找:https://github.com/caffe2/caffe2/labels/build