caffe: fuck compile error again : error: a value of type "const float *" cannot be used to initialize an entity of type "float *"

[email protected]:~/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
[email protected]:~/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,先试试吧。。。

 

时间: 2016-02-24
Tags: type, file, entity, void

caffe: fuck compile error again : error: a value of type "const float *" cannot be used to initialize an entity of type "float *"的相关文章

ERROR internal error process exited while conne错误

使用virt-install安装vm的时候出现了一下错误,解决方法如下: $sudo ./create-vm-demo.sh Starting install- ERROR internal error process exited while connecting to monitor: char device redirected to /dev/pts/2 kvm: -drive file=/home/muge0913/workstation/kvm/test.img,if=none,id

sql-SQL Error(3) : Error writing file

问题描述 SQL Error(3) : Error writing file 今天打开HeidiSQL想要在昨天的视图里增加一个查询的字段,就发生了一下错误: 后来把视图删除了 重新建 还是报这个错 我要怎么办.. 解决方案 http://stackoverflow.com/questions/7415710/mysql-writing-file-error-errcode-28

Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version

Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class 今天在idea上,利用scala的随机函数,写了一个测试程序,往kafka的服务器不间断写数据,程序写完后,打架包的时候报错. 解决方法一: 把项目里src下方的"test"文件夹删除后再打包就不报错了,"test"文件夹

测试-c语言程序编译出错error: syntax error before &amp;amp;quot;typedef&amp;amp;quot;

问题描述 c语言程序编译出错error: syntax error before "typedef" 设计的一个顺序循环队列和测试函数,结果编译的时候就有好多error: syntax error before ""不知道要怎么改,求帮助~ 这是我的代码: 头文件: #include typedef struct SeqCQueue { DataType queue[MaxQueueSize]; int MaxQueueSize; int rear; int fro

人脸识别-linux下qt中opencv打开摄像头HIGHGUI ERROR:OpenCV Error:

问题描述 linux下qt中opencv打开摄像头HIGHGUI ERROR:OpenCV Error: 我在Ubuntu下用qt结合opencv做一个人眼状态识别的程序,qt做界面,程序在vs控制台环境下已经可以运行,但是qt下出错.错误信息 如下: HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/mkc/op

php 数据采集-php Parse error: syntax error, unexpected T_VARIABLE in 错误

问题描述 php Parse error: syntax error, unexpected T_VARIABLE in 错误 <?php session_start(); $username=$_post[user]; $sql=mysql_query("select*from luntan where regname="$username""); $result=mysql_fetch_array($sql); if($result!=flase){ ec

发送一次消息却来很多次回调???-(void)didSendMessage:(EMMessage *)message error:(EMError *)error

问题描述 //发送音频消息        EMMessage *tempMessage = [ChatSendHelper sendVoice:voice                                                toUsername:_conversation.chatter                                               isChatGroup:YES                              

【我的Android进阶之旅】解决 Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容。请查看计算机的系统信息,了解是否需要 x86

一.错误描述 刚刚打开Android Studio新建一个项目,然后就编译不了,报了如下所示的错误: 错误描述为: Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容.请查看计算机的系统信息,了解是否需要 x86 (32 位)或 x64 (64 位)版本的程序,然后联系软件发布者. 分析错误 原来是因为JDK版本和之前配置的JDK版本不一致导致的. 1.查看系统的JDK版本 系统JDK之前从JDK1.7升级到了JDK1.8,如下图

【技术贴】webservice 调用 Transport error : 401 Error:Una

    解决 webservice 调用之后报错:调用异常:Transport error : 401 Error:Unauthorized 授权失败. 加入如下代码 //Sap需要ws-security的认证,调用sap webservice的认证信息需要输入用户名和密码: HttpTransportProperties.Authenticator sapAuth = new HttpTransportProperties.Authenticator(); sapAuth.setUsernam