使用 HPC(高性能计算)应对计算流体动力学 (CFD) 的挑战已成为惯例。随着近一二十年间,HPC 工作站向超级计算机的发展变缓,计算集群正不断地取代单独的大型 SMP(共享内存处理)超级计算机的地位,并且已成为“新常态”。另外,一项更加新的创新——云技术,同样也大幅提升了总的计算吞吐量。
这一篇博文将向您介绍在数分钟内于运行 ANSYS Fluent(一款市售的计算流体动力学软件包)的 AWS 上完成 HPC 集群设置的最佳优良实践。此外您还能看到一些安装 ANSYS Fluent 并运行您的首个作业的示例脚本。“最佳指南”是一种相对称呼,在云技术中更是如此,因为存在能以不同方式组合达成相同目的的诸多可能性(亦称为服务)。仅在需要使用特定的应用程序特性或应用程序功能的情况下,才能判定某种选择是否优于另一种。举例来说,“高性能并行文件系统 (Amazon FSx) 优于 NFS 共享”这一判断在绝大部分 HPC 工作负载中是成立的,但在另一些情形中(例如 !I/O 密集型应用程序,或者创建小型 HPC 集群来运行少量和 / 或小型作业)NFS 共享已经绰绰有余,并且此种方式更加廉价,设置简单。在此篇博文中我们将分享我们视作最佳优良实践的方法,以及其他一些您在实践中可能会考虑的可用替代选择。
我们将会使用的主要集群组件是以下的 AWS 服务:
注意:ANSYS Fluent 是一款需要许可证的市售软件包。本文假定您已获得在 AWS 上使用(或通过 AWS 访问)ANSYS Fluent 的许可证。此外,下文的安装脚本还需要您拥有 ANSYS 安装包。您可以在“下载 – 当前发行版本”下方下载当前发行版本的 ANSYS。
为了加速集群的创建,更重要的是,为了缩短计算节点的启动时间,良好做法是创建一个部分软件包已预安装并且设置已完成配置的自定义 AMI。
yum -y update
yum install -y dkms zlib-devel libXext-devel libGLU-devel libXt-devel libXrender-devel libXinerama-devel libpng-devel libXrandr-devel libXi-devel libXft-devel libjpeg-turbo-devel libXcursor-devel readline-devel ncurses-devel Python Python-devel cmake QT-devel QT-assistant mpfr-devel gmp-devel htop wget screen vim xorg-x11-drv-dummy xorg-x11-server-utils libXp.x86_64 xorg-x11-fonts-cyrillic.noarch xterm.x86_64 openmotif.x86_64 compat-libstdc++-33.x86_64 libstdc++.x86_64 libstdc++.i686 gcc-c++.x86_64 compat-libstdc++-33.i686 libstdc++-devel.x86_64 libstdc++-devel.i686 compat-gcc-34.x86_64 gtk2.i686 libXxf86vm.i686 libSM.i686 libXt.i686 xorg-x11-fonts-ISO8859-1-75dpi.no xorg-x11-fonts-iso8859-1-75dpi.no libXext gdm gnome-session gnome-classic-session gnome-session-xsession xorg-x11-server-Xorg xorg-x11-drv-dummy xorg-x11-fonts-Type1 xorg-x11-utils gnome-terminal gnu-free-fonts-common gnu-free-mono-fonts gnu-free-sans-fonts gnu-free-serif-fonts alsa-plugins-pulseaudio alsa-utils
yum -y groupinstall "GNOME Desktop"
yum -y erase initial-setup gnome-initial-setup initial-setup-gui
#a reboot here may be helpful in case the kernel has been updated
#this will disable the ssh host key checking
#usually this may not be needed, but with some specific configuration Fluent may require this setting.
cat <<\EOF >> /etc/ssh/ssh_config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
EOF
#set higher limits, usefull when running Fluent (and in general HPC applications) on multiple nodes via MPI
cat <<\EOF >> /etc/security/limits.conf
* hard memlock unlimited
* soft memlock unlimited
* hard stack 1024000
* soft stack 1024000
* hard nofile 1024000
* soft nofile 1024000
EOF
#stop and disable the firewall
systemctl disable firewalld
systemctl stop firewalld
#install the latest ENA driver, ATM 2.1.1
cd /tmp
wget https://github.com/amzn/amzn-drivers/archive/ena_Linux_2.1.1.tar.gz
tar zxvf ena_Linux_2.1.1.tar.gz
mv amzn-drivers-ena_Linux_2.1.1 /usr/src/ena-2.1.1
cat < /usr/src/ena-2.1.1/dkms.conf
PACKAGE_NAME="ena"
PACKAGE_VERSION="2.1.1"
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
BUILT_MODULE_LOCATION[0]="kernel/Linux/ena"
BUILT_MODULE_NAME[0]="ena"
DEST_MODULE_LOCATION[0]="/updates"
DEST_MODULE_NAME[0]="ena"
CLEAN="cd kernel/Linux/ena; make clean"
MAKE="cd kernel/Linux/ena; make BUILD_KERNEL=\${kernelver}"
EOF
dkms add -m ena -v 2.1.1
dkms build -m ena -v 2.1.1
dkms install -m ena -v 2.1.1
dracut -f —add-drivers ena
#reboot again, and make sure that after the reboot the ena driver is up to date (run modinfo ena to check)
#install the latest version of NICE DCV (at the moment it is 2017.4)
cd /tmp
wget https://d1uj6qtbmh3dt5.cloudfront.net/server/nice-dcv-2017.4-6898-el7.tgz
tar xzvf nice-dcv-2017.4-6898-el7.tgz
cd nice-dcv-2017.4-6898-el7
yum install -y nice-dcv-server-2017.4.6898-1.el7.x86_64.rpm nice-dcv-gltest-2017.4.216-1.el7.x86_64.rpm nice-xdcv-2017.4.210-1.el7.x86_64.rpm
#install this additional package only in case you are running on an instance equipped with GPU
yum install -y nice-dcv-gl-2017.4.490-1.el7.i686.rpm nice-dcv-gl-2017.4.490-1.el7.x86_64.rpm
# Add the line "blacklist = /usr/bin/Xorg" to section [gl] of /etc/dcv/dcv-gl.conf
# to fix an incompatibility introduced with the latest versions of Xorg and Nvidia driver
sed -i 's|\[gl\]|&\nblacklist = /usr/bin/Xorg|' /etc/dcv/dcv-gl.conf
#Clean up the instance before creating the AMI.
/usr/local/sbin/ami_cleanup.sh
#shutdown the instance
shutdown -h now
现在您可以通过 AWS CLI(或 AWS Web 控制台)创建您的 AMI 了:
AWS ec2 create-image --instance-id i-1234567890abcdef0 --name "Fluent-AMI-v1" --description "This is my first ANSYS Fluent AMI"
输出将如下所示:
{"ImageId": "ami-1a2b3c4d5e6f7g"}
记住 AMI id。稍后 AWS ParallelCluster 配置文件中将会用到。
下一步,创建或复用已有 VPC。注意 vpc-ID 和 subnet-ID。有关为 AWS ParallelCluster 创建并配置 VPC 方法的更多信息,可参阅网络配置。
您可以使用单个子网同时用于主实例和计算实例,或者使用两个子网:一个公共子网上为主实例,一个私有子网上为计算实例。
下方的配置文件展示了在单个子网上运行集群的方法,如此架构图所示:
使用 AWS ParallelCluster 运行 ANSYS Fluent 的最佳实践
还要创建一个开启 8443 端口的临时安全组。这将用于允许与使用 NICE DCV 作为远程桌面流协议的主节点建立入站连接。
现在您可以开始编写配置文件了。在您本地 PC 上打开一个文本文件,并将下方代码粘贴进去。(此处为示例,您可能要依照偏好修改其中一些参数。您还要将占位符 替换为您自己的设置。)
[AWS]
AWS_region_name =
[global]
sanity_check = true
cluster_template = Fluent_cluster_test1
update_check = true
[vpc vpc-us-east-1]
vpc_id = vpc-
master_subnet_id = subnet-
additional_sg=sg-
[cluster Fluent_cluster]
key_name =
vpc_settings = vpc-us-east-1
compute_instance_type=c5n.18xlarge
master_instance_type=g3.4xlarge
initial_queue_size = 0
max_queue_size = 10
maintain_initial_size = true
scheduler=sge
cluster_type = ondemand
s3_read_write_resource=arn:AWS:s3:::*
post_install = s3:///Fluent-post-install.sh
placement_group = DYNAMIC
placement = compute
master_root_volume_size = 64
compute_root_volume_size = 20
base_os = centos7
extra_json = {"cluster" : {"cfn_scheduler_slots" : "cores"} }
tags = {"Name" : "Fluent_cluster_test1"}
fsx_settings = parallel-fs
custom_ami = ami-
[fsx parallel-fs]
shared_dir = /fsx
storage_capacity = 3600
import_path = s3://
imported_file_chunk_size = 1024
export_path = s3:///export
让我们来详细研究一下该配置中的某些设置:
#!/bin/bash
#source the AWS ParallelCluster profile
. /etc/parallelcluster/cfnconfig
#disable hyper-threading
for cpunum in $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | cut -s -d, -f2- | tr ',' '\n' | sort -un); do
echo 0 > /sys/devices/system/cpu/cpu$cpunum/online
done
case "${cfn_node_type}" in
MasterServer)
#save the instance type
instanceType=$(curl http://169.254.169.254/latest/meta-data/instance-type)
if [[$instanceType == *"g3"*]]; then
# configure Xorg to use the Nvidia GPU with the right driver
nvidia-xconfig -preserve-busid -enable-all-gpus
#Configure the GPU settings to be persistent
nvidia-persistenced
#Disable the autoboost feature for all GPUs on the instance
nvidia-smi -auto-boost-default=0
#Set all GPU clock speeds to their maximum frequency.
nvidia-smi -ac 2505,1177
else
cd /etc/X11/
#download a dummy xorg.conf,
#This is used by instances without GPU
wget -q https://xpra.org/xorg.conf
fi
#set the system to run the graphical mode (init 5)
systemctl set-default graphical.target
#and start GDM
systemctl enable gdm.service
systemctl start gdm.service
sleep 2
#enable and start also DCV
systemctl enable dcvserver.service
systemctl start dcvserver.service
sleep 2
#create a NICE DCV session
dcv create-session --owner centos --user centos test1
echo "centos:" | chpasswd
;;
ComputeFleet)
#nothing here, for now
;;
esac
注:将占位符 替换为您自己的密码。该密码将仅用于通过 NICE DCV 执行连接。要通过 SSH 进行连接,您仍然需要使用配置文件中定义的私有密钥。
[版权声明] :本文系网友分享,仅以非商业性的交流和科研为目的,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本网( friends@stuch.cn )联系!我们将协调给予处理。转载授权码:确权中,请原作者尽快与我们取得联系,阅读原文(请登录)..