linux mpi4py,无法在CentOS 7上安装mpi4py

我有CentOS 7,并安装了mpicc(它可以在C中为openmpi编译)。我还有Python2.7.5,刚刚安装了pip。我运行此命令时遇到以下错误:sudo pip install mpi4py

Collecting mpi4py Using cached mpi4py-2.0.0.tar.gz Installing

> collected packages: mpi4py Running setup.py install for mpi4py ...

> error

> Complete output from command /usr/bin/python2 -u -c "import setuptools,

> tokenize;__file__='/tmp/pip-build-x5jD4O/mpi4py/setup.py';exec(compile(getattr(tokenize,

> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,

> 'exec'))" install --record /tmp/pip-mpMoZO-record/install-record.txt

> --single-version-externally-managed --compile:

> running install

> running build

> running build_src

> running build_py

> creating build

> creating build/lib.linux-x86_64-2.7

> creating build/lib.linux-x86_64-2.7/mpi4py

> copying src/__main__.py -> build/lib.linux-x86_64-2.7/mpi4py

> copying src/__init__.py -> build/lib.linux-x86_64-2.7/mpi4py

> creating build/lib.linux-x86_64-2.7/mpi4py/include

> creating build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/mpi4py.MPI.h -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/mpi4py.MPI_api.h -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/mpi4py.h -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/__init__.pxd -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/libmpi.pxd -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/MPI.pxd -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/__init__.pyx -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/mpi.pxi -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/include/mpi4py/mpi4py.i -> build/lib.linux-x86_64-2.7/mpi4py/include/mpi4py

> copying src/MPI.pxd -> build/lib.linux-x86_64-2.7/mpi4py

> copying src/libmpi.pxd -> build/lib.linux-x86_64-2.7/mpi4py

> running build_clib

> MPI configuration: [mpi] from 'mpi.cfg'

> checking for library 'lmpe' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -llmpe -o _configtest

> /bin/ld: cannot find -llmpe

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> building 'mpe' dylib library

> creating build/temp.linux-x86_64-2.7

> creating build/temp.linux-x86_64-2.7/src

> creating build/temp.linux-x86_64-2.7/src/lib-pmpi

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c src/lib-pmpi/mpe.c -o build/temp.linux-x86_64-2.7/src/lib-pmpi/mpe.o

> creating build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi

> gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/src/lib-pmpi/mpe.o -o

> build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi/libmpe.so

> checking for library 'vt-mpi' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt-mpi -o _configtest

> /bin/ld: cannot find -lvt-mpi

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> checking for library 'vt.mpi' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt.mpi -o _configtest

> /bin/ld: cannot find -lvt.mpi

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> building 'vt' dylib library

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c src/lib-pmpi/vt.c -o build/temp.linux-x86_64-2.7/src/lib-pmpi/vt.o

> gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/src/lib-pmpi/vt.o -o

> build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi/libvt.so

> checking for library 'vt-mpi' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt-mpi -o _configtest

> /bin/ld: cannot find -lvt-mpi

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> checking for library 'vt.mpi' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt.mpi -o _configtest

> /bin/ld: cannot find -lvt.mpi

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> building 'vt-mpi' dylib library

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c src/lib-pmpi/vt-mpi.c -o build/temp.linux-x86_64-2.7/src/lib-pmpi/vt-mpi.o

> gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/src/lib-pmpi/vt-mpi.o -o

> build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi/libvt-mpi.so

> checking for library 'vt-hyb' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt-hyb -o _configtest

> /bin/ld: cannot find -lvt-hyb

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> checking for library 'vt.ompi' ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c _configtest.c -o _configtest.o

> gcc -pthread _configtest.o -lvt.ompi -o _configtest

> /bin/ld: cannot find -lvt.ompi

> collect2: error: ld returned 1 exit status

> failure.

> removing: _configtest.c _configtest.o

> building 'vt-hyb' dylib library

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -c src/lib-pmpi/vt-hyb.c -o build/temp.linux-x86_64-2.7/src/lib-pmpi/vt-hyb.o

> gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/src/lib-pmpi/vt-hyb.o -o

> build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi/libvt-hyb.so

> running build_ext

> MPI configuration: [mpi] from 'mpi.cfg'

> checking for MPI compile and link ...

> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _configtest.c -o _configtest.o

> _configtest.c:2:17: fatal error: mpi.h: No such file or directory

> #include

> ^

> compilation terminated.

> failure.

> removing: _configtest.c _configtest.o

> error: Cannot compile MPI programs. Check your configuration!!!

到目前为止,我尝试了所有的解决方案,但似乎都不管用,请问有人知道这个问题吗?谢谢你

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 安装mpi4py需要在Linux操作系统中进行。您可以通过运行以下命令来安装: 1. 确定已安装MPI软件包。如果没有安装,请先安装。 2. 运行以下命令以安装mpi4py: ``` pip install mpi4py ``` 3. 安装完成后,您可以使用mpi4py在Python脚本中使用MPI功能。 ### 回答2: MPI4Py是一个用于实现Message Passing Interface(MPI)的Python绑定库。MPI是一种用于分布式内存并行计算的标准通信协议。MPI4Py是许多Python程序员向高性能计算和并行编程转向时的理想选择。在Linux安装MPI4Py安装其他Python包类似,具有一些额外的步骤。以下是安装MPI4Py的步骤: 步骤1:安装MPIMPIMPI4Py必须的前置依赖项。 MPI有各种实现,例如MPICH,OpenMPI和Intel MPI。如果您的MPI安装,请根据您的Linux操作系统发行版使用正确的命令进行安装。 例如,在Ubuntu和Debian上安装OpenMPI: $ sudo apt-get install openmpi-bin openmpi-common libopenmpi-dev 步骤2:安装python-dev和pip Python开发工具包(python-dev)和pip是安装MPI4Py的必需工具。进入终端并输入以下命令: $ sudo apt-get install python-dev python-pip 步骤3:安装mpi4py 可以使用PIP(Python包管理器)来直接安装MPI4Py。在终端中,输入以下命令: $ sudo pip install mpi4py 安装完成后,可以在Python代码中使用MPI4Py,如下所示: from mpi4py import MPI comm = MPI.COMM_WORLD print("Hello, I am rank %d of %d." % (comm.rank, comm.size)) MPI4Py包括一些常见的MPI函数,可以方便地用于Python并行编程。使用MPI4Py可以加速Python应用程序并提高其性能。 ### 回答3: MPI(Message Passing Interface)是一种用于进行分布式计算的标准通信协议。MPI4pyMPI的Python版本,提供了Python接口以便开发人员在Python中进行并行计算。安装MPI4py需要按照以下步骤进行。 1.安装MPI库:MPI4py需要依赖MPI库,需要先安装MPI。常用的MPI库有OpenMPIMPICH。可以通过包管理器安装,例如在Ubuntu上执行以下命令安装OpenMPI: sudo apt-get install openmpi-bin libopenmpi-dev 其中openmpi-bin安装MPI程序,libopenmpi-dev安装MPI的头文件和静态库。 2.安装Python和pip:MPI4py需要Python3.x环境以及pip包管理器。如果你已经装好了Python3.x和pip,可以跳过这一步。 3.安装mpi4py:在安装MPI库和Python环境后,可以通过pip安装mpi4py,执行以下命令: pip install mpi4py 如果你使用的是Python2.x环境,则需要执行以下命令: pip2 install mpi4py 4.测试:安装完成后,可以通过以下命令测试MPI4py是否正常工作: mpiexec -n 4 python -c "from mpi4py import MPI; comm = MPI.COMM_WORLD; print('hello world from process %d of %d' % (comm.rank, comm.size))" 其中-n参数指定了进程数量,上面的命令会启动4个进程,每个进程都会输出自己的进程编号和总进程数。 这就是安装MPI4py的步骤。MPI4py提供了很多并行计算的函数和数据类型,可以用于加速大规模的计算任务。如果你需要进行分布式计算,建议学习MPI4py的基本用法并将其应用到自己的项目中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值