Caffe编译踩坑(一):/usr/include/boost/system/error_code.hpp:233:21: error: looser throw specifier

近期在尝试跑LiteFlowNet,需要编译caffe,因为服务器上已经安装了CUDA11.3,其采用的环境是CUDA8.0+Cudnn5.1,因此安装了CUDA8.0的相关文件,并安装了gcc-4.8和g+±4.8。然而,在编译caffe时出现以下报错:

./include/caffe/parallel.hpp(99): warning: type qualifier on return type is meaningless

./include/caffe/parallel.hpp(99): warning: type qualifier on return type is meaningless

/usr/include/boost/system/error_code.hpp:233:21: error: looser throw specifier for ‘virtual const char* boost::system::error_category::std_category::name() const’
         virtual const char * name() const BOOST_NOEXCEPT
                     ^
/usr/include/c++/4.8/system_error:78:21: error:   overriding ‘virtual const char* std::error_category::name() const noexcept (true)’
     name() const noexcept = 0;
                     ^
/usr/include/boost/system/error_code.hpp:243:37: error: looser throw specifier for ‘virtual std::error_condition boost::system::error_category::std_category::default_error_condition(int) const’
         virtual std::error_condition default_error_condition( int ev ) const
                                     ^
/usr/include/c++/4.8/system_error:84:25: error:   overriding ‘virtual std::error_condition std::error_category::default_error_condition(int) const noexcept (true)’
     default_error_condition(int __i) const noexcept;
                         ^
/usr/include/boost/system/error_code.hpp:245:21: error: looser throw specifier for ‘virtual bool boost::system::error_category::std_category::equivalent(int, const std::error_condition&) const’
         virtual bool equivalent( int code, const std::error_condition & condition ) const
                     ^
/usr/include/c++/4.8/system_error:87:14: error:   overriding ‘virtual bool std::error_category::equivalent(int, const std::error_condition&) const noexcept (true)’
     equivalent(int __i, const error_condition& __cond) const noexcept;
              ^
/usr/include/boost/system/error_code.hpp:247:21: error: looser throw specifier for ‘virtual bool boost::system::error_category::std_category::equivalent(const std::error_code&, int) const’
         virtual bool equivalent( const std::error_code & code, int condition ) const
                     ^
/usr/include/c++/4.8/system_error:90:14: error:   overriding ‘virtual bool std::error_category::equivalent(const std::error_code&, int) const noexcept (true)’
     equivalent(const error_code& __code, int __i) const noexcept;
              ^
Makefile:590: recipe for target '.build_release/cuda/src/caffe/layers/correlation_layer1d.o' failed
make: *** [.build_release/cuda/src/caffe/layers/correlation_layer1d.o] Error 1
make: *** 正在等待未完成的任务....

在网上找了很久的解决方案,但是资料太少,仅有的一篇回答是需要在/usr/include/boost/config/compile/nvcc.hpp中添加

#  define BOOST_NO_CXX11_NOEXCEPT

遂尝试了一下,发现没有任何效果。之后,偶然看到关于改进boost代码的一个帖子,其中为了在CUDA8.0下禁用c++11的部分代码,boost作者在nvcc.hpp文件中添加了以下语句:

#if (BOOST_CUDA_VERSION >= 8000000) && (BOOST_CUDA_VERSION < 8010000)
#  define BOOST_NO_CXX11_NOEXCEPT
#endif

然而,虽然我在编译caffe时使用CUDA8.0,但是系统默认CUDA是11.3,所以在进行boost时会使用到C++11的代码,因此将本段代码注释,即可解决问题:

//#if (BOOST_CUDA_VERSION >= 8000000) && (BOOST_CUDA_VERSION < 8010000)
//#  define BOOST_NO_CXX11_NOEXCEPT
//#endif
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值