python报错解决方案:./../scikit_learn.libs/libgomp-d22c30c5.so.1.0.0: cannot allocate memory in static TLS

文章讲述了在ARM平台上遇到sklearn报错的问题,涉及libgomp内存占用TLS块。提供了两种解决方案:一是通过设置LD_PRELOAD环境变量指向特定的libgomp动态库;二是升级glibc版本至2.32。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错如下:

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: run python 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

别出BUG求求了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值