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 · 25 comments

Comments

Projects
None yet
@eakbas
Copy link

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

This comment has been minimized.

Copy link

commented Mar 22, 2016

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented Mar 23, 2016

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

This comment has been minimized.

Copy link

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 Apr 8, 2016

@SrCMpink

This comment has been minimized.

Copy link

commented Jun 14, 2016

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Aug 25, 2016

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

@shubh-agrawal

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Aug 26, 2016

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

@mcdickenson

This comment has been minimized.

Copy link

commented Aug 26, 2016

@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

This comment has been minimized.

Copy link

commented Aug 26, 2016

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

This comment has been minimized.

Copy link

commented Sep 27, 2016

@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

This comment has been minimized.

Copy link

commented Sep 27, 2016

@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

This comment has been minimized.

Copy link

commented Sep 27, 2016

@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

This comment has been minimized.

Copy link

commented Sep 28, 2016

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

@brisker

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Feb 22, 2017

@Anhaoxu

This comment has been minimized.

@GongXinyuu

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 26, 2017

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

@KojiShiono KojiShiono referenced this issue Jun 20, 2017

Open

CPU Mode? #81

@danielaRiesgo

This comment has been minimized.

Copy link

commented Sep 26, 2017

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

NaxAlpha added a commit to NaxAlpha/py-faster-rcnn that referenced this issue Nov 7, 2017

@IvyGongoogle

This comment has been minimized.

Copy link

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.

@ghost ghost referenced this issue Jan 25, 2018

Closed

CPU only? #39

@Mypathissional

This comment has been minimized.

Copy link

commented Aug 20, 2018

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

@LP308210365

This comment has been minimized.

Copy link

commented Apr 19, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.