yeezhu / SPN.pytorch

PyTorch implementation of "Soft Proposal Networks for Weakly Supervised Object Localization", ICCV 2017.
http://yzhu.work/spn.html
MIT License
211 stars 37 forks source link

No module named 'spn.spnlib.spn._ext.libspn._libspn' #5

Closed zhangyuygss closed 6 years ago

zhangyuygss commented 6 years ago

I compile the spnlib part and meet this problem when running code: File "/home/zhangyu/codes/weakly_localization/spn/__init__.py", line 1, in <module> from .models import vgg16_sp File "/home/zhangyu/codes/weakly_localization/spn/models.py", line 5, in <module> from spn.spnlib.spn.modules import SoftProposal File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/modules/__init__.py", line 1, in <module> from .SoftProposal import SoftProposal File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/modules/SoftProposal.py", line 5, in <module> from ..functions import sp_generate File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/functions/__init__.py", line 1, in <module> from .SPG import SPGenerate File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/functions/SPG.py", line 5, in <module> from .._ext import libspn File "/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/_ext/libspn/__init__.py", line 3, in <module> from ._libspn import lib as _lib, ffi as _ffi ImportError: No module named 'spn.spnlib.spn._ext.libspn._libspn'

the problem come from this code spnlib/spn/_ext/libspn/init.py:

from torch.utils.ffi import _wrap_function from ._libspn import lib as _lib, ffi as _ffi all = [] def _import_symbols(locals): for symbol in dir(_lib): fn = getattr(_lib, symbol) locals[symbol] = _wrap_function(fn, _ffi) all.append(symbol) _import_symbols(locals())

I checked, there are no file except a init.py in /spnlib/spn/_ext/libspn, so I think it may be something wrong while compliing. Here is my compiling information:

zhangyu@GPUServer2:~/codes/weakly_localization/spn/spnlib$ sudo sh make.sh Compiling cuda kernels... Installing extension... Including CUDA code. running clean Including CUDA code. running install running bdist_egg running egg_info writing requirements to spn.egg-info/requires.txt writing spn.egg-info/PKG-INFO writing top-level names to spn.egg-info/top_level.txt writing dependency_links to spn.egg-info/dependency_links.txt reading manifest file 'spn.egg-info/SOURCES.txt' writing manifest file 'spn.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py creating build/lib.linux-x86_64-2.7 creating build/lib.linux-x86_64-2.7/spn copying spn/init.py -> build/lib.linux-x86_64-2.7/spn creating build/lib.linux-x86_64-2.7/spn/modules copying spn/modules/init.py -> build/lib.linux-x86_64-2.7/spn/modules copying spn/modules/SoftProposal.py -> build/lib.linux-x86_64-2.7/spn/modules creating build/lib.linux-x86_64-2.7/spn/_ext copying spn/_ext/init.py -> build/lib.linux-x86_64-2.7/spn/_ext creating build/lib.linux-x86_64-2.7/spn/functions copying spn/functions/init.py -> build/lib.linux-x86_64-2.7/spn/functions copying spn/functions/SPG.py -> build/lib.linux-x86_64-2.7/spn/functions copying spn/functions/utils.py -> build/lib.linux-x86_64-2.7/spn/functions creating build/lib.linux-x86_64-2.7/spn/_ext/libspn copying spn/_ext/libspn/init.py -> build/lib.linux-x86_64-2.7/spn/_ext/libspn running build_ext generating cffi module 'build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.c' creating build/temp.linux-x86_64-2.7 building 'spn._ext.libspn._libspn' extension creating build/temp.linux-x86_64-2.7/build creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/home creating build/temp.linux-x86_64-2.7/home/zhangyu creating build/temp.linux-x86_64-2.7/home/zhangyu/codes creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn creating build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.o -fopenmp x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.c -o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.o -fopenmp x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/TH -I/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC -I/usr/local/cuda/include -Ispn/src -I/usr/include/python2.7 -c /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c -o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.o -fopenmp In file included from generic/SoftProposalGenerator.cu:1:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:14: spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Float_SP_Generate’: spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable] float sumOver_debug; ^ In file included from generic/SoftProposalGenerator.cu:1:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17: spn/src/generic/SoftProposalGenerator.cu: In function ‘cuspn_Double_SP_Generate’: spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 6 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default] 1); ^ In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1: /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float ’ but argument is of type ‘double ’ THC_API void THCudaBlas_Sgemv(THCState state, char trans, long m, long n, float alpha, float a, long lda, float x, long incx, float beta, float y, long incy); ^ In file included from generic/SoftProposalGenerator.cu:1:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17: spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 8 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default] 1); ^ In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1: /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float ’ but argument is of type ‘double ’ THC_API void THCudaBlas_Sgemv(THCState state, char trans, long m, long n, float alpha, float a, long lda, float x, long incx, float beta, float y, long incy); ^ In file included from generic/SoftProposalGenerator.cu:1:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17: spn/src/generic/SoftProposalGenerator.cu:113:17: warning: passing argument 11 of ‘THCudaBlas_Sgemv’ from incompatible pointer type [enabled by default] 1); ^ In file included from /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THC.h:6:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:1: /usr/local/lib/python2.7/dist-packages/torch/utils/ffi/../../lib/include/THC/THCBlas.h:15:14: note: expected ‘float ’ but argument is of type ‘double ’ THC_API void THCudaBlas_Sgemv(THCState state, char trans, long m, long n, float alpha, float a, long lda, float x, long incx, float beta, float y, long incy); ^ In file included from generic/SoftProposalGenerator.cu:1:0, from /home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.c:17: spn/src/generic/SoftProposalGenerator.cu:67:11: warning: unused variable ‘sumOver_debug’ [-Wunused-variable] float sumOver_debug; ^ x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/spn._ext.libspn._libspn.o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn.o build/temp.linux-x86_64-2.7/home/zhangyu/codes/weakly_localization/spn/spnlib/spn/src/libspn_cuda.o spn/src/libspn_kernel.cu.o -o build/lib.linux-x86_64-2.7/spn/_ext/libspn/_libspn.so creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/spn copying build/lib.linux-x86_64-2.7/spn/init.py -> build/bdist.linux-x86_64/egg/spn creating build/bdist.linux-x86_64/egg/spn/modules copying build/lib.linux-x86_64-2.7/spn/modules/init.py -> build/bdist.linux-x86_64/egg/spn/modules copying build/lib.linux-x86_64-2.7/spn/modules/SoftProposal.py -> build/bdist.linux-x86_64/egg/spn/modules creating build/bdist.linux-x86_64/egg/spn/_ext copying build/lib.linux-x86_64-2.7/spn/_ext/init.py -> build/bdist.linux-x86_64/egg/spn/_ext creating build/bdist.linux-x86_64/egg/spn/_ext/libspn copying build/lib.linux-x86_64-2.7/spn/_ext/libspn/init.py -> build/bdist.linux-x86_64/egg/spn/_ext/libspn copying build/lib.linux-x86_64-2.7/spn/_ext/libspn/_libspn.so -> build/bdist.linux-x86_64/egg/spn/_ext/libspn creating build/bdist.linux-x86_64/egg/spn/functions copying build/lib.linux-x86_64-2.7/spn/functions/init.py -> build/bdist.linux-x86_64/egg/spn/functions copying build/lib.linux-x86_64-2.7/spn/functions/SPG.py -> build/bdist.linux-x86_64/egg/spn/functions copying build/lib.linux-x86_64-2.7/spn/functions/utils.py -> build/bdist.linux-x86_64/egg/spn/functions byte-compiling build/bdist.linux-x86_64/egg/spn/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/modules/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/modules/SoftProposal.py to SoftProposal.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/libspn/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/functions/init.py to init.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/functions/SPG.py to SPG.pyc byte-compiling build/bdist.linux-x86_64/egg/spn/functions/utils.py to utils.pyc creating stub loader for spn/_ext/libspn/_libspn.so byte-compiling build/bdist.linux-x86_64/egg/spn/_ext/libspn/_libspn.py to _libspn.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying spn.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying spn.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying spn.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying spn.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying spn.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... creating 'dist/spn-1.0-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing spn-1.0-py2.7-linux-x86_64.egg Removing /usr/local/lib/python2.7/dist-packages/spn-1.0-py2.7-linux-x86_64.egg Copying spn-1.0-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages spn 1.0 is already the active version in easy-install.pth Installed /usr/local/lib/python2.7/dist-packages/spn-1.0-py2.7-linux-x86_64.egg Processing dependencies for spn==1.0 Searching for cffi==1.11.2 Best match: cffi 1.11.2 Processing cffi-1.11.2-py2.7-linux-x86_64.egg cffi 1.11.2 is already the active version in easy-install.pth Using /home/zhangyu/codes/paperCode/SPN.pytorch-master/spnlib/.eggs/cffi-1.11.2-py2.7-linux-x86_64.egg Searching for pycparser==2.18 Best match: pycparser 2.18 Processing pycparser-2.18-py2.7.egg pycparser 2.18 is already the active version in easy-install.pth Using /home/zhangyu/codes/paperCode/SPN.pytorch-master/spnlib/.eggs/pycparser-2.18-py2.7.egg Finished processing dependencies for spn==1.0

How can I solve this and make the codes run?

yeezhu commented 6 years ago

@zhangyuygss Please try to install spnlib based on Python 3.5.