ubuntu18.04编译最新caffe错误修正

这里记录些编译caffe时的报错:

每次报错修改好后,别忘了先make clean,再make all -j4:


1.主要是cuda,nvcc路径问题,解决方案:

就是找到东西,把它复制到caffe想要的路径或者修改make.config文件中相应的库路径,个人比较喜欢复制的方法。。。


2.还有就是我用的CUDA9.1不再支持compute_20架构了,所以把以下两行注释了就好了。

CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \

        #-gencode arch=compute_20,code=sm_21 \


3. g++问题:

有两种方法,

方法一:版本要低于要求,我用的g++-5 gcc-5,结果5不行,又现装的4.8

sudo apt-get install gcc-4.8

sudo apt-get install g++-4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 40

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70

然后,在make.config文件中指定版本

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
CUSTOM_CXX := g++-4.8

方法二:去掉这个错误提醒

我是apt安装的nvidia-cuda-tool,所以是在/usr/include/crt/host_config.h

普遍的源码编译的是在/usr/local/cuda/include/host_config.h

我的是

#if __GNUC__ > 6

#error -- unsupported GNU version! gcc versions later than 6 are not supported!

#endif /* __GNUC__ > 6 */

大家可能是

< #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)
---
> //#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9)
115c115
< #error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
---
> //#error -- unsupported GNU version! gcc versions later than 4.9 are not supported!
117c117
< #endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */
---
 > //#endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */


4.大量 undefined reference to

这是是很多辅助库没装到它能找到的地方的问题:

比如:

undefined reference to `boost::archive  等一大长串

就是没找到boost的那一套,所以就先找一下它在哪里:

locate boost

看到它集中在两个地方/usr/lib/x86_64-linux-gnu/和/usr/include/

所以把他们分别加到makefile.config文件中相应的位置,让caffe找到他们:

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ /usr/include/ /usr/lib/x86_64-linux-gnu/
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ /usr/lib/x86_64-linux-gnu/

并且在Makefile中制定加上需要的库:

CUDA_LIB_DIR += $(CUDA_DIR)/lib

INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
ifneq ($(CPU_ONLY), 1)
    INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
    LIBRARY_DIRS += $(CUDA_LIB_DIR)
    LIBRARIES := cudart cublas curand
endif

LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5 \
        boost_serialization boost_program_options


最后,

make all -j8

make pycaffe -j8

就好
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值