We use the scripts in the FAQ with some modifications:
http://www.schedmd.com/slurmdocs/faq.html#terminal

These just use normal ssh X forwarding, so users just need to log in
with proper ssh X forwarding enabled.  I'll attach the scripts we are
using. They could use some additional error handling and usage
information, but for the most part these are working well.

Doing this means users can ssh to the nodes they have allocated, so I
also combine that with a pam_exec script to put ssh sessions in a
cgroup associated to one of the users jobs on the node (in case of
multiple jobs by the same users, I use the cgroup for the last job
started)

It requires this in the pam sshd module:
session    optional     pam_exec.so /sbin/pam_ssh_exec.sh

I'll attach the pam_ssh_exec.sh as well.

We've also put together a similar type of script called sviz that starts
up VirtualGL on a node with a GPU in it for remote hardware accelerated
visualization. 


On Sun, Feb 10, 2013 at 11:39:04PM -0700, Christopher Samuel wrote:
> 
> Hi folks,
> 
> One of the nice things in Torque that a number of our users use is 
> interactive jobs with X11 forwarding so they can run various codes with 
> graphical interfaces on the compute nodes (such as VMD, or MATLAB, etc).
> 
> Are there any plans for Slurm to support this?
> 
> They also get a bash shell with a pty set up for it so it can do command 
> completion, etc.   Basically just like SSH'ing into the node but running 
> within a job and inside its cpuset.
> 
> All the best!
> Chris
> -- 
>   Christopher Samuel        Senior Systems Administrator
>   VLSCI - Victorian Life Sciences Computation Initiative
>   Email: [email protected] Phone: +61 (0)3 903 55545
>   http://www.vlsci.org.au/      http://twitter.com/vlsci

-- 
andy wettstein
hpc system administrator
research computing center
university of chicago
773.702.1104

#!/bin/bash
# -*- coding: utf-8 -*-
# Author: P�r Andersson (National Supercomputer Centre, Sweden)
# Version: 0.3 2007-07-30
#
# This will submit a batch script that starts screen on a node.
# Then ssh is used to connect to the node and attach the screen.
# The result is very similar to an interactive shell in PBS
# (qsub -I)

script_dir="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"

# Batch Script that starts SCREEN
BS=$script_dir/_interactive
# Interactive screen script
IS=$script_dir/_interactive_screen

KEYFILE=$HOME/.ssh/id_dsa-slurm
KEYFROM="10.50.180.0/22,10.138.4.0/23"
TIMELIMIT=120

if [ ! -f $KEYFILE ]; then
   ssh-keygen -t dsa -f $KEYFILE -P ""
   echo -n "from=\"$KEYFROM\" " >> ~/.ssh/authorized_keys
   cat $KEYFILE.pub >> ~/.ssh/authorized_keys
   chmod 700 ~/.ssh
   chmod 644 ~/.ssh/authorized_keys
fi


touch $HOME/.screenrc-slurm

if ! which sbatch > /dev/null 2>&1; then
    echo "sbatch command not in your path. Do you have the slurm module loaded?"
fi

# Submit the job and get the job id
JOB=$(sbatch --time=$TIMELIMIT --output=/dev/null --error=/dev/null $@ $BS 2>&1 
\
    | egrep -o -e "\b[0-9]+$")

# Make sure the job is always canceled
trap "{ scancel -q $JOB; exit; }" SIGINT SIGTERM EXIT

echo "Waiting for JOBID $JOB to start (press CTRL-C to stop)"

while true; do

    # Check job status
    STATUS=$(squeue -j $JOB -t PD,R -h -o %t)

    if [ "$STATUS" = "R" ];then
        # Job is running, break the while loop
        break
    elif [ "$STATUS" != "PD" ];then
        echo "Job is not Running or Pending. Aborting"
        scancel $JOB
        exit 1
    fi
    echo -n "."
    sleep 1

done

# Determine the first node in the job:
NODE=$(srun --jobid=$JOB -N1 hostname)

# SSH to the node and attach the screen
sleep 1s
ssh -o "IdentitiesOnly=yes" -o "StrictHostKeyChecking=no" -i $KEYFILE -X -t 
$NODE $IS slurm$JOB
# The trap will now cancel the job before exiting.
#!/bin/sh
# -*- coding: utf-8 -*-
# Author: P�r Andersson  (National Supercomputer Centre, Sweden)
# Version: 0.2 2007-07-30
#
# Simple batch script that starts SCREEN.

exec screen -c $HOME/.screenrc-slurm -Dm -S slurm$SLURM_JOB_ID
#!/bin/sh
# -*- coding: utf-8 -*-
# Author: P�r Andersson  (National Supercomputer Centre, Sweden)
# Version: 0.3 2007-07-30
#

SCREENSESSION=$1

screen="screen -c $HOME/.screenrc-slurm"

# If DISPLAY is set then set that in the screen, then create a new
# window with that environment and kill the old one.
if [ "$DISPLAY" != "" ];then
    $screen -S $SCREENSESSION -X unsetenv DISPLAY
    $screen -p0 -S $SCREENSESSION -X setenv DISPLAY $DISPLAY
    $screen -p0 -S $SCREENSESSION -X screen
    $screen -p0 -S $SCREENSESSION -X kill
fi

exec $screen -S $SCREENSESSION -rd

Attachment: pam_ssh_exec.sh
Description: Bourne shell script

Reply via email to