caffe: fuck compile error again : error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
wangxiao@wangxiao-GTX980:~/Downloads/caffe-master$ make -j8
find: `wangxiao/bvlc_alexnet/spl': No such file or directory
find: `caffemodel': No such file or directory
find: `wangxiao/bvlc_alexnet/0.77': No such file or directory
find: `caffemodel': No such file or directory
NVCC src/caffe/layers/euclidean_loss_layer.cu
src/caffe/layers/euclidean_loss_layer.cu(41): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
detected during instantiation of "void caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &, const std::vector<__nv_bool, std::allocator<__nv_bool>> &, const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &) [with Dtype=float]"
(140): here
src/caffe/layers/euclidean_loss_layer.cu(42): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
detected during instantiation of "void caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &, const std::vector<__nv_bool, std::allocator<__nv_bool>> &, const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &) [with Dtype=float]"
(140): here
src/caffe/layers/euclidean_loss_layer.cu(41): error: a value of type "const double *" cannot be used to initialize an entity of type "double *"
detected during instantiation of "void caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &, const std::vector<__nv_bool, std::allocator<__nv_bool>> &, const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &) [with Dtype=double]"
(140): here
src/caffe/layers/euclidean_loss_layer.cu(42): error: a value of type "const double *" cannot be used to initialize an entity of type "double *"
detected during instantiation of "void caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &, const std::vector<__nv_bool, std::allocator<__nv_bool>> &, const std::vector<caffe::Blob<Dtype> *, std::allocator<caffe::Blob<Dtype> *>> &) [with Dtype=double]"
(140): here
4 errors detected in the compilation of "/tmp/tmpxft_000007e5_00000000-16_euclidean_loss_layer.compute_50.cpp1.ii".
make: *** [.build_debug/cuda/src/caffe/layers/euclidean_loss_layer.o] Error 1
wangxiao@wangxiao-GTX980:~/Downloads/caffe-master$
----------------------------------------------------------------------
----------------------------------------------------------------------
原因分析:
主要是因为,在欧式距离损失函数中,我增添了以下两句话:
Dtype* diff_cpu_data = bottom[i]->mutable_cpu_diff();
Dtype* label_data = bottom[1]->cpu_data(); // label data: 0 or 1
Dtype* predict_data = bottom[0]->cpu_data(); // predict data
再来看看提示的错误:
src/caffe/layers/euclidean_loss_layer.cu(41): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
detected during instantiation of "void
caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const
std::vector<caffe::Blob<Dtype> *,
std::allocator<caffe::Blob<Dtype> *>> &, const
std::vector<__nv_bool, std::allocator<__nv_bool>> &,
const std::vector<caffe::Blob<Dtype> *,
std::allocator<caffe::Blob<Dtype> *>> &) [with
Dtype=float]"
(140): here
src/caffe/layers/euclidean_loss_layer.cu(42): error: a value of type "const float *" cannot be used to initialize an entity of type "float *"
detected during instantiation of "void
caffe::EuclideanLossLayer<Dtype>::Backward_gpu(const
std::vector<caffe::Blob<Dtype> *,
std::allocator<caffe::Blob<Dtype> *>> &, const
std::vector<__nv_bool, std::allocator<__nv_bool>> &,
const std::vector<caffe::Blob<Dtype> *,
std::allocator<caffe::Blob<Dtype> *>> &) [with
Dtype=float]"
(140): here
肯定是少了 const 约束:
so , 改为:
const Dtype* label_data = bottom[1]->cpu_data(); // label data: 0 or 1
const Dtype* predict_data = bottom[0]->cpu_data(); // predict data
在编译,就ok啦 ~~
2. 问题2:
CXX src/caffe/layers/accuracy_layer.cpp
src/caffe/layers/accuracy_layer.cpp: In instantiation of ‘void caffe::AccuracyLayer<Dtype>::Forward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]’:
src/caffe/layers/accuracy_layer.cpp:286:1: required from here
src/caffe/layers/accuracy_layer.cpp:98:21: error: assignment of read-only location ‘*(bottom_data + 84u)’
bottom_data[21] = 1; bottom_data[22] = 0; bottom_data[23] = 0; bottom_data[24] = 0;
看到错误就应该知道:错误的原因是给只读的变量赋值了。。。
但是,又想改变那个值,来作为最后求解的结果,怎么办呢? 好吧,那就只好先将该变量存到一个中间变量里面去了,但是,问题又来了,原本const 的变量可以赋值给普通的变量么?
例如: float a = const float b ? 这样ok么?我觉得不ok,先试试吧。。。
caffe: fuck compile error again : error: a value of type "const float *" cannot be used to initialize an entity of type "float *"的更多相关文章
- ubuntu下安装pandas出现 compile failed with error code 1 in /tmp/pip_build_hadoop/pandas
都是用pip装的,是不是应该用apt-get 装的呀 ubuntu下安装pandas (出现 compile failed with error code 1 in /tmp/pip_build_ha ...
- Inceptor [Code: 40000, SQL State: 42000] COMPILE FAILED: Internal error NullPointerException: [Error 40000] java.lang.NullPointerException
下面代码报空指针 with `__all_dim__` as ( select * from ( select from_unixtime(unix_timestamp(`__bts__`) -1,' ...
- fatal error C1189: #error : core.hpp header must be compiled as C++
两次opencv工程需要设置为C++编译:找了一半天的解决方法. I am building a C application that uses OpenCV. when compiling, I g ...
- AndroidStudio与eclipse打包的时候报错。Error:(4) Error: "ssdk_instapager_login_html" is not translated in "en"
作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985 QQ986945193 博客园主页:http://www.cnblogs.com/mcxiaobing ...
- sqoop:Failed to download file from http://hdp01:8080/resources//oracle-jdbc-driver.jar due to HTTP error: HTTP Error 404: Not Found
环境:ambari2.3,centos7,sqoop1.4.6 问题描述:通过ambari安装了sqoop,又添加了oracle驱动配置,如下: 保存配置后,重启sqoop报错:http://hdp0 ...
- MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL
MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL 是因为目标板的芯片处于休眠 ...
- Android Studio Error:CreateProcess error=216
Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you' ...
- mysql [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist (转载)
mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 2013-11-2 ...
- [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
mysql 启动总是报错: 错误日志中显示: [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' ...
随机推荐
- 显示pdf
document.all[document.all.PDFNotKnown ? "IfNoAcrobat" : "IfAcrobat"].style.displ ...
- Ubuntu 14.10 下安装java反编译工具 jd-gui
系统环境,Ubuntu 14.10 ,64位 1 下载JD-GUI,网址http://221.3.153.126/1Q2W3E4R5T6Y7U8I9O0P1Z2X3C4V5B/jd.benow.ca/ ...
- “java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
最近在项目中使用hibernate查询时,总报错“java.sql.SQLException: Value '0000-00-00' can not be represented as java.sq ...
- android avoiding-memory-leaks
android avoiding-memory-leaks Memory Leak是会有多个方面会引起的,比如Drawable, RemoteViews, Receiver, Cursor,Input ...
- python 优雅的使用正则表达式 ~ 2
使用正则表达式 那些基础的理论也说了不少了现在就开始 实操 ( 不知道为啥特别喜欢这个词... ) 吧 . 上一节课说过 正则表达式也是一门语言 , 他被集成到了python当中 , 并且用 re 模 ...
- 51 nod 机器人走方格
从一个长方形的方格的右上角 走到 左下角 , 问一共有多少种不同的路线可以达到 . #include<stdio.h> #include<string.h> #include& ...
- Android Studio And Gradle
AS特色: 智能感知体验特好,堪比VS 布局预览,手写布局后预览页面即时显示,便于布局调整和优化 编辑速度飞快流畅,毫无eclipse的卡顿 布局或源码中有图标和颜色的预览,十分直观 调试时体验极佳 ...
- iOS App提交指南-协议、税务和银行业务
App通过审核时,选择的是手动发布,想着等到自己生日那天来发布,当做留个纪念,结果生日当天发布时,由于App属于收费应用,还需要填写协议.税务和银行信息,结果又急急忙忙地去找了下这方面的资料,现在把整 ...
- css3 动画贝塞尔曲线
http://cubic-bezier.com/#.17,.67,.83,.67 缓动函数速查表: http://www.xuanfengge.com/easeing/easeing/ Ceaser: ...
- 钉子和小球_DP
Description 有一个三角形木板,竖直立放,上面钉着n(n+1)/2颗钉子,还有(n+1)个格子(当n=5时如图1).每颗钉子和周围的钉子的距离都等于d,每个格子的宽度也都等于d,且除了最左端 ...