pyopencl import error cffi.so undefined symbol

﹥>﹥吖頭↗ 提交于 2019-12-04 14:43:27

The problem is the the dual ABI in libstdc++ with gcc5.1 for std::string and std::list. Anaconda now installs libstdc++.so.6.0.19 (presumably because they've added a Python package with a C++ library) from gcc 4.8.3 and pre dual ABI where as Ubuntu 16.04 comes with gcc 5.4 and libstdc++.6.0.21. When you build pyopencl it builds and links against your system libstdc++ but when you try to import pyopencl it dynamically links against the Anaconda one and fails to find the symbols.

It should be possible to solve this by adding -D_GLIBCXX_USE_CXX11_ABI=0 to the CXXFLAGS list in the pyopencl siteconf.py. That solves the std::string issue but has other missing symbols:

ImportError: /home/cryan/anaconda3/lib/python3.6/site-packages/pyopencl-2016.2.1-py3.6-linux-x86_64.egg/pyopencl/_cffi.abi3.so: undefined symbol: _ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEEPFvvE

Your options are:

  1. Install gcc from Anaconda (conda install gcc) and build pyopencl using that. Unfortunately if you have Anaconda on your PATH you'll use their gcc everywhere.
  2. Just delete/rename the libstdc++ in ~/anaconda3/lib: cd ~/anaconda3/lib; mv libstdc++.so libstdc++.annoying; mv libstdc++.so.6 libstdc++.annoying.6. Python modules will find your system one which should be backwards compatible.

I'm having the exact same issue.

ImportErrorTraceback (most recent call last)
<ipython-input-1-f1779268ba42> in <module>()
----> 1 import pyopencl as cl

/opt/anaconda2/lib/python2.7/site-packages/pyopencl/__init__.py in <module>()
     32 
     33 try:
---> 34     import pyopencl.cffi_cl as _cl
     35 except ImportError:
     36     import os

/opt/anaconda2/lib/python2.7/site-packages/pyopencl/cffi_cl.py in <module>()
     37 from pytools import memoize_method
     38 
---> 39 from pyopencl._cffi import ffi as _ffi
     40 from .compyte.array import f_contiguous_strides, c_contiguous_strides
     41 

ImportError: /opt/anaconda2/lib/python2.7/site-packages/pyopencl/_cffi.so: undefined symbol: _ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE

I'm on Ubuntu 16.04, using the libOpenCL.so in AMDAPPSDK-3.0. I am able to run some of the OpenCL examples included with this SDK, so I believe this is a pyopencl issue.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!