Interactive jobs - Desktop environment on a compute nodes¶
Interactive jobs give the user a desktop like environment on a compute node.
Such jobs are useful for tasks where user interactions / input are needed.
For example, although matlab
or Ansys Fluent
jobs can be run as
batch jobs through the command line or scripts, sometimes interacting with their
GUIs is necessary.
Recommended workflow¶
Create the VNC configuration. This step is done when the account is created and hence can be skipped. Execute the procedure described there if your VNC configuration does not exist or is corrupted.
submit the job script ( e.g
sbatch job.sh
)Get the port number after the job starts running from e.g slurm-166866.out get the VNC port number
VNC_HEAD_PORT = 5201
.connect using a vnc viewer to the vnc session running on the compute using e.g
localhost:5201
An interactive job on a compute node¶
When the interactive job script is submitted, a vnc session is created on the compute node. The session is terminated when the job exits or when the job is killed.
To connect to the vnc session using a vnc viewer (client) a tunnel to the
VNC_HEAD_PORT
that is specified in the job script below should be created.
details¶
Create/edit folder and files¶
first check if the folder
.vnc
exists and has the following two files:xstartup
andconfig
by executing:ls ~/.vnc
the output should show
config xstartup
If these files don’t exist, create them by copying the settings from a pre-defined directory on the shared filesystem
/home/shared/sample_scripts/slurm_vnc_job
rm -fvr ~/.vnc cp -fvr /home/shared/sample_scripts/slurm_vnc_job/.vnc ~/ chown -Rc $USER ~/.vnc cp /home/shared/sample_scripts/slurm_vnc_job/job.sh ~/
set the vnc password by executing the command (set a strong password that is at least 12 characters long)
vncpasswd # optionally set a view only password
submit the job¶
The following job script can be used as a template and the resources options
can be changed to meet the demands of a particular simulation. This job
script is also included in ~/.vnc folder. After submitting the job, the
VNC_HEAD_PORT
is written to the slurm-JOBID.out
file.
#!/bin/bash ## specify the job and project name #SBATCH --job-name=my_job_name #SBATCH --account=abc123 ## specify the required resources #SBATCH --partition=normal #SBATCH --nodes=1 #SBATCH --ntasks-per-node=1 #SBATCH --cpus-per-task=8 #SBATCH --mem=4000 #SBATCH --time=0-01:00:00 ### DO NOT EDIT BEYOND HERE UNLESS YOU KNOW WHAT YOU ARE DOING source ~/.bashrc VNC_HEAD_PORT=$(random_unused_port) echo "VNC_HEAD_PORT = ${VNC_HEAD_PORT}" JOB_INFO_FPATH=~/.vnc/slurm_${SLURM_JOB_ID}.vnc.out rm -f ${JOB_INFO_FPATH} VNC_SESSION_ID=$(vncserver 2>&1 | grep "desktop is" | tr ":" "\n" | tail -n 1) echo ${VNC_SESSION_ID} >> ${JOB_INFO_FPATH} ssh -R localhost:${VNC_HEAD_PORT}:localhost:$((5900 + ${VNC_SESSION_ID})) ohead1 -N & SSH_TUNNEL_PID=$! echo ${SSH_TUNNEL_PID} >> ${JOB_INFO_FPATH} sleep infinity
A copy of this file can be obtained from /home/shared/sample_scripts/slurm_vnc_job/job.sh
.
Altenatively create the file in your ~/
directory. The script can be submitted
the usual way using sbatch
.
Create a ssh tunnel¶
On a local terminal, use the VNC_HEAD_PORT
written to the slurm-JOBID.out
file to create the tunnel. The tunnel can be created using other application such
as mobaxterm
using its graphical user interface.
ssh -L localhost:<VNC_HEAD_PORT>:localhost:<VNC_HEAD_PORT> <user>@octopus.aub.edu.lb -N
Connect using a vnc viewer (client) to the ssh tunnel on localhost¶
If you’re using RealVNC type in localhost:<VNC_HEAD_PORT>
or on MobaXterm, session -> VNC
:
Remote hostname or IP address:
localhost
port:
<VNC_HEAD_PORT>