【发布时间】:2021-07-31 05:35:35
【问题描述】:
我想使用 hpc 来运行我的代码,所以我使用 concurrent.futures 模块运行了 test.py。我有 3 个节点,每个节点有 24 个核心,每个核心有两个线程。我想运行一次 72 核(144 线程),但我的代码运行了 144 次。
test.py:
import concurrent.futures
import time
def do_something(seconds=1):
print(f'Sleeping {seconds} second(s)')
time.sleep(seconds)
return f"Done Sleeping... {seconds}"
start = time.perf_counter()
secs = [2]*48
with concurrent.futures.ProcessPoolExecutor() as executor:
reaults = executor.map(do_something, secs)
for reault in reaults:
print(reault)
end = time.perf_counter()
print(f'Finished in {round (end - start,2)} second(s)')
提交给 hpc 的jobs.sh:
sbatch -N 3 -n 72 python3 test.py
我使用命令sbatch -N 3 ./job.sh 运行它。
结果是 48 行显示“Sleeping 2 seconds”,重复 144 次。
我还尝试了另一个job.sh:
#!/bin/bash
#SBATCH --job-name=mpi4py-test
#SBATCH --nodes=3
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=72
python3 test.py
我使用sbatch -N 3 ./job.sh 运行它
但是,我得到了输出:
sbatch: Warning: can't run 1 processes on 3 nodes, setting nnodes to 1
sbatch: error: Batch job submission failed: Requested node configuration is not available
如何同时使用 72 个内核来运行我的一项任务?
【问题讨论】:
标签: python pool slurm concurrent.futures