0

我想有一个干净的开始,所以我编译了我自己的最新 ATLAS、Lapack 和 Python 2.7.3 的副本。

我已经安装了 numpy,它可以识别来自 ATLAS 的 BLAS 以及以下工作......

  python
  import numpy
  numpy.test()

但是scipy可没那么容易!

$ python
Python 2.7.3 (default, Jan 14 2013, 13:13:35)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy.linalg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/__init__.py", line 133, in <module>
    from basic import *
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/basic.py", line 12, in <module>
    from lapack import get_lapack_funcs
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/lapack.py", line 15, in <module>
    from scipy.linalg import clapack
ImportError: /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/clapack.so: undefined symbol:
+clapack_sgesv

$ which python
/projects/nrel/cid/ladab/pkgi/bin/python

$ ldd /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/clapack.so
        linux-vdso.so.1 =>  (0x00007fff57bff000)
        libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00007f9229192000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f9228ef4000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f9228cde000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f922894b000)
        /lib64/ld-linux-x86-64.so.2 (0x000000387dc00000)

$ cat scipy-0.11.0/site.cfg
[DEFAULT]
library_dirs = /projects/nrel/cid/ladab/pkgi/lib
include_dirs = /projects/nrel/cid/ladab/pkgi/include
[blas_opt]
libraries = f77blas, cblas, atlas
[lapack_opt]
libraries = lapack, f77blas, cblas, atlas

$ env | egrep python
PYTHONPATH=/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages

搜索 clapack_sgesv 的定义,我在 site-packages/scipy 中找不到:

$ cd /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg

$ for ii in *.so; do echo ========== $ii; nm $ii | egrep clapack_sgesv
> done
========== atlas_version.so
========== calc_lwork.so
========== cblas.so
========== clapack.so
                 U clapack_sgesv
00000000002103e0 d doc_f2py_rout_clapack_sgesv
0000000000009810 t f2py_rout_clapack_sgesv
========== fblas.so
========== flapack.so
========== _flinalg.so

它显然在 LD_LIBRARY_PATH 上可用,但 scipy 没有使用它......

$ echo $LD_LIBRARY_PATH
/projects/nrel/cid/ladab/pkgi/lib:/usr/lib64

$ cd /projects/nrel/cid/ladab/pkgi/lib

$ for ii in *.so; do echo ========== $ii; nm $ii | egrep clapack_sgesv; done
========== libsatlas.so
0000000000094ce0 T clapack_sgesv
========== libtatlas.so
00000000000accb0 T clapack_sgesv

你有什么建议吗?

4

2 回答 2

1

非常感谢 Adam Cadien 的评论…… http://www.scipy.org/Installing_SciPy/Linux中关于“在 Ubuntu(2010 年 11 月)上使用 gfortran 从源代码构建所有内容”的部分仍然运行良好。

于 2013-01-16T15:10:11.260 回答
0

从 Ubuntu 12.04 升级到 12.10 后,我遇到了这个问题。问题是我在 /usr/local/lib/python2.7/dist-packages 中安装了两个版本的 scipy。为了解决我所做的问题:

 sudo apt-get remove python-scipy
 sudo rm -fr /usr/local/lib/python2.7/dist-packages/scipy*
 sudo apt-get install python-scipy
于 2013-06-10T17:17:26.613 回答