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' ...
随机推荐
- ZOJ 3747 - Attack on Titans (递推)
题意:有三个兵种R,G,C,选取N个排成一列,要求G至少有M个连续的,R至多有K个连续的,问有多少种排列方式. 此题与UVa 10328 - Coin Toss非常相似,都是问某个字符连续出现的种数. ...
- UITableViewCell 自适应高度 ios8特性
这篇文章介绍了在一个动态数据的 table view 中,cell 根据 text view 内容的输入实时改变 cell 和 table view 的高度.自动计算 cell 高度的功能使用 iOS ...
- Android布局文件layout.xml的一些属性值
第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 andr ...
- Mac 将mysql路径加入环境变量
1.打开终端,输入: cd ~ 会进入~文件夹 2.然后输入:touch .bash_profile 回车执行后, 2.再输入:open -e .bash_profile 会在TextEdit中打开这 ...
- PHP 防范IP攻击
<?php //查询禁止IP $ip =$_SERVER['REMOTE_ADDR']; $fileht=".htaccess2"; if(!file_exists($fil ...
- HDU 4819 Mosaic(13年长春现场 二维线段树)
HDU 4819 Mosaic 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4819 题意:给定一个n*n的矩阵,每次给定一个子矩阵区域(x,y,l) ...
- InitGoogleLogging坑爹
google::InitGoogleLogging(argv[0]); //::google::InitGoogleLogging(argv[0]); 加上这句,竟然没有日志
- LeetCode Binary Tree Right Side View (DFS/BFS)
题意: 给一棵二叉树,要求收集每层的最后一个节点的值.按从顶到底装进vector返回. 思路: BFS比较简单,先遍历右孩子就行了. /** * Definition for a binary tre ...
- 《深入浅出Node.js》第1章 Node简介
@by Ruth92(转载请注明出处) 第1章 Node简介 一.Node的起源 高性能Web服务器的要点:事件驱动.非阻塞I/O. 选择JavaScript的原因:高性能.符合事件驱动.没有历史包袱 ...
- 【Modal】
1.Bootstrap Modal 文档里标签.属性.方法.事件都写的很清楚 2.AngularUI - Bootstrap UI Bootstrap 2.1 $scope.open = functi ...