运行
$ python -c "import torch; import cv2"
完美无缺。但是,运行
$ python -c "import cv2; import torch"
结果
*** Error in `python': free(): invalid pointer: 0x00007f327bb85b80 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f32964057e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f329640e37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f329641253c]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt6locale5_Impl16_M_install_facetEPKNS_2idEPKNS_5facetE+0x142)[0x7f327b91f802]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt6locale5_ImplC2Em+0x1e3)[0x7f327b921953]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt6locale18_S_initialize_onceEv+0x15)[0x7f327b9228c5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xea99)[0x7f3296766a99]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt6locale13_S_initializeEv+0x21)[0x7f327b922911]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt6localeC1Ev+0x13)[0x7f327b922953]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libshm.so(_ZNSt8ios_base4InitC1Ev+0xb4)[0x7f327b8f41b4]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61(+0x2f85b4)[0x7f324bfe45b4]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61(+0x2f8703)[0x7f324bfe4703]
/home/grzegorz/.venv/local/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61(+0x393cc6)[0x7f324c07fcc6]
======= Memory map: ========
00400000-006ea000 r-xp 00000000 fc:01 4463490 /home/grzegorz/.venv/bin/python
008e9000-008eb000 r--p 002e9000 fc:01 4463490 /home/grzegorz/.venv/bin/python
008eb000-00962000 rw-p 002eb000 fc:01 4463490 /home/grzegorz/.venv/bin/python
00962000-00985000 rw-p 00000000 00:00 0
01fcf000-02560000 rw-p 00000000 00:00 0 [heap]
7f3244000000-7f3244021000 rw-p 00000000 00:00 0
7f3244021000-7f3248000000 ---p 00000000 00:00 0
7f324bcec000-7f324e5dd000 r-xp 00000000 fc:01 9708013 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61
7f324e5dd000-7f324e7dd000 ---p 028f1000 fc:01 9708013 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61
7f324e7dd000-7f324e7f6000 rw-p 028f1000 fc:01 9708013 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61
7f324e7f6000-7f324e807000 rw-p 00000000 00:00 0
7f324e807000-7f324e80c000 rw-p 0290b000 fc:01 9708013 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcusparse-94011b8d.so.8.0.61
7f324e80c000-7f3250ca7000 r-xp 00000000 fc:01 9708004 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcurand-3d68c345.so.8.0.61
7f3250ca7000-7f3250ea7000 ---p 0249b000 fc:01 9708004 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcurand-3d68c345.so.8.0.61
7f3250ea7000-7f3252278000 rw-p 0249b000 fc:01 9708004 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcurand-3d68c345.so.8.0.61
7f3252278000-7f3252782000 rw-p 00000000 00:00 0
7f3252782000-7f3252783000 rw-p 0386d000 fc:01 9708004 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcurand-3d68c345.so.8.0.61
7f3252783000-7f325559b000 r-xp 00000000 fc:01 9708000 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcublas-e78c880d.so.8.0.88
7f325559b000-7f325579b000 ---p 02e18000 fc:01 9708000 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcublas-e78c880d.so.8.0.88
7f325579b000-7f32557b9000 rw-p 02e18000 fc:01 9708000 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcublas-e78c880d.so.8.0.88
7f32557b9000-7f32557c8000 rw-p 00000000 00:00 0
7f32557c8000-7f32557cb000 rw-p 02e36000 fc:01 9708000 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libcublas-e78c880d.so.8.0.88
7f32557cb000-7f32557e0000 r-xp 00000000 fc:01 9708002 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libgomp-ae56ecdc.so.1.0.0
7f32557e0000-7f32559df000 ---p 00015000 fc:01 9708002 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libgomp-ae56ecdc.so.1.0.0
7f32559df000-7f32559e2000 rw-p 00014000 fc:01 9708002 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libgomp-ae56ecdc.so.1.0.0
7f32559e2000-7f32584ba000 r-xp 00000000 fc:01 9708006 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libnccl.so.1
7f32584ba000-7f32586ba000 ---p 02ad8000 fc:01 9708006 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libnccl.so.1
7f32586ba000-7f32586bb000 rw-p 02ad8000 fc:01 9708006 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libnccl.so.1
7f32586bb000-7f32586bd000 rw-p 02ae4000 fc:01 9708006 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libnccl.so.1
7f32586bd000-7f325c526000 r-xp 00000000 fc:01 9708007 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libTHCUNN.so.1
7f325c526000-7f325c726000 ---p 03e69000 fc:01 9708007 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libTHCUNN.so.1
7f325c726000-7f325c735000 rw-p 03e69000 fc:01 9708007 /home/grzegorz/.venv/lib/python2.7/site-packages/torch/lib/libTHCUNN.so.1
7f325c735000-7f325c755000 rw-p 00000000 00:00 0
7f325c755000-7f325ca1d000 rw-p 04124000 fc:01 9708007
.
.
.
7f3295d6b000-7f3295d6c000 r--p 00107000 fc:01 4465366 /lib/x86_64-linux-gnu/libm-2.23.so
7f3295d6c000-7f3295d6d000 rw-p 00108000 fc:01 4465366 /lib/x86_64-linux-gnu/libm-2.23.so
7f3295d6d000-7f3295d86000 r-xp 00000000 fc:01 4456675 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f3295d86000-7f3295f85000 ---p 00019000 fc:01 4456675 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f3295f85000-7f3295f86000 r--p 00018000 fc:01 4456675 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f3295f86000-7f3295f87000 rw-p 00019000 fc:01 4456675 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f3295f87000-7f3295f89000 r-xp 00000000 fc:01 4465364 /lib/x86_64-linux-gnu/libutil-2.23.so
7f3295f89000-7f3296188000 ---p 00002000 fc:01 4465364 /lib/x86_64-linux-gnu/libutil-2.23.so
7f3296188000-7f3296189000 r--p 00001000 fc:01 4465364 /lib/x86_64-linux-gnu/libutil-2.23.so
7f3296189000-7f329618a000 rw-p 00002000 fc:01 4465364 /lib/x86_64-linux-gnu/libutil-2.23.so
7f329618a000-7f329618d000 r-xp 00000000 fc:01 4465360 /lib/x86_64-linux-gnu/libdl-2.23.so
7f329618d000-7f329638c000 ---p 00003000 fc:01 4465360 /lib/x86_64-linux-gnu/libdl-2.23.so
7f329638c000-7f329638d000 r--p 00002000 fc:01 4465360 /lib/x86_64-linux-gnu/libdl-2.23.so
7f329638d000-7f329638e000 rw-p 00003000 fc:01 4465360 /lib/x86_64-linux-gnu/libdl-2.23.so
7f329638e000-7f329654e000 r-xp 00000000 fc:01 4465371 /lib/x86_64-linux-gnu/libc-2.23.so
7f329654e000-7f329674e000 ---p 001c0000 fc:01 4465371 /lib/x86_64-linux-gnu/libc-2.23.so
7f329674e000-7f3296752000 r--p 001c0000 fc:01 4465371 /lib/x86_64-linux-gnu/libc-2.23.so
7f3296752000-7f3296754000 rw-p 001c4000 fc:01 4465371 /lib/x86_64-linux-gnu/libc-2.23.so
7f3296754000-7f3296758000 rw-p 00000000 00:00 0
7f3296758000-7f3296770000 r-xp 00000000 fc:01 4465354 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f3296770000-7f329696f000 ---p 00018000 fc:01 4465354 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f329696f000-7f3296970000 r--p 00017000 fc:01 4465354 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f3296970000-7f3296971000 rw-p 00018000 fc:01 4465354 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f3296971000-7f3296975000 rw-p 00000000 00:00 0
7f3296975000-7f329699b000 r-xp 00000000 fc:01 4465349 /lib/x86_64-linux-gnu/ld-2.23.so
7f32969c5000-7f3296a85000 rw-p 00000000 00:00 0
7f3296ab6000-7f3296b7b000 rw-p 00000000 00:00 0
7f3296b96000-7f3296b97000 rw-p 00000000 00:00 0
7f3296b97000-7f3296b98000 rwxp 00000000 00:00 0
7f3296b98000-7f3296b9a000 rw-p 00000000 00:00 0
7f3296b9a000-7f3296b9b000 r--p 00025000 fc:01 4465349 /lib/x86_64-linux-gnu/ld-2.23.so
7f3296b9b000-7f3296b9c000 rw-p 00026000 fc:01 4465349 /lib/x86_64-linux-gnu/ld-2.23.so
7f3296b9c000-7f3296b9d000 rw-p 00000000 00:00 0
7fffa626c000-7fffa628d000 rw-p 00000000 00:00 0 [stack]
7fffa639e000-7fffa63a0000 r--p 00000000 00:00 0 [vvar]
7fffa63a0000-7fffa63a2000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
有谁知道可能导致这种情况的原因?
请注意,将导入放入工作顺序并不是真正的解决方案。通常cv2
是在依赖链中导入的,torch
也是如此。我无法告诉用户我的小图书馆他必须导入我按特定顺序提供的模块,否则一切都会爆炸。
环境: