带有headnode的pbs和slurm集群的客户端包。
hpc05的Python项目详细描述
HPC05
ipyparallel.Client
带有头节点的pbs或slurm集群的包。
通过ssh使用headnode连接到pbs或slurm集群的脚本。由于ipyparallel
在不活动和人们懒惰时不会剔除引擎(因为他们忘记了qdel
他们的工作),因此它会在设置的超时(默认值为15分钟)后自动终止ipengines
。注意,这个包不仅适用于tu delft上的hpc05
集群,也适用于其他集群。
安装
首先在计算机和群集上安装此软件包。
conda config --add channels conda-forge conda install hpc05
或者使用pip
pip install hpc05
通过复制ssh密钥,确保可以通过ssh
无密码连接:
ssh-copy-id hpc05
设置配置文件
您需要集群上的并行配置文件,可以通过本地计算机上的以下命令创建:
importhpc05# for PBS usehpc05.create_remote_pbs_profile(profile='pbs',hostname='hpc05')# on the remote machine# orhpc05.create_local_pbs_profile(profile='pbs')# on the cluster# for SLURM usehpc05.create_remote_slurm_profile(profile='slurm',hostname='hpc05')# on the remote machine# orhpc05.create_local_slurm_profile(profile='slurm')# on the cluster
启动ipcluster
并连接(通过ssh
)
要启动并连接到ipcluster
只需执行(如果有错误,请阅读错误消息以获取说明):
client,dview,lview=hpc05.start_remote_and_connect(n=100,profile='pbs',hostname='hpc05',folder='~/your_folder_on_the_cluster/')
这相当于以下三个命令:
# 0. Killing and removing files of an old ipcluster (this is optional with# the `start_remote_and_connect` function, use the `kill_old_ipcluster` argument)hpc05.kill_remote_ipcluster(hostname='hpc05')# 1. starting an `ipcluster`, similar to running# `ipcluster start --n=100 --profile=pbs` on the cluster headnode.hpc05.start_remote_ipcluster(n=100,profile='pbs',hostname='hpc05')# 2. Connecting to the started ipcluster and adding a folder to the cluster's `PATH`client,dview,lview=hpc05.connect_ipcluster(n=200,profile='pbs',hostname='hpc05',folder='~/your_folder_on_the_cluster/')
启动ipcluster
并连接(在群集头节点上)
要启动并连接到ipcluster
只需执行(如果有错误,请阅读错误消息以获取说明):
client,dview,lview=hpc05.start_and_connect(n=100,profile='pbs',folder='~/your_folder_on_the_cluster/')
这相当于以下三个命令:
# 0. Killing and removing files of an old ipcluster (this is optional with# the `start_remote_and_connect` function, use the `kill_old_ipcluster` argument)hpc05.kill_ipcluster()# 1. starting an `ipcluster`, similar to `ipcluster start --n=200 --profile=pbs`hpc05.start_ipcluster(n=200,profile='pbs')# 2. Connecting to the started ipcluster and adding a folder to the cluster's `PATH`client,dview,lview=hpc05.connect_ipcluster(n=200,profile='pbs',folder='~/your_folder_on_the_cluster/')
监控资源
如果您使用hpc05_monitor.start(client)
启动此包,它将监视您的资源,请参见以下示例使用:
importtimeimporthpc05_monitorhpc05_monitor.start(client,interval=5)# update hpc05_monitor.MAX_USAGE every 'interval' seconds.whilenothpc05_monitor.LATEST_DATA:time.sleep(1)hpc05_monitor.print_usage()# uses hpc05_monitor.LATEST_DATA by defaulthpc05_monitor.print_max_usage()# uses hpc05_monitor.MAX_USAGE
输出:
id hostname date CPU% MEM%
15 node29.q1cluster 2018-09-10T14:25:05.350499 190% 3%
19 node29.q1cluster 2018-09-10T14:25:04.860693 200% 3%
26 node29.q1cluster 2018-09-10T14:25:05.324466 200% 3%
28 node29.q1cluster 2018-09-10T14:25:05.148623 190% 2%
29 node29.q1cluster 2018-09-10T14:25:04.737664 190% 3%
...
开发
我们使用pre-commit对代码进行linting,因此pip install pre_commit
并运行
pre-commit install
在仓库里。