如何用一个GPU启动n个任务



我有一个大型计算节点集群,每个节点有6个GPU。我想从100名工人开始,比方说,每个人都可以访问一个GPU。

我现在做的是这样的:

sbatch --gres=gpu:6 --gpus-per-task=1 --ntasks='100' main.sh

在main.sh:内部

srun --gpus-per-task=1 --gres=gpu:1 -n 100 worker.sh

通过这种方式,我启动了100个工人(完全使用17个节点(。但我有一个问题:CUDA_VISIBLE_DEVICES设置不正确。

sbatch --gres=gpu:6 --gpus-per-task=1 --ntasks='100' main.sh
# CUDA_VISIBLE_DEVICES in main.sh: 0,1,2,3,4,5 (that's fine)
srun --gpus-per-task=1 --gres=gpu:1 -n 100 worker.sh
# CUDA_VISIBLE_DEVICES in worker.sh: 0,1,2,3,4,5 (this is my problem: how to assign exactly 1 GPU to each worker and to that worker alone?)

这可能是我对Slurm实际工作方式的误解,因为我对这类HPC系统的编程还很陌生。但有什么线索可以告诉我如何实现我想要实现的目标吗?(每个工人只有一个GPU分配给它(

我们使用SLURM 20.02.2。

我认为这里缺少的是,您还应该明确定义节点的数量:你可以节点=每个节点17 x 6个GPU=102个任务(如果您只需要100个任务,这意味着最后一个节点可能只使用了4个任务而使用不足(

#SBATCH --ntasks=100
#SBATCH --gres=gpu:6
#SBATCH --nodes=17
#SBATCH --ntasks-per-node=6
#SBATCH --cpus-per-task=1   (depends on the available cores per node)
srun -l main.py

最新更新