Yochengliu/MLIC-KD-WSD

error when I compile caffe

Closed this issue · 12 comments

Thanks for your code!

There is an error when I compiled caffe. Here is the error information

/home/imre/zlin/code/caffe/src/caffe/util/interp.cu(237): error: identifier "Half" is undefined /home/imre/zlin/code/caffe/src/caffe/util/interp.cu(238): error: "Half" is not a type name /home/imre/zlin/code/caffe/src/caffe/util/interp.cu(239): error: "Half" is not a type name

It seems that the "Half" below is not defined in interp.cu. How can I fix this problem?

void caffe_gpu_interp2_backward<Half,false>(const int channels, Half *data1, const int x1, const int y1, const int height1, const int width1, const int Height1, const int Width1, const Half *data2, const int x2, const int y2, const int height2, const int width2, const int Height2, const int Width2) {

Indeed, there is another error about "Half". File roi_pooling_layer.cu includes a half.hpp

#include "caffe/half/half.hpp"

which cause a not found error. And I can't find this half.hpp in caffe cloned from https://github.com/BVLC/caffe. I removed this line, then it goes well.

Sorry for the two compiling errors.
Error 1: we have update the mentioned files with new version.
Error2 : just removing that line.
Thank you for your findings, please have a try again and let us know if you succeed ^_^

Thank you for your help. These two errors have been fixed.

In interp.cu there still have a not exist error in line 3: #include "caffe/common.cuh". I removed it. Is that right?

And this time, error appears in data_transformer.cpp. Here is the error info:

/home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp: In member function ‘void caffe::DataTransformer<Dtype>::TransformDataLabel(const cv::Mat&, caffe::Blob<Dtype>*, int, int, int, Dtype*)’:
/home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:27:44: error: ‘class caffe::TransformationParameter’ has no member named ‘random_sized_crop’ const bool is_random_sized_crop = param_.random_sized_crop(); /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:46:51: error: there are no arguments to ‘Rand’ that depend on a template parameter, so a declaration of ‘Rand’ must be available [-fpermissive] const bool do_mirror = param_.mirror() && Rand(2); /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:46:51: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:81:48: error: there are no arguments to ‘Rand’ that depend on a template parameter, so a declaration of ‘Rand’ must be available [-fpermissive] h_off = Rand(img_height - crop_size + 1); /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:82:47: error: there are no arguments to ‘Rand’ that depend on a template parameter, so a declaration of ‘Rand’ must be available [-fpermissive] w_off = Rand(img_width - crop_size + 1); /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp: In instantiation of ‘void caffe::DataTransformer<Dtype>::TransformDataLabel(const cv::Mat&, caffe::Blob<Dtype>*, int, int, int, Dtype*) [with Dtype = float]’: /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:146:1: required from here /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:37:3: error: in argument to unary ! if (!is_random_sized_crop) { /home/imre/zlin/code/caffe/src/caffe/data_transformer.cpp:46:49: error: ‘Rand’ was not declared in this scope const bool do_mirror = param_.mirror() && Rand(2);

(...... many errors about Rand ......)

How can I fix it?

By the way, I replaced the origin data_transformer.cpp and data_transformer.hpp using the files you give.

@Yochengliu Is there any solution?

Error1: We updated all the interp-relative files in last issue, please check them or just clone again.
Error2: We add the Rand() functions in data_transformer.cpp/.hpp. Note that do not directly replace the .cpp files in official caffe with the given .cpp files, maybe you should add the given functions into the corresponding codes (cpp/hpp).
Please show us if you find errors again.

Thanks for your help again. I add code of provided data_transformer.cpp/.hpp to original files and the problem is solved.

This time there are three 'not found' errors:

data_layers.hpp:17:43: fatal error: caffe/internal_thread_array.hpp: No such file or directory
data_layers.hpp:21:37: fatal error: caffe/util/hdxy_units.hpp: No such file or directory
human_att_data_layer.cpp:18:39: fatal error: caffe/util/mpi_function.hpp: No such file or directory

So can you provide the three hpp files?

Just remove them. It makes no difference.
Please try again.

Error happens again...

This time the problems are in human_att_data_layer.cpp:

In file included from /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:12:0: /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:27:58: error: expected template-name before ‘<’ token class HumanAttDataLayer : public BasePrefetchingDataLayer<Dtype> { ^ /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:27:58: error: expected ‘{’ before ‘<’ token /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:27:58: error: expected unqualified-id before ‘<’ token /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:23:53: error: invalid use of incomplete type ‘class caffe::HumanAttDataLayer<Dtype>’ HumanAttDataLayer<Dtype>::~HumanAttDataLayer<Dtype>() {
In file included from /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:12:0: /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:27:7: note: declaration of ‘class caffe::HumanAttDataLayer<Dtype>’ class HumanAttDataLayer : public BasePrefetchingDataLayer<Dtype> { ^ /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:28:41: error: invalid use of incomplete type ‘class caffe::HumanAttDataLayer<Dtype>’ int HumanAttDataLayer<Dtype>::Rand(int n) {
In file included from /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:12:0: /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:27:7: note: declaration of ‘class caffe::HumanAttDataLayer<Dtype>’ class HumanAttDataLayer : public BasePrefetchingDataLayer<Dtype> { ^ /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:38:38: error: invalid use of incomplete type ‘class caffe::HumanAttDataLayer<Dtype>’ const vector<Blob<Dtype>*>& top) {
In file included from /home/imre/zlin/code/caffe/include/caffe/blob.hpp:8:0, from /home/imre/zlin/code/caffe/include/caffe/layers/data_layers.hpp:12, from /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:12: /home/imre/zlin/code/caffe/src/caffe/layers/human_att_data_layer.cpp:361:19: error: explicit instantiation of ‘class caffe::HumanAttDataLayer<float>’ before definition of template INSTANTIATE_CLASS(HumanAttDataLayer); ^ /home/imre/zlin/code/caffe/include/caffe/common.hpp:43:18: note: in definition of macro ‘INSTANTIATE_CLASS’ template class classname<float>;

---------many errors about function of class HumanAttDataLayer---------

You can see this file for detail: https://pan.baidu.com/s/1PwjgatI7Fp4pXjuLPOKAmg

I will be very busy in next days. After my busy time, I will upload an official caffe for your convenience before the end of this month.

Sorry for a long wait. We have uploaded caffe-MLIC, in which the implementation of MLIC-KD-WSD is merged. Please check it and have a try.

Thank you for your update! This time the compile of caffe is more convenient.

But I still got an error in human_att_data_layer.cpp, here is the error info:

/home/imre/zlin/code/MLIC-KD-WSD/caffe-MLIC/src/caffe/layers/human_att_data_layer.cpp:324:100: error: redeclaration of ‘std::vector<std::__cxx11::basic_string<char> > caffe::HumanAttDataLayer<Dtype>::StrSplit(std::__cxx11::string&, std::__cxx11::string)’ may not have default arguments [-fpermissive] std::vector<std::string> HumanAttDataLayer<Dtype>::StrSplit(std::string &str, std::string sep = ",")

It may be caused by the different version of c++ std. I suggest you delete the default argument of 'sep'. The two links below may help you.

https://stackoverflow.com/questions/32105975/why-cant-i-have-template-and-default-arguments

https://stackoverflow.com/questions/13295530/error-default-argument-given-for-parameter-after-previous-specification

I build it successfully! Thanks for your help again!