报错如下:
RuntimeError: Failed to import transformers.pipelines because of the
following error (look up to see its traceback):
/home/q/lib/python3.8/site-packages/sklearn/__check_build/…/…/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0:
cannot allocate memory in static TLS block
___________________________________________________________________________ Contents of /home//lib/python3.8/site-packages/sklearn/__check_build:
pycache init.py _check_build.cpython-38-aarch64-linux-gnu.so
___________________________________________________________________________ It seems that scikit-learn has not been built correctly.If you have installed scikit-learn from source, please do not forget
to build the package before using it: runpython setup.py install
or
make
in the source directory.If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
解决方案
经过网络查询,这是libgomp在arm平台上的一个bug。libgomp gets the statically allocated TLS space that it needs, before the optimization of handing out that space to other libraries kicks in .
即:libgomp-d22c30c5.so.1.0.0运行时占用了TLS部分内存.
1. 方法1
参考这个解决方案:Autokeras trying to import libgomp-d22c30c5.so.1.0.0 from scikit-learn on arm64/aarch64 #1475, https://github.com/keras-team/autokeras/issues/1475
glibc版本2.17不变,显示声明环境变量LD_PRELOAD如下:
export LD_PRELOAD=$LD_PRELOAD:/usr/local/python3.7.5/lib/python3.7/site-packages/scikit_learn.libs/libgomp-d22c30c5.so.1.0.0
2. 方法2
参考自: Bug 1722181 - libgomp.so.1: cannot allocate memory in static TLS block, https://bugzilla.redhat.com/show_bug.cgi?id=1722181
升级glibc版本到2.32.