Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling error with CPU ONLY #2

Closed
xiaoweiChen opened this issue Dec 28, 2017 · 2 comments
Closed

Compiling error with CPU ONLY #2

xiaoweiChen opened this issue Dec 28, 2017 · 2 comments

Comments

@xiaoweiChen
Copy link

Hi, I'm feeling your paper is interesting.

First, My environment can compile caffe well.
I try to use your version by CPU ONLY mode by following in Makefile.config

# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1

While, I meet the error as below:

.build_release/lib/libcaffe.so: undefined reference to `caffe::WeightLogQuantReLULayer<float>::Forward_gpu(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `caffe::WeightLogQuantReLULayer<double>::Backward_gpu(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<bool, std::allocator<bool> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `caffe::WeightLogQuantReLULayer<double>::Forward_gpu(std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&, std::vector<caffe::Blob<double>*, std::allocator<caffe::Blob<double>*> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `caffe::WeightLogQuantReLULayer<float>::Backward_gpu(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<bool, std::allocator<bool> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&)'
collect2: error: ld returned 1 exit status
Makefile:625: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1

I compare the WeightLogQuantReLULayer class implement, and lucky find the reason
The src/caffe/layers/weight_log_quant_relu_layer.cpp leak some necessary lines, like below:

#ifdef CPU_ONLY
STUB_GPU(WeightLogQuantReLULayer);
#endif

When I make up this code block into src/caffe/layers/weight_log_quant_relu_layer.cpp, the compiling is well.

Hopefully, you can make up this for this repo.

Whole file like:

#include <algorithm>
#include <vector>

#include "caffe/layers/weight_log_quant_relu_layer.hpp"

namespace caffe {


template <typename Dtype>
void WeightLogQuantReLULayer<Dtype>::LayerSetUp(
    const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
	
	this->blobs_.resize(2);
	this->blobs_[0].reset(new Blob<Dtype>({2}));	// num_level, updated
	this->blobs_[1].reset(new Blob<Dtype>({256}));	// bdr, rep
	
	Dtype* data = this->blobs_[0]->mutable_cpu_data();
	data[0] = 8;	// default num_level
	data[1] = 1;	// uninitialized

	this->hist_.Reshape({1024});
	
	this->param_propagate_down_.push_back(false);
	this->param_propagate_down_.push_back(false);
}

template <typename Dtype>
void WeightLogQuantReLULayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
      const vector<Blob<Dtype>*>& top) {
	NeuronLayer<Dtype>::Reshape(bottom, top);

}

#ifdef CPU_ONLY
STUB_GPU(WeightLogQuantReLULayer);
#endif


INSTANTIATE_CLASS(WeightLogQuantReLULayer);
REGISTER_LAYER_CLASS(WeightLogQuantReLU);


}  // namespace caffe
@EunhyeokPark
Copy link
Owner

Thank you for your debugging, but unfortunately, I didn't implement WQ for CPU.

There is no other special reason but I only ran the experiment in the GPU environment.

When you run my code on CPU, even though it is compiled successfully, assert error will occur.

@xiaoweiChen
Copy link
Author

en... Thanks for your notifying.
I'm watching the WQ implement now, and not running WQ on CPU yet.

If your implement not support ONLY CPU, may notifying for others in ReadMe file.
I think it is a better way. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants