-
Notifications
You must be signed in to change notification settings - Fork 6.8k
The conflict between MXNet and OpenCV #8569
Comments
I've seen the same issue when building with cuda9 + cudnn7 with gperftools option on. |
I think the reason is that There are some shared pointers between MXNet and OpenCV, but it's not available to free the memories different allocators(gperftools, jemallo, glibc) allocated. |
Out of curiosity, does the crash occur if you import cv2 after mxnet? |
@KellenSunderland The crash will occur too if importing cv2 after mxnet with |
@wkcn Thanks, for the info. I think your description on the relation between the USE_GPERFTOOLS flag and the crash is clear. I just saw some other similar reports that were dependent on the order you initialize opencv in relation to the gperf using library (i.e. mxnet in this case). |
@KellenSunderland Thank you! |
Hi there, I can confirm setting USE_GPERFTOOLS=0 fixes the issue (it was double free for me). I kept USE_JEMALLOC=1 and both modules loads together in any order. Adam. |
Maybe this should be reopened? Possible solutions can be:
as already suggested by @wkcn. |
You can use LD_PRELOAD to workaround this in the meantime. |
@tequilaguru Thank you! I will try it next time. |
I hava met tha same problem, that I build mxnet-1.2.1 with cuda-9.1,cudnn7.1 with USE_GPERFOOLS =1 . When I put the libmxnet.so in another machine to run inference, it asks me the lack of libtcmalloc.so.4, then I install the gperftools by yum, the problem occur when I import mxnet in python |
It should work with LD_PRELOAD, either with tcmalloc or jemalloc |
Hi, there.
I found the reason of the conflict between MXNet and OpenCV.
Environment info
Operation System: Arch Linux 4.13.6
MXNet: 3f37577 (Date: Tue Nov 7 02:13:07 2017 +0800)
OpenCV: 3.3.1
Python: 2.7.14/3.6.3
GCC: 6.3.1 20170109
Build config:
make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas
Steps to reproduce
make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas
make/config.mk
is default.The building was successful.
cd python sudo python setup.py install
It showed the error that:
*** Error in python': free(): invalid pointer:0x000055ec46fe1520 ***
What I have tried to solve it
I deleted all
"import cv2"
in$(MXNET_PATH)/python/mxnet/{recordio.py, image/{detection.py, image.py}}
Then I made two tests in the folder
$(MXNET_PATH)/python/
.src/tcmalloc.cc
is the code of gperftools.So I think there is a conflict between
gperftools
andopencv2
.I set
USE_GPERFTOOLS = 0
andUSE_JEMALLOC = 0
in$(MXNET_PATH)/make/config.mk
, and rebuild MXNet.The problem is solved.
I think the reason is that
gperftools
orjemalloc
replaces the memory allocator includingmalloc
, howeverpython-opencv
uses the default allocator.There are some shared pointers between MXNet and OpenCV, but it's not available to free the memories different allocators(gperftools, jemallo, glibc) allocated.
Solutions
There are two solutions to use
MXNet
andOpenCV
simultaneously.python-opencv
withthe builtin memory allocator
, and setUSE_GPERFTOOLS = 0
andUSE_JEMALLOC = 0
in$(MXNET_PATH)/make/config.mk
. Rebuild MXNet or use pip to install MXNet.python-opencv
withthe responding memory allocator with MXNet
, such aspython-opencv
withgperftools memory allocator
andMXNet
withgperftools memory allocator
.The text was updated successfully, but these errors were encountered: