我想在我的系统(Linux 2.6.32_1-18-0-0 x86_64 GNU/Linux)中安装tensorflow库,但是由于系统中的libc太旧,一些函数定义找不到。错误信息如下:
$ python
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/.jumbo/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/root/.jumbo/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 48, in <module>
from tensorflow.python import pywrap_tensorflow
File "/root/.jumbo/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/root/.jumbo/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /root/.jumbo/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: symbol memcpy, version GLIBC_2.14 not defined in file libc.so.6 with link time reference
因此,我自己实现了缺少的函数,并将其编译为So,放入/home/tensorflow/mylibc中/我的Libc.so在
下次启动python时,我是这样做的
^{pr2}$在我更多的测试中,一切似乎都很好,实际上也没问题。在
但是,当运行jupyter(ipython notebook)时,在笔记本中,当我输入“import tensorflow”时,我再次遇到导入错误 我运行jupyter如下:
LD_PRELOAD=/home/tensorflow/mylibc/mylibc.so jupyter notebook --ip=0.0.0.0 --port=8888 > /dev/null 2>&1 &
错误如下
ImportError: /root/.jumbo/opt/gcc46/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /root/.jumbo/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)
然后,我决定为python编写一个shell脚本。如下所示:
$ cd ~/.jumbo/bin # the python binary directory
$ ls -l | grep python
-rwxr-xr-x 1 root root 234 Oct 10 03:58 ipython
-rwxr-xr-x 1 root root 234 Oct 10 03:58 ipython2
-rwxr-xr-x 1 root root 87 Oct 10 05:40 python -> python2
lrwxrwxrwx 1 root root 14 Aug 15 02:42 python-config -> python2-config
lrwxrwxrwx 1 root root 9 Aug 15 02:42 python2 -> python2.7
lrwxrwxrwx 1 root root 16 Aug 15 02:42 python2-config -> python2.7-config
-rwxr-xr-x 1 root root 9864 Jul 26 03:17 python2.7
-rwxr-xr-x 1 root root 1626 Jul 26 03:17 python2.7-config
$ rm python
$ vim python # I typed the following text into file python, making python as a wrapper for python2.7, the actual executable file
#!/bin/sh
LD_PRELOAD=/home/tensorflow/mylibc/mylibc.so "/root/.jumbo/bin/python2.7" $@
$ chmod +x python
然后我再次运行jupyter,创建了一个新的笔记本,试图导入tensorflow。但是,又出现了同样的导入错误。在
我列出了jupyter的进程,发现在启动一个新的笔记本时,jupyter实际上会产生一个单独的进程。用python2.7代替python来执行新的笔记本
root 792 0.1 0.0 685252 43856 ? Ssl 06:31 0:00 /root/.jumbo/bin/python2.7 -m ipykernel -f /root/.local/share/jupyter/runtime/kernel-d8e49d7b-d36f-4806-8013-be5a7c3a2028.json
root 1020 0.5 0.0 13352 1348 ? S 06:58 0:00 /bin/sh /root/.jumbo/bin/python /root/.jumbo/bin/jupyter-notebook --ip=0.0.0.0 --port=8888
所以,我的问题是,如何让ldu PRELOAD在我的jupyter笔记本上实际工作?谢谢你的建议。在
目前没有回答
相关问题 更多 >
编程相关推荐