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' ...
随机推荐
- Format a Hard Drive in Csharp C#格式化总结
using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Management; ...
- JS内置对象
字符串对象 <script> //字符串对象 var str = "Hello worldlsgjlsjg"; document.write('string.lengt ...
- php的查询数据
php中 连接数据库,通过表格形式输出,查询数据.全选时,下面的分选项都选中;子选项取消一个时,全选按钮也取消选中. <!DOCTYPE html PUBLIC "-//W3C//DT ...
- hdu 2092
Ps:wa了两次....一次是从加法那边暴力,然而算法错误..应该从乘法那边暴力破解...然而又没算负数..加上负数..直接暴力AC. 代码: #include "stdio.h" ...
- metaprogramming笔记
动态多态与静态多态 动态多态:允许我们通过单个基类指针或引用处理多个派生类型的对象. 模板元编程中强调静态多态,允许不同类型的对象以同样的方式被操纵,只要它们支持某种共通的语法即可. 动态多态,连同& ...
- Spring中配置文件applicationContext.xml配置详解
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...
- 解决:信息中插入avi格式的视频时,提示“unsupported video format”
[测试步骤]:新建信息,添加AVI格式的视频 [测试结果]:添加时弹出提示"unsupported video format" 该问题主要提现在手机彩信视频附件不支持该AVI格式的 ...
- C#判断字符串是否为数字
string i = Console.ReadLine(); int a=0; if (int.TryParse(i, out a) == false) / ...
- magento问题集2
SQLSTATE[42S02]: Base table or view not found: 1146 Table XXXXXX 安装Galathemes.com theme插件. 首页无法打开,提示 ...
- iOS-GCD用法
Grand Central Dispatch (GCD)是Apple开发的一个多核编程的解决方法. dispatch queue分成以下三种: 1)运行在主线程的Main queue,通过dispat ...