源码安装Hyper MPI
前提条件
编译环境变量检查
- 请执行以下命令,检查GCC 7.3/8.4/9.3是否安装。
gcc -v
回显信息显示如下表示GCC 7.3.0已安装:
gcc version 7.3.0(GCC);
- 请执行以下命令,检查libtool是否安装。
libtool --version
回显信息显示如下表示libtool 2.4.2已安装:
libtool (GNU libtool) 2.4.2
软件包编译
Hyper MPI包含ompi和ucx两个软件层,其中ompi的安装依赖于ucx,编译时应先编译ucx。
- ucx编译
- 执行如下命令,从github上获取hucx源码包“hucx-huawei.tar.gz”。
- 执行如下命令,从github上获取xucg源码包“xucg-huawei.tar.gz”。
- 执行如下命令,解压上述两个源码包,并将xucg源码包中的内容复制到hucx源码包中的“src\ucg”目录下。
tar -xzvf hucx-huawei.tar.gz
tar -xzvf xucg-huawei.tar.gz
- 执行如下命令,压缩hucx源码包。
- 将源码包上传至服务器,例如“/where/to/download/ucx”目录。
- 执行如下命令,进入源码包路径。
/where/to/download/ucx:代表ucx源码包上传后的存放路径。
- 执行如下命令,解压软件包。
- 执行如下命令,进入autogen.sh脚本所在目录。
- 执行如下命令,进行源码包安装。
./contrib/configure-opt --prefix=/where/to/install/ucx
环境上若没有安装numactl插件,则需要执行如下命令,指定--disable-numa参数:
./contrib/configure-opt --prefix=/where/to/install/ucx --disable-numa
make -j32
make -j32 install
make后面-j参数是并行编译参数,指的是有多少CPU核心参与编译过程,需用户根据实际CPU核数进行指定。
- ompi编译
- 执行如下命令,从github上获取ompi源码包ompi-huawei.tar.gz。
- 将源码包上传至服务器,例如“/where/to/download/ompi”目录。
- 执行如下命令,进入源码包路径。
/where/to/download/ompi:代表ompi源码包上传后的存放路径。
- 执行如下命令,解压软件包。
- 执行如下命令,进入autogen.pl脚本所在目录。
- 执行如下命令,进行源码包安装。
./configure --prefix=/where/to/install/ompi --with-platform=contrib/platform/mellanox/optimized --enable-mpi1-compatibility --with-ucx=/where/to/install/ucx
make
make install
配置环境变量
可通过environment-modules工具和写入~/.bashrc文件两种方式配置环境变量。
- 方式1:使用environment-modules工具管理环境变量,加载环境前,先确认已安装此工具。此方式用于临时生效Hyper MPI环境变量。
- 执行如下命令,在environment-modules工具安装路径下创建并编辑Hmpi_modulefiles配置文件。
vim /path/to/install/Hmpi_modulefiles
修改内容如下:
#%Module1.0 # HMPI module for use with 'environment-modules' package: conflict mpi prepend-path OPAL_PREFIX /path/to/install/ompi/ prepend-path PATH /path/to/install/ompi/bin:/path/to/install/ucx/bin prepend-path LD_LIBRARY_PATH /path/to/install/ompi/lib:/path/to/install/ucx/lib prepend-path INCLUDE /path/to/install/ompi/include
/path/to/install:表示environment-modules工具的安装路径。用户若不指定安装路径,则默认安装在/usr/share/Modules/modulefiles路径下。
- 按“Esc”键,输入:wq!,按“Enter”保存并退出编辑。
- 执行如下module命令,加载环境变量。
module use /usr/share/Modules/modulefiles
module load /usr/share/Modules/modulefiles/Hmpi_modulefiles
- 执行如下命令,在environment-modules工具安装路径下创建并编辑Hmpi_modulefiles配置文件。
- 方式2:将以下环境变量写到用户的~/.bashrc文件中,使其配置生效。此方式永久生效Hyper MPI环境变量。
配置环境变量主要是将hucx和hmpi加入到PATH和LD_LIBRARY_PATH中:
export PATH=/where/to/install/ompi/bin:/where/to/install/ucx/bin:$PATH
export LD_LIBRARY_PATH=/where/to/install/ompi/lib:/where/to/install/ucx/lib:$LD_LIBRARY_PATH
export PATH=/where/to/install/ompi/bin:/where/to/install/ucx/bin:$PATH
export LD_LIBRARY_PATH=/where/to/install/ompi/lib:/where/to/install/ucx/lib:$LD_LIBRARY_PATH