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

Set CPU-only mode #31

Closed
ardeal opened this issue Mar 11, 2019 · 9 comments
Closed

Set CPU-only mode #31

ardeal opened this issue Mar 11, 2019 · 9 comments

Comments

@ardeal
Copy link

ardeal commented Mar 11, 2019

Hi,

I tried to run the demo.py file in python, but I got the following error:

F0311 15:58:18.148229  6000 common.cpp:76] Cannot use GPU in CPU-only Caffe: check mode.

however, I have modified the mode to CPU-only mode. Should I modified some other code to disable GPU mode but enable CPU-only mode?

By the way, the faceboxes model was downloaded from the page you publicized your source code:
https://github.com/sfzhang15/FaceBoxes

os.chdir(caffe_root)
sys.path.insert(0, 'python')
import caffe

caffe.set_device(0)
# caffe.set_mode_gpu()
caffe.set_mode_cpu()

model_def = 'D:/code_cv/face_detection/FaceBoxes/models/faceboxes/deploy.prototxt'
model_weights = 'D:/code_cv/face_detection/FaceBoxes/models/faceboxes/faceboxes.caffemodel'
net = caffe.Net(model_def, model_weights, caffe.TEST)

image = caffe.io.load_image('examples/images/1.jpg')

Thanks and Best Regards,
Ardeal

@sfzhang15
Copy link
Owner

@ardeal
Try to comment out 'caffe.set_device(0)' ?

@ardeal
Copy link
Author

ardeal commented Mar 12, 2019

Hi Dr. Zhang,

Thank you for your help!

I did the following experiments:


Experiment 1:
Set CPU-only = 0 and re-build caffe. If my understanding is correct, CPU and GPU are both supported by the newly built Caffe.
in demo.py file:

caffe.set_device(0)
caffe.set_mode_gpu()
#caffe.set_mode_cpu()

re-run demo.py, and I encountered the following error:

I0312 09:00:16.459015  9840 layer_factory.hpp:77] Creating layer input
F0312 09:00:16.459015  9840 layer_factory.hpp:81] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Input (known types: MemoryData)
*** Check failure stack trace: ***

when the code went to:

net = caffe.Net(model_def, model_weights, caffe.TEST)

Experiment 2:
using the CPU and GPU version of Caffe and the following configuration:

#caffe.set_device(0)
#caffe.set_mode_gpu()
caffe.set_mode_cpu()

I encountered the same error.


Experiment 3:
using the CPU and GPU version of Caffe and the following configuration:

caffe.set_device(0)
# caffe.set_mode_gpu()
caffe.set_mode_cpu()

I encountered the same error.


In addition, the faceboxes.caffemodel file was download from the link in your code page:
https://github.com/sfzhang15/FaceBoxes

the newwork file I was using:
faceboxes/deploy.prototxt'

Is the model for CPU or GPU?

Do you have any idea about my issue?

Thanks and Best Regards,
Ardeal

@sfzhang15
Copy link
Owner

@ardeal
It seems the type of input layer is not registered. Your input type is "data"?

@ardeal
Copy link
Author

ardeal commented Mar 12, 2019

The first a few lines in your deploy.prototxt file are:
name: "deploy"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 640
dim: 480
}

is the input type "data"?

I just want to run your trained model to check the performance of you faceboxes algorithms.
Did I choose the correct input file?
otherwise, what input file should be chosen?

@ardeal
Copy link
Author

ardeal commented Mar 12, 2019

Hi Dr. Zhang,

Thanks for your help!
I am now able to run faceboxes code on VS2015, and the output of algorithms seems to be correct.

I need to add the following code in python/caffe/_caffe.cpp file to fixed above issues:

#include "caffe/layers/input_layer.hpp"
#include "caffe/layers/conv_layer.hpp"
#include "caffe/layers/cudnn_conv_layer.hpp"
#include "caffe/layers/relu_layer.hpp"
#include "caffe/layers/pooling_layer.hpp"
#include "caffe/layers/softmax_layer.hpp"



namespace caffe
{
	extern INSTANTIATE_CLASS(ConvolutionLayer);
	REGISTER_LAYER_CLASS(Convolution);

	extern INSTANTIATE_CLASS(ReLULayer);
	REGISTER_LAYER_CLASS(ReLU);
	
	extern INSTANTIATE_CLASS(PoolingLayer);
	REGISTER_LAYER_CLASS(Pooling);

	extern INSTANTIATE_CLASS(SoftmaxLayer);
	REGISTER_LAYER_CLASS(Softmax);
	
}

But there is something weird. The following is the figure plotted when I run demo.py:

image

A few faces were missed by the algorithms. Is it the same performance as yours?

Thanks and Best Regards,
Ardeal

@sfzhang15
Copy link
Owner

@ardeal
Yes. There are some faces with low scores, maybe becasue they have small scales. You can low the threshold from 0.5 to 0.25 to show all faces, or you can enlarge the image.

@ardeal
Copy link
Author

ardeal commented Mar 13, 2019

I got it!
Many thanks for your help, Dr. Zhang!

@ahlemlouma
Copy link

i have the same problem can someone help me plz
F0929 20:55:49.671247 6050 base_data_layer.cpp:84] Cannot use GPU in CPU-only Caffe: check mode.
*** Check failure stack trace: ***
Aborted (core dumped)

@yezhengli-Mr9
Copy link

yezhengli-Mr9 commented Jan 6, 2021

i have the same problem can someone help me plz
F0929 20:55:49.671247 6050 base_data_layer.cpp:84] Cannot use GPU in CPU-only Caffe: check mode.
*** Check failure stack trace: ***
Aborted (core dumped)

Any tutorial to switch to CPU-only caffe?caffe.set_mode_cpu() seems not enough. I am studying another problem anyway.

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

4 participants