How to Install H5PY-MPI
0. Preparation
- linux system
- gcc
- anaconda/miniconda
1. Install open-mpi
Go to "https://www.open-mpi.org/software/".
Download the lastest release (ended with ".tar.gz").
Open the terminal and change dir to the download destination.
Suppose the pack's name is "openmpi-4.1.5.tar.gz".
Run following command to decompress:
tar xvzf openmpi-4.1.5.tar.gz
You will get a folder named "openmpi-4.1.5" under the current dir.
Remember the path of the folder. We will get back here when testing.
In terminal, change dir into the folder.
Run following command to compile (Without --prefix
argument, openmpi would be installed in a default location. MAKE SURE it is installed in the default location):
./configure
Run following command to install:
sudo make all install
Run following command to open .bashrc (If you do not want to use vim, use another text editor such as nano
or gredit
instead.):
sudo vim ~/.bashrc
Add following command at the bottom of .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Run following command to activate changes immediately:
source ~/.bashrc
Change terminal dir to the example folder of the previous decompressed folder.
In my case, I should run following command:
cd ~/Downloads/openmpi-4.1.5/examples
Run following command to build:
make
Run following command to run test file
mpirun -np 4 hello_c
If the ouput is 4 lines of "Hello World", then you have successfully installed open-mpi.
2. Install HDF5
Go to "https://www.hdfgroup.org/downloads/hdf5/source-code" to download the latest release of HDF5 (which in my case is "hdf5-1.14.2.tar.gz)
Open ternimal. Change dir to the download dest. Run following code to decompress:
tar xvzf hdf5-1.14.2.tar.gz
Change dir into the decompressed folder.
Run following code to set MPI-C as compiler:
export CC=mpicc
Run following code to turn on HDF5_MPI:
export HDF5_MPI="ON"
Run following code to change build config:
./configure --enable-shared --enable-parallel --prefix=/usr/local/hdf5
Run following code to set default HDF5_dir:
export HDF5_DIR="/usr/local/hdf5"
Run following code to compile:
make
Run following code to install HDF5:
sudo make install
Run following code to install some other things (Sry. I'm not sure what "other things" are.):
sudo make check-install
3. Install h5py with MPI and HDF5 build
Create a new env.
Activate the new env and run following command:
conda install openmpi
Install tree additional packages:
conda install gcc_linux-64
conda install gxx_linux-64
conda install gfortran_linux-64
Run following code to set MPI-C as compiler:
export CC=mpicc
Run following code to turn on HDF5_MPI:
export HDF5_MPI="ON"
Run following code to set default HDF5_dir:
export HDF5_DIR="/usr/local/hdf5"
Run following code to build h5py from source:
pip install --no-binary=h5py h5py -i https://pypi.tuna.tsinghua.edu.cn/simple
标签:code,Run,HDF5,MPI,Compile,following,install,h5py
From: https://www.cnblogs.com/jamesnulliu/p/Linux-Compile-and-Build-h5py-with-MPI.html