<div dir="ltr">Hi Michael,<div>Thanks for your message. Yes I was able to get all interactive sessions killed quickly when trying other partitions and deactivating the prolog. I read your example and I understand how it could possibly work (in the ex., maybe instead of looking if the gpu model is passed, we could look at the number of gpu passed?), but where do i set up that function and where do i call it? <br>Thanks,<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><b><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#9c1d21">Fritz Ratnasamy</span></b><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#9c1d21">Data Scientist</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Arial",sans-serif;color:#9c1d21">Information Technology</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="color:rgb(103,110,115);font-family:Times,serif;font-size:10.5pt">The University of Chicago</span></p><p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">Booth School of Business</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">5807 S. Woodlawn</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">Chicago,</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"> </span><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">Illinois</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"> </span><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">60637</span></p>

<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial"><span style="font-size:10.5pt;font-family:"Times",serif;color:#676e73">Phone: +(1) 773-834-4556</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:#333333"></span></p></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 25, 2021 at 9:54 AM Michael Robbert <<a href="mailto:mrobbert@mines.edu">mrobbert@mines.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-8088488059055945166WordSection1">
<p class="MsoNormal">I doubt that it is a problem with your script and suspect that there is some weird interaction with scancel on interactive jobs. If you wanted to get to the bottom of that I’d suggest disabling the prolog and test by manually cancelling
 some interactive jobs. <u></u><u></u></p>
<p class="MsoNormal">Another suggestion is to try a completely different approach to solve your problem. Why wait until the job starts to do the check? You can use a submit filter and it will alert the user as soon as they try to submit. That will prevent them
 from potentially having to wait in the queue if the cluster is busy and gets around having to cancel a running job. There is a description and simple example at the bottom of this page:
<a href="https://slurm.schedmd.com/resource_limits.html" target="_blank">https://slurm.schedmd.com/resource_limits.html</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Mike<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">slurm-users <<a href="mailto:slurm-users-bounces@lists.schedmd.com" target="_blank">slurm-users-bounces@lists.schedmd.com</a>> on behalf of Ratnasamy, Fritz <<a href="mailto:fritz.ratnasamy@chicagobooth.edu" target="_blank">fritz.ratnasamy@chicagobooth.edu</a>><br>
<b>Date: </b>Tuesday, August 24, 2021 at 21:00<br>
<b>To: </b><a href="mailto:slurm-users@lists.schedmd.com" target="_blank">slurm-users@lists.schedmd.com</a> <<a href="mailto:slurm-users@lists.schedmd.com" target="_blank">slurm-users@lists.schedmd.com</a>><br>
<b>Subject: </b>[External] [slurm-users] scancel gpu jobs when gpu is not requested<u></u><u></u></span></p>
</div>
<div style="border:1pt solid rgb(156,101,0);padding:2pt">
<p class="MsoNormal" style="line-height:12pt;background:rgb(255,235,156)"><b><span style="font-size:10pt;color:rgb(156,101,0)">CAUTION:</span></b><span style="font-size:10pt;color:black"> This email originated from outside of the Colorado School of Mines organization.
 Do not click on links or open attachments unless you recognize the sender and know the content is safe.<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Hello, <br>
<br>
I have written a script in my prolog.sh that cancels any slurm job if the parameter gres=gpu is not present. This is the script i added to my prolog.sh<br>
<br>
<span style="font-family:"Courier New"">if [ $SLURM_JOB_PARTITION == "gpu" ]; then<br>
        if [ ! -z "${GPU_DEVICE_ORDINAL}" ]; then<br>
                echo "GPU ID used is ID: $GPU_DEVICE_ORDINAL "<br>
                list_gpu=$(echo "$GPU_DEVICE_ORDINAL" | sed -e "s/,//g")<br>
                Ngpu=$(expr length $list_gpu)<br>
        else<br>
                echo "No GPU selected"<br>
                Ngpu=0<br>
        fi</span> <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">       # if  0 gpus were allocated, cancel the job</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">        if [ "$Ngpu" -eq "0" ]; then<br>
              scancel ${SLURM_JOB_ID}                                          fi<br>
fi</span><br>
<br>
What the code does is look at the number of gpus allocated, and if it is 0, cancel the job ID. It working fine if a user use sbatch submit.sh (and the submit.sh do not have the value --gres=gpu:1). However, when requesting an interactive session without gpus,
 the job is getting killed and the job hangs for 5-6 mins before getting killed. <br>
<br>
<u></u><u></u></p>
<pre style="margin-right:0in;margin-bottom:3pt;margin-left:0in"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">jlo@mfe01:~ $ srun --partition=gpu --pty bash --login<u></u><u></u></span></pre>
<pre style="margin-right:0in;margin-bottom:3pt;margin-left:0in"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">srun: job 4631872 queued and waiting for resources<u></u><u></u></span></pre>
<pre style="margin-right:0in;margin-bottom:3pt;margin-left:0in"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">srun: job 4631872 has been allocated resources<u></u><u></u></span></pre>
<pre style="margin-right:0in;margin-bottom:3pt;margin-left:0in"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">srun: Force Terminated job 4631872 ...the killing hangs for 5-6minutes<u></u><u></u></span></pre>
<p class="MsoNormal">Is there anything wrong with my script? Why only when scancel an interactive session, I am seeing this hanging. I would like to remove the hanging<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks<br clear="all">
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(156,29,33)">Fritz Ratnasamy</span></b><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(156,29,33)">Data Scientist</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(156,29,33)">Information Technology</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">The University of Chicago</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">Booth School of Business</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">5807 S. Woodlawn</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">Chicago,</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:rgb(51,51,51)"> </span><span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">Illinois</span><span style="font-size:10.5pt;font-family:"Helvetica Neue";color:rgb(51,51,51)"> </span><span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">60637</span><u></u><u></u></p>
<p class="MsoNormal" style="background-image:initial;background-position:initial;background-repeat:initial">
<span style="font-size:10.5pt;font-family:Times;color:rgb(103,110,115)">Phone: +(1) 773-834-4556</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p></p>
<div style="background-color:rgb(255,235,156);width:100%;border-style:solid;border-color:rgb(156,101,0);border-width:1pt;padding:2pt;font-size:10pt;line-height:12pt;font-family:Calibri;color:black;text-align:left">
<span style="color:rgb(156,101,0)">CAUTION:</span> This email has originated outside of University email systems. Please do not click links or open attachments unless you recognize the sender and trust the contents as safe.</div>
<br>
<p></p>
</div>

</blockquote></div>