Ubuntu 16.04安装OpenMPI

Ubuntu 16.04安装OpenMPI环境

安装环境

  • Ubuntu 16.04
  • Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
  • openmpi-1.8.0

下载安装包

1
wget http://www.open-mpi.org/software/ompi/v1.8/downloads/openmpi-1.8.0.tar.gz

解压缩

1
2
tar zxvf openmpi-1.8.0.tar.gz
cd openmpi-1.8.0

配置安装文件

1
2
# 默认至目录:/usr/local/lib,可自定义安装目录,加参数--prefix="/usr/local/openmpi"
./configure --prefix="/usr/local/openmpi"

安装openMPI

1
2
sudo make
sudo make all install

配置环境变量

1
2
3
4
sudo gedit ~/.bashrc
# 在.bashrc文件的最后加上下面这行
export PATH=/usr/local/openmpi/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/openmpi/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

测试

1
2
3
cd openmpi-1.8.0/examples
make
mpirun -np 4 hello_c