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

Error when running demo.py: No module named '_ext' #8

Closed
lwoiceshyn opened this issue Sep 15, 2017 · 4 comments
Closed

Error when running demo.py: No module named '_ext' #8

lwoiceshyn opened this issue Sep 15, 2017 · 4 comments

Comments

@lwoiceshyn
Copy link

Can you explain what this import is doing in path_nms.py?
from _ext import nms
It's preventing me from running the demo script. I'm using Python 3.6.

@ruotianluo
Copy link
Owner

Did you follow the fourth step of https://github.com/ruotianluo/pytorch-faster-rcnn#installation ?

@lwoiceshyn
Copy link
Author

Yes, it seems to run fine, here is the output:

Including CUDA code. /home/leow/pytorch-faster-rcnn/lib/nms generating /tmp/tmpyk65xa34/_nms.c running build_ext building '_nms' extension creating home creating home/leow creating home/leow/pytorch-faster-rcnn creating home/leow/pytorch-faster-rcnn/lib creating home/leow/pytorch-faster-rcnn/lib/nms creating home/leow/pytorch-faster-rcnn/lib/nms/src gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/leow/anaconda3/include/python3.6m -c _nms.c -o ./_nms.o gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/leow/anaconda3/include/python3.6m -c /home/leow/pytorch-faster-rcnn/lib/nms/src/nms.c -o ./home/leow/pytorch-faster-rcnn/lib/nms/src/nms.o In file included from /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/TH.h:4:0, from /home/leow/pytorch-faster-rcnn/lib/nms/src/nms.c:1: /home/leow/pytorch-faster-rcnn/lib/nms/src/nms.c: In function ‘cpu_nms’: /home/leow/pytorch-faster-rcnn/lib/nms/src/nms.c:7:42: warning: passing argument 1 of ‘THLongTensor_isContiguous’ from incompatible pointer type [-Wincompatible-pointer-types] THArgCheck(THLongTensor_isContiguous(boxes), 2, "boxes must be contiguous"); ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THGeneral.h:78:35: note: in definition of macro ‘THArgCheck’ _THArgCheck(__FILE__, __LINE__, __VA_ARGS__); \ ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THTensor.h:8:39: note: expected ‘const THLongTensor * {aka const struct THLongTensor *}’ but argument is of type ‘THFloatTensor * {aka struct THFloatTensor *}’ #define THTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME) ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THGeneral.h:116:37: note: in definition of macro ‘TH_CONCAT_4_EXPAND’ #define TH_CONCAT_4_EXPAND(x,y,z,w) x ## y ## z ## w ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THTensor.h:8:27: note: in expansion of macro ‘TH_CONCAT_4’ #define THTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME) ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/generic/THTensor.h:115:12: note: in expansion of macro ‘THTensor_’ TH_API int THTensor_(isContiguous)(const THTensor *self); ^ /home/leow/pytorch-faster-rcnn/lib/nms/src/nms.c:9:42: warning: passing argument 1 of ‘THLongTensor_isContiguous’ from incompatible pointer type [-Wincompatible-pointer-types] THArgCheck(THLongTensor_isContiguous(areas), 4, "areas must be contiguous"); ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THGeneral.h:78:35: note: in definition of macro ‘THArgCheck’ _THArgCheck(__FILE__, __LINE__, __VA_ARGS__); \ ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THTensor.h:8:39: note: expected ‘const THLongTensor * {aka const struct THLongTensor *}’ but argument is of type ‘THFloatTensor * {aka struct THFloatTensor *}’ #define THTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME) ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THGeneral.h:116:37: note: in definition of macro ‘TH_CONCAT_4_EXPAND’ #define TH_CONCAT_4_EXPAND(x,y,z,w) x ## y ## z ## w ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THTensor.h:8:27: note: in expansion of macro ‘TH_CONCAT_4’ #define THTensor_(NAME) TH_CONCAT_4(TH,Real,Tensor_,NAME) ^ /home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/generic/THTensor.h:115:12: note: in expansion of macro ‘THTensor_’ TH_API int THTensor_(isContiguous)(const THTensor *self); ^ gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH -I/home/leow/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -I/home/leow/anaconda3/include/python3.6m -c /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c -o ./home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.o /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c: In function ‘gpu_nms’: /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c:29:35: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] unsigned long long* mask_flat = THCudaLongTensor_data(state, mask); ^ /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c:37:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] unsigned long long * mask_cpu_flat = THLongTensor_data(mask_cpu); ^ /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c:40:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] unsigned long long* remv_cpu_flat = THLongTensor_data(remv_cpu); ^ /home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.c:23:7: warning: unused variable ‘boxes_dim’ [-Wunused-variable] int boxes_dim = THCudaTensor_size(state, boxes, 1); ^ gcc -pthread -shared -L/home/leow/anaconda3/lib -Wl,-rpath=/home/leow/anaconda3/lib,--no-as-needed ./_nms.o ./home/leow/pytorch-faster-rcnn/lib/nms/src/nms.o ./home/leow/pytorch-faster-rcnn/lib/nms/src/nms_cuda.o /home/leow/pytorch-faster-rcnn/lib/nms/src/cuda/nms_kernel.cu.o -L/home/leow/anaconda3/lib -lpython3.6m -o ./_nms.so

@ruotianluo
Copy link
Owner

ruotianluo commented Sep 15, 2017

I guess it's because I'm running under python 2.7.

Try:
from ._ext import nms

build.py gives you _ext folder. So it should be the problem of importing.

@lwoiceshyn
Copy link
Author

lwoiceshyn commented Sep 15, 2017

Yes, the directory imports are different in 3.6. That fix worked for the issue.

Thanks!

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

2 participants