lmb-freiburg / flownet2

FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
https://lmb.informatik.uni-freiburg.de/Publications/2017/IMKDB17/
Other
1k stars 318 forks source link

‘RandomGeneratorParameter’ does not name a type, maybe need to add `#include "caffe/proto/caffe.pb.h"` in the file `$CAFFE_ROOT$/include/caffe/util/rng.hpp` #17

Closed xmfbit closed 7 years ago

xmfbit commented 7 years ago

When I try to compile your code, error occurs like this.

examples/mnist examples/siamese examples/cpp_classification examples/cifar10 matlab/+caffe/private python/caffe src/caffe src/caffe/layers src/caffe/solvers src/caffe/proto src/caffe/util src/caffe/test src/gtest tools
PROTOC src/caffe/proto/caffe.proto
CXX src/caffe/layers/inner_product_layer.cpp
CXX src/caffe/layers/window_data_layer.cpp
CXX src/caffe/layers/input_layer.cpp
CXX src/caffe/layers/cudnn_relu_layer.cpp
CXX src/caffe/layers/silence_layer.cpp
CXX src/caffe/layers/absval_layer.cpp
CXX src/caffe/layers/neg_relu_layer.cpp
CXX src/caffe/layers/recurrent_layer.cpp
CXX src/caffe/layers/bnll_layer.cpp
CXX src/caffe/layers/prelu_layer.cpp
CXX src/caffe/layers/base_data_layer.cpp
CXX src/caffe/layers/imgreader_layer.cpp
CXX src/caffe/layers/slice_layer.cpp
CXX src/caffe/layers/sigmoid_layer.cpp
CXX src/caffe/layers/lrn_layer.cpp
CXX src/caffe/layers/tanh_layer.cpp
CXX src/caffe/layers/mean_layer.cpp
CXX src/caffe/layers/batch_norm_layer.cpp
CXX src/caffe/layers/pooling_layer.cpp
CXX src/caffe/layers/cudnn_sigmoid_layer.cpp
CXX src/caffe/layers/flatten_layer.cpp
CXX src/caffe/layers/hdf5_output_layer.cpp
CXX src/caffe/layers/softmax_layer.cpp
CXX src/caffe/layers/contrastive_loss_layer.cpp
CXX src/caffe/layers/downsample_layer.cpp
CXX src/caffe/layers/cudnn_pooling_layer.cpp
CXX src/caffe/layers/hdf5_data_layer.cpp
CXX src/caffe/layers/data_layer.cpp
CXX src/caffe/layers/cudnn_conv_layer.cpp
CXX src/caffe/layers/channel_norm_layer.cpp
CXX src/caffe/layers/custom_data_layer.cpp
CXX src/caffe/layers/neuron_layer.cpp
CXX src/caffe/layers/tile_layer.cpp
CXX src/caffe/layers/l1loss_layer.cpp
CXX src/caffe/layers/batch_reindex_layer.cpp
CXX src/caffe/layers/dummy_data_layer.cpp
CXX src/caffe/layers/im2col_layer.cpp
CXX src/caffe/layers/deconv_layer.cpp
CXX src/caffe/layers/euclidean_loss_layer.cpp
CXX src/caffe/layers/conv_layer.cpp
CXX src/caffe/layers/flow_warp_layer.cpp
CXX src/caffe/layers/correlation_layer1d.cpp
CXX src/caffe/layers/accum_layer.cpp
CXX src/caffe/layers/mvn_layer.cpp
CXX src/caffe/layers/multinomial_logistic_loss_layer.cpp
CXX src/caffe/layers/spp_layer.cpp
CXX src/caffe/layers/log_layer.cpp
CXX src/caffe/layers/exp_layer.cpp
CXX src/caffe/layers/image_data_layer.cpp
CXX src/caffe/layers/parameter_layer.cpp
CXX src/caffe/layers/cudnn_lcn_layer.cpp
src/caffe/layers/channel_norm_layer.cpp: In instantiation of ‘void caffe::ChannelNormLayer<Dtype>::Reshape(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]’:
src/caffe/layers/channel_norm_layer.cpp:193:1:   required from here
src/caffe/layers/channel_norm_layer.cpp:34:13: warning: unused variable ‘channels’ [-Wunused-variable]
   const int channels = bottom[0]->channels();
             ^
src/caffe/layers/channel_norm_layer.cpp: In instantiation of ‘void caffe::ChannelNormLayer<Dtype>::Reshape(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]’:
src/caffe/layers/channel_norm_layer.cpp:193:1:   required from here
src/caffe/layers/channel_norm_layer.cpp:34:13: warning: unused variable ‘channels’ [-Wunused-variable]
CXX src/caffe/layers/base_conv_layer.cpp
CXX src/caffe/layers/split_layer.cpp
CXX src/caffe/layers/augmentation_layer_base.cpp
CXX src/caffe/layers/generate_augmentation_parameters_layer.cpp
CXX src/caffe/layers/resample_layer.cpp
CXX src/caffe/layers/memory_data_layer.cpp
CXX src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp
CXX src/caffe/layers/data_augmentation_layer.cpp
CXX src/caffe/layers/reshape_layer.cpp
CXX src/caffe/layers/flowriter_layer.cpp
CXX src/caffe/layers/pfmwriter_layer.cpp
CXX src/caffe/layers/lpq_loss_layer.cpp
CXX src/caffe/layers/floatreader_layer.cpp
CXX src/caffe/layers/lstm_unit_layer.cpp
CXX src/caffe/layers/argmax_layer.cpp
CXX src/caffe/layers/power_layer.cpp
CXX src/caffe/layers/lstm_layer.cpp
CXX src/caffe/layers/accuracy_layer.cpp
CXX src/caffe/layers/scale_layer.cpp
CXX src/caffe/layers/eltwise_layer.cpp
CXX src/caffe/layers/crop_layer.cpp
CXX src/caffe/layers/elu_layer.cpp
CXX src/caffe/layers/bias_layer.cpp
CXX src/caffe/layers/flow_augmentation_layer.cpp
CXX src/caffe/layers/threshold_layer.cpp
CXX src/caffe/layers/relu_layer.cpp
CXX src/caffe/layers/filter_layer.cpp
CXX src/caffe/layers/disparity_data_layer.cpp
CXX src/caffe/layers/softmax_loss_layer.cpp
src/caffe/layers/flow_warp_layer.cpp: In instantiation of ‘void caffe::FlowWarpLayer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]’:
src/caffe/layers/flow_warp_layer.cpp:259:1:   required from here
src/caffe/layers/flow_warp_layer.cpp:130:18: warning: unused variable ‘warped_data’ [-Wunused-variable]
     const Dtype* warped_data = top[0]->cpu_data(); // dest
                  ^
src/caffe/layers/flow_warp_layer.cpp: In instantiation of ‘void caffe::FlowWarpLayer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]’:
src/caffe/layers/flow_warp_layer.cpp:259:1:   required from here
src/caffe/layers/flow_warp_layer.cpp:130:18: warning: unused variable ‘warped_data’ [-Wunused-variable]
CXX src/caffe/layers/hinge_loss_layer.cpp
CXX src/caffe/layers/cudnn_tanh_layer.cpp
CXX src/caffe/layers/rnn_layer.cpp
CXX src/caffe/layers/floatwriter_layer.cpp
CXX src/caffe/layers/infogain_loss_layer.cpp
CXX src/caffe/layers/reduction_layer.cpp
CXX src/caffe/layers/concat_layer.cpp
CXX src/caffe/layers/cudnn_lrn_layer.cpp
CXX src/caffe/layers/correlation_layer.cpp
CXX src/caffe/layers/dropout_layer.cpp
CXX src/caffe/layers/loss_layer.cpp
CXX src/caffe/layers/imgwriter_layer.cpp
CXX src/caffe/layers/embed_layer.cpp
CXX src/caffe/layers/cudnn_softmax_layer.cpp
CXX src/caffe/common.cpp
CXX src/caffe/layer.cpp
CXX src/caffe/syncedmem.cpp
CXX src/caffe/parallel.cpp
CXX src/caffe/layer_factory.cpp
CXX src/caffe/solvers/adagrad_solver.cpp
CXX src/caffe/solvers/adam_solver.cpp
CXX src/caffe/solvers/adadelta_solver.cpp
CXX src/caffe/solvers/rmsprop_solver.cpp
CXX src/caffe/solvers/sgd_solver.cpp
CXX src/caffe/solvers/nesterov_solver.cpp
CXX src/caffe/data_reader.cpp
CXX src/caffe/blob.cpp
CXX src/caffe/internal_thread.cpp
CXX src/caffe/net.cpp
CXX src/caffe/data_transformer.cpp
CXX src/caffe/util/io.cpp
CXX src/caffe/util/rng.cpp
CXX src/caffe/util/upgrade_proto.cpp
CXX src/caffe/util/output.cpp
CXX src/caffe/util/math_functions.cpp
CXX src/caffe/util/benchmark.cpp
CXX src/caffe/util/db_leveldb.cpp
CXX src/caffe/util/hdf5.cpp
CXX src/caffe/util/insert_splits.cpp
CXX src/caffe/util/db.cpp
In file included from src/caffe/util/rng.cpp:1:0:
./include/caffe/util/rng.hpp:20:79: error: ‘RandomGeneratorParameter’ does not name a type
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                               ^
./include/caffe/util/rng.hpp:20:105: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                                                         ^
src/caffe/util/rng.cpp:8:35: error: ‘RandomGeneratorParameter’ does not name a type
 Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff, Dtype prob0_value) {
                                   ^
src/caffe/util/rng.cpp:8:61: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff, Dtype prob0_value) {
                                                             ^
src/caffe/util/rng.cpp: In function ‘Randtype caffe::caffe_rng_generate(const int&, Dtype, Dtype)’:
src/caffe/util/rng.cpp:10:13: error: request for member ‘apply_schedule’ in ‘param’, which is of non-class type ‘const int’
   if (param.apply_schedule())
             ^
src/caffe/util/rng.cpp:11:20: error: request for member ‘spread’ in ‘param’, which is of non-class type ‘const int’
     spread = param.spread() * discount_coeff;
                    ^
src/caffe/util/rng.cpp:13:20: error: request for member ‘spread’ in ‘param’, which is of non-class type ‘const int’
     spread = param.spread();
                    ^
src/caffe/util/rng.cpp:14:40: error: request for member ‘rand_type’ in ‘param’, which is of non-class type ‘const int’
   const std::string rand_type =  param.rand_type();
                                        ^
src/caffe/util/rng.cpp:20:34: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_uniform(1, param.mean() - spread, param.mean() + spread, &tmp);
                                  ^
src/caffe/util/rng.cpp:20:57: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_uniform(1, param.mean() - spread, param.mean() + spread, &tmp);
                                                         ^
src/caffe/util/rng.cpp:22:19: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
       tmp = param.mean();
                   ^
src/caffe/util/rng.cpp:23:15: error: request for member ‘exp’ in ‘param’, which is of non-class type ‘const int’
     if (param.exp())
               ^
src/caffe/util/rng.cpp:30:35: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_gaussian(1, param.mean(), spread, &tmp);
                                   ^
src/caffe/util/rng.cpp:32:19: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
       tmp = param.mean();
                   ^
src/caffe/util/rng.cpp:33:15: error: request for member ‘exp’ in ‘param’, which is of non-class type ‘const int’
     if (param.exp())
               ^
src/caffe/util/rng.cpp:39:15: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
     if (param.prob() > 0.)
               ^
src/caffe/util/rng.cpp:40:36: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_bernoulli(1, param.prob(), &tmp);
                                    ^
src/caffe/util/rng.cpp:53:15: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
     if (param.prob() > 0.)
               ^
src/caffe/util/rng.cpp:54:36: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_bernoulli(1, param.prob(), &tmp2);
                                    ^
src/caffe/util/rng.cpp:65:36: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
         caffe_rng_uniform(1, param.mean() - spread, param.mean() + spread, &tmp1);
                                    ^
src/caffe/util/rng.cpp:65:59: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
         caffe_rng_uniform(1, param.mean() - spread, param.mean() + spread, &tmp1);
                                                           ^
src/caffe/util/rng.cpp:67:22: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
         tmp1 = param.mean();
                      ^
src/caffe/util/rng.cpp:70:15: error: request for member ‘exp’ in ‘param’, which is of non-class type ‘const int’
     if (param.exp())
               ^
src/caffe/util/rng.cpp:83:15: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
     if (param.prob() > 0.)
               ^
src/caffe/util/rng.cpp:84:36: error: request for member ‘prob’ in ‘param’, which is of non-class type ‘const int’
       caffe_rng_bernoulli(1, param.prob(), &tmp2);
                                    ^
src/caffe/util/rng.cpp:95:37: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
         caffe_rng_gaussian(1, param.mean(), spread, &tmp1);
                                     ^
src/caffe/util/rng.cpp:97:22: error: request for member ‘mean’ in ‘param’, which is of non-class type ‘const int’
         tmp1 = param.mean();
                      ^
src/caffe/util/rng.cpp:100:15: error: request for member ‘exp’ in ‘param’, which is of non-class type ‘const int’
     if (param.exp())
               ^
src/caffe/util/rng.cpp:110:12: error: request for member ‘discretize’ in ‘param’, which is of non-class type ‘const int’
   if(param.discretize()) rand = round(rand);
            ^
src/caffe/util/rng.cpp:111:16: error: request for member ‘multiplier’ in ‘param’, which is of non-class type ‘const int’
   rand = param.multiplier() * rand;
                ^
src/caffe/util/rng.cpp: At global scope:
src/caffe/util/rng.cpp:116:54: error: ‘RandomGeneratorParameter’ does not name a type
 template float caffe_rng_generate<float,float>(const RandomGeneratorParameter& param, float discount_coeff, float prob0_value);
                                                      ^
src/caffe/util/rng.cpp:116:80: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template float caffe_rng_generate<float,float>(const RandomGeneratorParameter& param, float discount_coeff, float prob0_value);
                                                                                ^
src/caffe/util/rng.cpp:117:52: error: ‘RandomGeneratorParameter’ does not name a type
 template bool caffe_rng_generate<float,bool>(const RandomGeneratorParameter& param, float discount_coeff, float prob0_value);
                                                    ^
src/caffe/util/rng.cpp:117:78: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template bool caffe_rng_generate<float,bool>(const RandomGeneratorParameter& param, float discount_coeff, float prob0_value);
                                                                              ^
src/caffe/util/rng.cpp:118:55: error: ‘RandomGeneratorParameter’ does not name a type
 template float caffe_rng_generate<double,float>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                       ^
src/caffe/util/rng.cpp:118:81: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template float caffe_rng_generate<double,float>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                                                 ^
src/caffe/util/rng.cpp:119:57: error: ‘RandomGeneratorParameter’ does not name a type
 template double caffe_rng_generate<double,double>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                         ^
src/caffe/util/rng.cpp:119:83: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template double caffe_rng_generate<double,double>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                                                   ^
src/caffe/util/rng.cpp:120:53: error: ‘RandomGeneratorParameter’ does not name a type
 template bool caffe_rng_generate<double,bool>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                     ^
src/caffe/util/rng.cpp:120:79: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template bool caffe_rng_generate<double,bool>(const RandomGeneratorParameter& param, double discount_coeff, double prob0_value);
                                                                               ^
make: *** [.build_release/src/caffe/util/rng.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from src/caffe/common.cpp:8:0:
./include/caffe/util/rng.hpp:20:79: error: ‘RandomGeneratorParameter’ does not name a type
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                               ^
./include/caffe/util/rng.hpp:20:105: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                                                         ^
make: *** [.build_release/src/caffe/common.o] Error 1
In file included from src/caffe/util/math_functions.cpp:8:0:
./include/caffe/util/rng.hpp:20:79: error: ‘RandomGeneratorParameter’ does not name a type
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                               ^
./include/caffe/util/rng.hpp:20:105: error: ISO C++ forbids declaration of ‘param’ with no type [-fpermissive]
 template <typename Dtype,typename Randtype> Randtype caffe_rng_generate(const RandomGeneratorParameter& param, Dtype discount_coeff = 1,Dtype prob0_value = NAN);
                                                                                                         ^
make: *** [.build_release/src/caffe/util/math_functions.o] Error 1

So I add #include "caffe/proto/caffe.pb.h" in the file $CAFFE_ROOT$/include/caffe/util/rng.hpp and the error is fixed.

My environment is Ubuntu 14.04.1LTS with CUDA8.0. GCC version is 4.8.4

nikolausmayer commented 7 years ago

Hi, that's interesting, I do not get this error. Do you compile with USE_CUDNN?

Best, Nikolaus

xmfbit commented 7 years ago

Yes, I compiled with USE_CUDNN=1 and I found that your release did't support CUDNN6.0 which I am using. I have fixed the problem by adding #include "caffe/proto/caffe.pb.h" in file /include/caffe/util/rng.hpp. And I replaced include/caffe/util/cudnn.hpp with the same file in the latest official caffe repo. Another problem, in the file src/cafffe/layers/resample_layer.cu, opencv2/gpu/gpu.hpp is redundant, and it is incompatible with OpenCV 3.X, so I removed it.

wuyuzaizai commented 7 years ago

@xmfbit I did same with you, but new problem occur:

tools/convert_imageset_and_disparity.cpp: In member function ‘void ImagePair::read_data()’: tools/convert_imageset_and_disparity.cpp:156:31: error: ‘numeric_limits’ is not a member of ‘std’ value=std::numeric_limits::max(); ^ tools/convert_imageset_and_disparity.cpp:156:51: error: expected primary-expression before ‘short’ value=std::numeric_limits::max(); ^ In file included from ./include/thirdparty/CImg/CImg.h:208:0, from tools/convert_imageset_and_disparity.cpp:38: tools/convert_imageset_and_disparity.cpp: In function ‘int main(int, char)’: tools/convert_imageset_and_disparity.cpp:328:14: error: expected unqualified-id before ‘int’ leveldb::Status status = leveldb::DB::Open( ^ In file included from tools/convert_imageset_and_disparity.cpp:17:0: tools/convert_imageset_and_disparity.cpp:330:11: error: ‘status’ was not declared in this scope CHECK(status.ok()) << "Failed to open leveldb " << argv[arg_offset+2]; ^ tools/convert_imageset_and_disparity.cpp:330:11: note: suggested alternatives: In file included from /usr/include/boost/filesystem.hpp:17:0, from ./include/caffe/util/io.hpp:4, from tools/convert_imageset_and_disparity.cpp:36: /usr/include/boost/filesystem/operations.hpp:396:15: note: ‘boost::filesystem::status’ file_status status(const path& p, system::error_code& ec) ^ /usr/include/boost/filesystem/operations.hpp:320:17: note: ‘boost::filesystem::detail::status’ file_status status(const path&p, system::error_code ec=0); ^ Makefile:575: recipe for target '.build_release/tools/convert_imageset_and_disparity.o' failed make: [.build_release/tools/convert_imageset_and_disparity.o] Error 1 make: *** Waiting for unfinished jobs....

xmfbit commented 7 years ago

Sorry, but I have no idea about your problem. What's the version of your compiler and platform? You can try to add #include <limits>. @wuyuzaizai You can refer to my modified FlowNet2, which can build successfully in my environment: Ubuntu 16.04, CUDA8.0 with CUDNN6.0

nikolausmayer commented 7 years ago

@xmfbit I'm adding the missing rng.hpp include. Could you explain how the opencv2/gpu/gpu.hpp include is redundant? I did not find any other include for this, and it does not seem to be included by any other opencv2 header.

@wuyuzaizai I think this is not connected to this issue. If the problem persists, please open a separate issue for this.

Nikolaus

xmfbit commented 7 years ago

The implementations has nothing to do with the API declarations in the opencv gpu file. I guess the author added this for debugging, because the last several lines in the file resample layer have been commented. I removed it and built the flownet successfully.

nikolausmayer commented 7 years ago

Ah, now I get it :) I'll remove it then. Thanks!

Nikolaus

plaovem commented 7 years ago

@wuyuzaizai hello, I meet the same problem as you. Have you solved the problem ? Could you tell me, please?