Detectron: CPU and pure Caffe2 / C++ inference support including mobile devices (was "the model can be use for mobile phone like as Android?")

Created on 24 Jan 2018  ·  16Comments  ·  Source: facebookresearch/Detectron

the model can be use for mobile phone like as Android

planned feature

Most helpful comment

We plan to provide a conversion tool and instructions for how to run Detectron models on mobile phones in the future.

All 16 comments

We plan to provide a conversion tool and instructions for how to run Detectron models on mobile phones in the future.

Attempting to build for CPU-only inference, caffe2 successfully installed. Running test_spatial_narrow_as_op.py fails due to a missing GPU library.

$ python ../tests/test_spatial_narrow_as_op.py
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
Traceback (most recent call last):
File "../tests/test_spatial_narrow_as_op.py", line 88, in
utils.c2.import_detectron_ops()
File "/home/user/Detectron/lib/utils/c2.py", line 41, in import_detectron_ops
detectron_ops_lib = envu.get_detectron_ops_lib()
File "/home/user/Detectron/lib/utils/env.py", line 73, in get_detectron_ops_lib
'version includes Detectron module').format(detectron_ops_lib)
AssertionError: Detectron ops lib not found at '/home/user/caffe2/build/lib/libcaffe2_detectron_ops_gpu.so'; make sure that your Caffe2 version includes Detectron module

@rbgirshick, Can we make inferences without GPUs? Getting the same error as @ss32

Attempting to build for CPU-only inference, caffe2 successfully installed. Running test_spatial_narrow_as_op.py fails due to a missing GPU library.

$ python ../tests/test_spatial_narrow_as_op.py
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
Traceback (most recent call last):
File "../tests/test_spatial_narrow_as_op.py", line 88, in
utils.c2.import_detectron_ops()
File "/home/user/Detectron/lib/utils/c2.py", line 41, in import_detectron_ops
detectron_ops_lib = envu.get_detectron_ops_lib()
File "/home/user/Detectron/lib/utils/env.py", line 73, in get_detectron_ops_lib
'version includes Detectron module').format(detectron_ops_lib)
AssertionError: Detectron ops lib not found at '/home/user/caffe2/build/lib/libcaffe2_detectron_ops_gpu.so'; make sure that your Caffe2 version includes Detectron module

I'm having the same problem here. Using pre-built binaries on Mac.

Facing the same issue. Have attempted to build caffe2 from source as well as by using the pre-built binaries on macOS.

I have the same issue ( see the error log).

My goal: have a test running on MacOs with CPU only.

Step: 1) install all other dependencies with cond ;
2) install caffe2 with conda.
3) install detectron with system pip(python), then put the lib directory to the PYTHONPATH variable.

Then I have the same issue above:

WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
E0204 13:06:36.049393 2041434112 init_intrinsics_check.cc:54] CPU feature avx is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU.
E0204 13:06:36.049954 2041434112 init_intrinsics_check.cc:54] CPU feature avx2 is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU.
E0204 13:06:36.049964 2041434112 init_intrinsics_check.cc:54] CPU feature fma is present on your machine, but the Caffe2 binary is not compiled with it. It means you may not get the full speed of your CPU.
Traceback (most recent call last):
File "/tmp/test_spatial_narrow_as_op.py", line 88, in
utils.c2.import_detectron_ops()
File "/Users/wangy/python/detectron/lib/utils/c2.py", line 41, in import_detectron_ops
detectron_ops_lib = envu.get_detectron_ops_lib()
File "/Users/wangy/python/detectron/lib/utils/env.py", line 73, in get_detectron_ops_lib
'version includes Detectron module').format(detectron_ops_lib)
AssertionError: Detectron ops lib not found at '/Users/wangy/miniconda2/lib/python2.7/site-packages/lib/libcaffe2_detectron_ops_gpu.so'; make sure that your Caffe2 version includes Detectron module

@CancerGenome That's likely unrelated to GPU-only issue. You have to install the Caffe2 version with detectron as a module (as said in the INSTALL.md instructions). It can be found here

@ss32 i solve this problem。Due to my computer have been installed caffe1 and caffe2,then I comment the caffe1 's environment variable which is PYTHONPATH variable. and add caffe2's environment variable.finally ,i success。just do :
gedit ~/.bashrc
comment this:

export PYTHONPATH=/pathto/caffe/python:$PYTHONPATH

add this:
export PYTHONPATH=/path/to/caffe2/build:$PYTHONPATH

hope help you ! luckly~

HI @rbgirshick about three weeks ago, I spent a Sunday afternoon installing caffe2 from source on a dev box with a 4Gb CUDA enabled GPU on Ubuntu 16.04 with a hope to be able to do feedforward on some larger images say 1920x1080 on the CPU to see the quality of the masking. But I found that I was bound to the GPU only library:

lib/python2.7/site-packages/lib/libcaffe2_detectron_ops_gpu.so

So I am currently left with the choice of using AWS cloud compute to do the masking or buy newer CUDA enabled hardware.

Do you have a timeline to speak of about when the CPU only implementation would be done?

Installed caffe2 and Detectron on my RaspberryPi. Having the same issue.

WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
WARNING:root:Debug message: No module named caffe2_pybind11_state_gpu
INFO:caffe2.python.net_drawer:Cannot import pydot, which is required for drawing a network. This can usually be installed in python with "pip install pydot". Also, pydot requires graphviz to convert dot files to pdf: in ubuntu, this can usually be installed with "sudo apt-get install graphviz".
net_drawer will not run correctly. Please install the correct dependencies.
Traceback (most recent call last):
File "test_spatial_narrow_as_op.py", line 88, in
utils.c2.import_detectron_ops()
File "/home/pi/detectron/lib/utils/c2.py", line 41, in import_detectron_ops
detectron_ops_lib = envu.get_detectron_ops_lib()
File "/home/pi/detectron/lib/utils/env.py", line 73, in get_detectron_ops_lib
'version includes Detectron module').format(detectron_ops_lib)
AssertionError: Detectron ops lib not found at '/home/pi/caffe2/build/lib/libcaffe2_detectron_ops_gpu.so'; make sure that your Caffe2 version includes Detectron module

The same question, is the CPU-only inference possible? I want to test Detectron but can't do it - my host OS is Windows(Detectron doesn't support it, as far as I understand) and in VMs I can't use GPU.
It says:

AssertionError: Detectron ops lib not found; make sure that your Caffe2 version includes Detectron module

@all Please see the note in caffe2/modules/detectron/CMakeLists.txt

# Note(ilijar): Since Detectron ops currently have no
# CPU implementation, we only build GPU ops for now.

The detectron module in caffe2 is available in GPU mode only!

Just went through the INSTALL.md again and the notes section of requirements clearly says "Detectron currently does not have CPU Implementations"

I think #372 & #449 finish to solve the CPU part of the problem.
So if you want this to be included I think helping the maintainers review these two PR (and also upvote them) could ease the process.

If you are interested in CPU support you can help us to bring it by upvoting and even reviewing these two issues : #372 & #449.

Ps: this could also help for pure Caffe2/PyTorch inference but in a more remote future

@rbgirshick @gadcam As of now, is it not possible to run Detectron on Android?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaopeng-eugene picture gaopeng-eugene  ·  4Comments

Hwang-dae-won picture Hwang-dae-won  ·  3Comments

realwecan picture realwecan  ·  3Comments

olgaliak picture olgaliak  ·  4Comments

twmht picture twmht  ·  3Comments