Way to the science

MESS安装及使用教程

考虑到MESS软件依赖、conda环境变量的复杂性以及个人使用需求的差异性,现分享两种MESS软件的安装和使用方法以供选择。

1. 公共目录下的Singularity容器化安装及使用

考虑到用户需求的差异,我们提供了两个MESS版本(MESS1.1.0和MESS2.9.0)以便使用。下面将以MESS1.1.0版本为例,具体介绍容器化过程和使用方法。

1.1 创建Singularity容器文件

# 指定容器基础镜像为Docker镜像,从continuumio/miniconda3:24.3.0-0镜像开始构建
Bootstrap: docker
From: continuumio/miniconda3:24.3.0-0

# 将本地环境配置文件mess110.yml复制到容器中
%files
    mess110.yml /opt/mess-env.yml

# 在容器构建过程中执行的操作
%post
    # 设置HTTP和HTTPS代理(如果需要)
    export https_proxy=http://192.168.33.243:7890
    export http_proxy=http://192.168.33.243:7890

    # 根据提供的环境文件创建Conda环境
    conda env create -f /opt/mess-env.yml

    # 为'apptainer run'命令激活mess-env环境
    echo "source /opt/conda/etc/profile.d/conda.sh" >> /.singularity_bash
    echo "conda activate mess-env" >> /.singularity_bash

    # 为'apptainer shell'命令激活mess-env环境
    echo "source /opt/conda/etc/profile.d/conda.sh" >> /etc/bash.bashrc
    echo "conda activate mess-env" >> /etc/bash.bashrc

    # 清理Conda缓存
    conda clean --all

# 设置'apptainer shell'命令的默认shell
%environment
    export SINGULARITY_SHELL=/bin/bash

# 定义容器的默认运行命令
%runscript
    exec /bin/bash --noprofile --init-file /.singularity_bash

# 提供容器使用说明
%help
    To run MESS directly:
    apptainer exec /mnt/softs/singularity_sifs/mess110.sif bash -c "source /opt/conda/etc/profile.d/conda.sh && conda activate mess-env && mess xx.inp"

    To run the container with the default command:
    apptainer run mess.sif

    To access an interactive shell session inside the container:
    apptainer shell mess.sif

1.2 构建Singularity容器

singularity build mess110.sif mess110.def

1.3 使用方法

# 对于小型计算任务,可选择直接在登录节点进行计算
apptainer exec /mnt/softs/singularity_sifs/mess110.sif bash -c "source /opt/conda/etc/profile.d/conda.sh && conda activate mess-env && mess xx.inp"

# 对于耗时任务,利用slurm脚本选择合适的核数进行计算
#!/bin/bash
#SBATCH --partition=Nebula_Galaxy
#SBATCH --nodelist=node8
#SBATCH -N 1 
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=6
#SBATCH --output="Output_%x"
#SBATCH --error="Error_%x"

job=${SLURM_JOB_NAME}
mkdir /tmp/$USER@$SLURM_JOB_ID

apptainer exec /mnt/softs/singularity_sifs/mess110.sif \
bash -c "source /opt/conda/etc/profile.d/conda.sh && conda activate mess-env && mess xx.inp"

wait 
rm -r /tmp/$USER@$SLURM_JOB_ID

2. 个人目录下的Conda环境依赖安装及使用

考虑到用户使用MESS软件需求的多样性,现根据Github上提供的README说明,介绍如何在个人目录下自行安装不同版本的MESS软件,以下为具体安装流程。

2.1 Conda安装

安装MESS代码最简单直接的方式就是通过Conda包管理器。关于Conda的安装步骤详见课题组网站“科研茶话会汇总帖2024/05/18”,此处不再赘述。

2.2 MESS安装

此处提供两处网址以供MESS软件包下载:
(1)https://tcg.cse.anl.gov/papr/codes/mess.html
(2)https://github.com/Auto-Mech/MESS
Gthub上提供了MESS更新迭代的所有版本,因此推荐有特殊使用需求的用户通过该网站下载相应的软件包。
另外,在GitHub上提供了多种详细的安装方式,此处推荐使用【Building from source using Conda environment for dependencies】中给出的安装步骤。以下为具体安装示例:

cd /home/cyj/conda2/MESS-1.1.0

# create the mess-env environment
conda env create -f environment.yml

# activate the environment and bulid the code
conda activate mess-env
bash debug/build.sh

# put the MESS executables in PATH
. debug/fake-install.sh

2.3 使用方法

# 对于小型计算任务,可选择直接在登录节点进行计算
conda activate mess-env
/home/cyj/conda2/MESS-1.1.0/debug/bin/mess xx.inp
!此处推荐使用mess代码的绝对安装路径,否则可能会报错

# 对于耗时任务,利用slurm脚本选择合适的核数进行计算
#!/bin/bash
#SBATCH --partition=Nebula_Galaxy
#SBATCH --nodelist=node8
#SBATCH -N 1 
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=8
#SBATCH --output="Output_%x"
#SBATCH --error="Error_%x"

job=${SLURM_JOB_NAME}
mkdir /tmp/$USER@$SLURM_JOB_ID

conda activate mess-env
/home/cyj/conda2/MESS-1.1.0/debug/bin/mess xx.inp

wait 
rm -r /tmp/$USER@$SLURM_JOB_ID

Leave a comment

Your email address will not be published. Required fields are marked *