Centos6 使用 gbdt lightgbm "libc.so.6: version `GLIBC_2.14' not found" "Segment Fault"

  • 由于系统自带的libc.so.6版本过低导致,运行:strings /lib64/libc.so.6|grep GLIBC_,结果中不包含GLIBC_2.14
  • 各种转载的更新glibc的方法不靠谱,轻则运行时"Segment Fault",重则系统崩溃
  • 查看依赖GLIBC_2.14的动态库
python
>>>import lightgbm
Traceback (most recent call last):
...
OSError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/prefer/anaconda2/lib/python2.7/site-packages/lightgbm/lib_lightgbm.so)
  • 找到对应动态库
cd /home/prefer/anaconda2/lib/python2.7/site-packages/lightgbm/lightgbm
  • 查找动态库对GLIBC_2.14的调用
readelf -s lib_lightgbm.so |grep GLIBC_2.14

readelf -V lib_lightgbm.so

  • 将动态库对GLIBC_2.14的依赖降为WEAK
0x039cd8+0x00a0+0x4=0x39d7c
for addr in 0x39d7c; do printf '\x02' | dd conv=notrunc of=./lib_lightgbm.so  bs=1 seek=$((addr)) ; done
readelf -V lib_lightgbm.so

  • 自己新建lib,补充GLIBC_2.14的函数
mkdir libc_my
cd libc_my
vim libc_my.c
#include <string.h>
void* memcpy(void *dest, const void *src, size_t n) {
        return memmove(dest, src, n);
}
gcc -s -shared -o libc_my.so -fPIC -fno-builtin libc_my.c
mv libc_my.so /home/prefer/anaconda2/lib/
  • 配置环境变量,重新运行python
export LD_LIBRARY_PATH=/home/prefer/anaconda2/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=/home/prefer/anaconda2/lib/libc_my.so
python
>>> import lightgbm
  • 如果还是不行,重复上述步骤

 

 

 

 

参考文献:

https://www.jianshu.com/p/308a4e803c81

https://blog.csdn.net/xp5xp6/article/details/52513428

http://www.lightofdawn.org/wiki/wiki.cgi/NewAppsOnOldGlibc

 

posted @ 2018-08-01 14:45  jhc888007  阅读(1398)  评论(0编辑  收藏  举报