[slurm-users] SLURM_NTASKS not defined after salloc
Jeffrey Frey
frey at udel.edu
Wed Jul 11 08:10:10 MDT 2018
SLURM_NTASKS is only unset when no task count flags are handed to salloc (no --ntasks, --ntasks-per-node, etc.). Can't you then assume if it's not present in the environment you've got a single task allocated to you? So in your generic starter script instead of using SLURM_NTASKS itself, use an expansion with a default value of 1:
${SLURM_NTASKS:-1}
> On Jul 11, 2018, at 9:39 AM, Alexander Grund <alexander.grund at tu-dresden.de> wrote:
>
> Hi Peter,
>
> thanks for the information, you are right: SLURM_NTASKS is not set if "-n" is not passed to salloc.
>
> I am kinda relying on what happens after I call "srun ./binary" especially how many instances will be started. scontrol shows this information, so I could parse this. But is there any better way?
> The script in question is a generic starter (wrapper) and should work no matter what the user passed to salloc. It should just be able to know, how many processes would be started by srun. How can I do that?
>
> Alex
>
>
> Am 11.07.2018 um 15:12 schrieb Peter Kjellström:
>> On Wed, 11 Jul 2018 14:10:51 +0200
>> Alexander Grund <alexander.grund at tu-dresden.de> wrote:
>>
>> > Hi all,
>> >
>> > is it expected/intended that the env variable SLURM_NTASKS is not
>> > defined after salloc? It only gets defined after the an srun command.
>> > The number of tasks appear in `scontrol -d show job <jobid>` though.
>> > So is it a bug in our installation or expected?
>>
>> my salloc sets SLURM_NTASKS (if you pass -n, otherwise not). This is
>> similar to how sbatch works.
>>
>> Tested on 17.11.7
>>
>> /Peter
>>
>> --
>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Alexander Grund
> Interdisziplinäre Anwendungsunterstützung und Koordination (IAK)
>
> Technische Universität Dresden
> Zentrum für Informationsdienste und Hochleistungsrechnen (ZIH)
> Chemnitzer Str. 46b, Raum 010 01062 Dresden
> Tel.: +49 (351) 463-35982
> E-Mail: alexander.grund at tu-dresden.de
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
::::::::::::::::::::::::::::::::::::::::::::::::::::::
Jeffrey T. Frey, Ph.D.
Systems Programmer V / HPC Management
Network & Systems Services / College of Engineering
University of Delaware, Newark DE 19716
Office: (302) 831-6034 Mobile: (302) 419-4976
::::::::::::::::::::::::::::::::::::::::::::::::::::::
More information about the slurm-users
mailing list