h5py没有针对mpi4py正确构建

时间:2015-09-19 10:42:46

标签: python build h5py mpi4py

我正在尝试针对mpi4py构建h5py。我的目的是能够在多个处理器之间共享文件。 h5py安装在系统上,但可能没有链接到mpi4py。 实际上,当我运行以下示例脚本时:

from mpi4py import MPI
import h5py

rank = MPI.COMM_WORLD.rank  # The process ID (integer 0-3 for 4-process run)

f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD)

dset = f.create_dataset('test', (4,), dtype='i')
dset[rank] = rank

f.close()

我收到错误消息:

Traceback (most recent call last):
  File "h5py_example.py", line 6, in <module>
    f = h5py.File('parallel_test.hdf5', 'w', driver='mpio', comm=MPI.COMM_WORLD)
  File "/usr/local/lib/python2.7/site-packages/h5py/_hl/files.py", line 259, in __init__
    fapl = make_fapl(driver, libver, **kwds)
  File "/usr/local/lib/python2.7/site-packages/h5py/_hl/files.py", line 61, in make_fapl
    kwds.setdefault('info', mpi4py.MPI.Info())
NameError: global name 'mpi4py' is not defined

我尝试按如下方式构建h5py:

python setup.py build --mpi --hdf5=/opt/local/

但这给了我以下问题:

error: option --mpi not recognized

我也尝试过使用自制软件和pip进行安装 (希望mpi4py自动链接) 没有成功。

如何正确安装并行h5py?

1 个答案:

答案 0 :(得分:2)

  1. python setup.py configure --mpi --hdf5=/path_parallel_hdf5_lib/

  2. python setup.py build

  3. python setup.py install --prefix=/wheretoinstall_h5py

  4. export PYTHONPATH=$PYTHONPATH:/wheretoinstall_h5py

  5. 您可能还需要预安装cython