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

How to setup with CPU ONLY mode #123

Closed
eakbas opened this issue Mar 22, 2016 · 26 comments
Closed

How to setup with CPU ONLY mode #123

eakbas opened this issue Mar 22, 2016 · 26 comments

Comments

@eakbas
Copy link

eakbas commented Mar 22, 2016

I'd like to install py-faster-rcnn in CPU ONLY mode. Is this possible? Which configuration files should I modify?

Thanks.

@happyharrycn
Copy link

It is definitely possible but not recommended. CPU version is almost two magnitude slower than GPU as I tested a few months ago. Here is a quick list of modifications.

  • Set USE_GPU_NMS in ./lib/fast_rcnn/config.py (or your YAML file) to False.
  • In ./tools/test_net.py / train_net.py, replace caffe.set_mode_gpu() with caffe_set_mode_cpu().
  • Plus, if you do not have a GPU, you can compile Caffe in CPU_ONLY mode (and also ignore the GPU nms code).

@eakbas
Copy link
Author

eakbas commented Mar 23, 2016

I made the changes you mentioned. When I try to build the cython modules, i.e. after running

cd $FRCN_ROOT/lib; make

I get:

python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 58, in
CUDA = locate_cuda()
File "setup.py", line 46, in locate_cuda
raise EnvironmentError('The nvcc binary could not be '
EnvironmentError: The nvcc binary could not be located in your $PATH. Either add it to your path, or set $CUDAHOME
make: *** [all] Error 1

@happyharrycn
Copy link

As I said, you will need to ignore GPU nms code. You can do so by removing 'nms.gpu_nms' module in ./libs/setup.py.

@dumka
Copy link

dumka commented Apr 5, 2016

@eakbas, I did everything as @happyharrycn recommended, including his last recommendation, but, anyway, I got the same error message as you did. But after that I removed line "CUDA = locate_cuda()" in ./lib/setup.py, after that I executed "cd $FRCN_ROOT/lib; make" and it went without error messages.

@eakbas eakbas closed this as completed Apr 8, 2016
@Mengmengbai
Copy link

cd $FRCN_ROOT/lib, modify setup.py,annotate these code that are correlative GPU, then make

...
#CUDA = locate_cuda()
...
...
#self.set_executable('compiler_so', CUDA['nvcc'])
...
...
#Extension('nms.gpu_nms',

['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],

library_dirs=[CUDA['lib64']],

libraries=['cudart'],

language='c++',

runtime_library_dirs=[CUDA['lib64']],

# this syntax is specific to this build system

# we're only going to use certain compiler args with nvcc and not with

# gcc the implementation of this trick is in customize_compiler() below

extra_compile_args={'gcc': ["-Wno-unused-function"],

'nvcc': ['-arch=sm_35',

'--ptxas-options=-v',

'-c',

'--compiler-options',

"'-fPIC'"]},

include_dirs = [numpy_include, CUDA['include']]

)

@shubh-agrawal
Copy link

shubh-agrawal commented Aug 25, 2016

@happyharrycn @eakbas @SrCMpink @dumka
I am trying to implement CPU_ONLY mode. I have followed this complete issue and made a clean make for ./lib. It gave no error. But upon running the demo from ./tools/demo.py it gave error as:

F0825 21:46:15.782125 7066 common.cpp:55] Cannot use GPU in CPU-only Caffe: check mode.

All modifications are made by me given in the post. Please suggest some solution.

@mcdickenson
Copy link

@shubh-agrawal Are you running demo.py with the --cpu option specified?

@shubh-agrawal
Copy link

shubh-agrawal commented Aug 26, 2016

No I haven't. I tried it out but came up with this error now,

[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 350:21: Message type "caffe.LayerParameter" has no field named "roi_pooling_param".
WARNING: Logging before InitGoogleLogging() is written to STDERR
F0826 11:47:10.569231 2981 upgrade_proto.cpp:928] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/shubh/py-faster-rcnn/models/pascal_voc/VGG16/faster_rcnn_alt_opt/faster_rcnn_test.pt
*** Check failure stack trace: ***
Aborted (core dumped)

Any idea about this?

@sandeeppalakkal
Copy link

Can you try for --net zf and update the results?

@mcdickenson
Copy link

@shubh-agrawal That looks to me like the caffe-fast-rcnn submodule is on the wrong branch. If you cd into that directory and run git checkout faster-rcnn and then rerun the demo (with the ZF net as @sandeeppalakkal suggests) what happens?

@shubh-agrawal
Copy link

You guys solved the problem. Thank you guys. The demo worked seamlessly. @mcdickenson @sandeeppalakkal

But I would update one more modification, here, so that other fellows following similar problem could follow up. There is nms_wrapper.py which still uses nms_gpu module. Hence, it was necessary to comment out piece of code related to that in $FRCN_ROOT/lib/fast_rcnn/nms_wrapper.py.
Uncomment the import module for nms_gpu. Rest making modification as discusses in this issue will solve the problem.

I wonder, why not any documentation with much needed modification for ONLY_CPU is found over the air.

@divamgupta
Copy link

@mcdickenson I all the things mentioned above but I got the floowing error

[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 47:11: Message type "caffe.LRNParameter" has no field named "engine".

How should I go about this?

@mcdickenson
Copy link

@divamgupta I'm not sure, I haven't encountered that before. It might be worth opening a separate issue for that. Are you building from master?

@shubh-agrawal
Copy link

@divamgupta I had encountered this error before. It occurs if you are on master branch of caffe-fast-rcnn. Please checkout to other branch that will be enlisted in git branch.
I hope this helps !

@divamgupta
Copy link

I used the faster-rcnn branch. This problem is only arising in the zf model only. vgg16 is working fine.

@brisker
Copy link

brisker commented Oct 2, 2016

@divamgupta
Have you solved this problem?
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 47:11: Message type "caffe.LRNParameter" has no field named "engine".

@mcdickenson
Copy link

mcdickenson commented Feb 22, 2017 via email

@Anhaoxu
Copy link

Anhaoxu commented Mar 5, 2017

@GongXinyuu
Copy link

GongXinyuu commented Mar 22, 2017

Hey guys, I found this solution works.
Comment these code in lib/setup.py
#CUDA = locate_cuda()

#self.set_executable('compiler_so', CUDA['nvcc'])

`
#Extension('nms.gpu_nms',

#['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],

#library_dirs=[CUDA['lib64']],

#libraries=['cudart'],

#language='c++',

#runtime_library_dirs=[CUDA['lib64']],

#this syntax is specific to this build system

#we're only going to use certain compiler args with nvcc and not with

#gcc the implementation of this trick is in customize_compiler() below

#extra_compile_args={'gcc': ["-Wno-unused-function"],

#'nvcc': ['-arch=sm_35',

#'--ptxas-options=-v',

#'-c',

#'--compiler-options',

#"'-fPIC'"]},

#include_dirs = [numpy_include, CUDA['include']]

#),

`

And then
make

@Anhaoxu
Copy link

Anhaoxu commented Mar 22, 2017

@GloryDream
Did you find there are lots of repetitive bbox in the result pictures displayed in demo.py?
I just make it in windows10 and use CPU mode,too.

@GongXinyuu
Copy link

@Anhaoxu
Sorry, I didn't run it successfully on my mac.

@danielaRiesgo
Copy link

danielaRiesgo commented Sep 26, 2017

@divamgupta could you solve it? I get a segmentation fault even when I don't specify --net zf.

NaxAlpha pushed a commit to NaxAlpha/py-faster-rcnn that referenced this issue Nov 7, 2017
@PapaMadeleine2022
Copy link

PapaMadeleine2022 commented Nov 22, 2017

for test, you just need too run './tools/demo.py --cpu'.
for end2end train, as there is only Forward_gpu implementation in smooth_L1_loss_layer.cu for SmoothL1LossLayer, so it seems that you only can use GPU mode.

@Mypathissional
Copy link

How many seconds on average needed for CPU-run only on a single image,say of size (224,224) ?

@LP308210365
Copy link

C:\Users\lenovo\Anaconda3\python.exe D:/tf-faster-rcnn-master/lib/setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied

I modified setup.py file ,but reported a new error

@muhammad-hassan-shakeel
Copy link

after above changes I'm getting this:

python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 12, in
from Cython.Distutils import build_ext
ImportError: No module named Cython.Distutils
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

When I executed pip install Cython it says:
Requirement already satisfied: cython in /usr/lib/python3/dist-packages (0.26.1)

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