loolzaaa / faster-rcnn-pytorch

A PyTorch implementation of Faster R-CNN
MIT License
17 stars 5 forks source link

ImportError: No module named '_C' #2

Closed ryankimky closed 4 years ago

ryankimky commented 4 years ago

this is my error below,

Traceback (most recent call last): File "run.py", line 8, in from script.train import train File "/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/script/train.py", line 12, in from lib.model.vgg16 import VGG16 File "/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/model/vgg16.py", line 4, in from lib.model.faster_rcnn import FasterRCNN File "/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/model/faster_rcnn.py", line 6, in from lib.model.rpn.rpn import _RPN File "/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/model/rpn/rpn.py", line 5, in from lib.model.rpn.proposal_layer import _ProposalLayer File "/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/model/rpn/proposal_layer.py", line 7, in from _C import nms ImportError: No module named '_C'

ryankimky commented 4 years ago

i followed this compile guide that you mention.

Compile all python extensions (NMS, ROI Pooling) for CPU and CUDA with next commands: cd lib python setup.py develop

loolzaaa commented 4 years ago

If you compile process finished without errors, you must find this module in ./lib folder. Name of the module: _C.........pyd.

Is there it?

loolzaaa commented 4 years ago

For windows, look like this:

image

ryankimky commented 4 years ago

i work on , Linux Ubuntu 16.04. now, i try to install and upgrade python3.5-dev. but ,, still,,, error comes up.

Now, I know that an error occurred during setup. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

It is being solved through stackoverflow. but, i am not sure...

loolzaaa commented 4 years ago

Usually, exact error message you can find above text failed with exit status 1.

ryankimky commented 4 years ago

run.py script working on pytorch 1.3.0?

loolzaaa commented 4 years ago

Should work, but my version is 1.4.0.

You find exact error messages from compiler?

ryankimky commented 4 years ago

still not solve it..

loolzaaa commented 4 years ago

Find in text of console some string where there is a "error" keyword.

loolzaaa commented 4 years ago

Is there something else? Here, there is no errors...

ryankimky commented 4 years ago

this is log, when i run setup.py script Log: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITH_CUDA -I/usr/local/lib/python3.5/dist-packages/torch/include -I/usr/local/lib/python3.5/dist-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.5/dist-packages/torch/include/TH -I/usr/local/lib/python3.5/dist-packages/torch/include/THC -I/usr/local/cuda/include -I/usr/include/python3.5m -c /storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/csrc/cpu/nms.cpp -o build/temp.linux-x86_64-3.5/storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/csrc/cpu/nms.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++

After then: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

loolzaaa commented 4 years ago

May be you need to install additional dependencies like python-dev or something else? Try this at start for python 3.x: $ sudo apt-get install python3-dev

ryankimky commented 4 years ago

can you solve this error below? this is exact error message.

Error /storage/storage/personal/KY/jupyter_lab_2/faster-rcnn-pytorch/lib/csrc/cpu/roi_pool.cpp:49:48: error: ‘FLT_MAX’ was not declared in this scope T maxval = is_empty ? 0 : -FLT_MAX; ^ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

loolzaaa commented 4 years ago

Try to add in lib/csrc/cpu/roi_pool.cpp and lib/csrc/cuda/roi_pool_kernel.cu this:

#include <math.h>
#include <float.h>
ryankimky commented 4 years ago

I'll apply to add right away

include

include

ryankimky commented 4 years ago

setup was successful. 😄 Thank you so much for the quick reply and help.