To forward a port using srun in a Slurm environment, you typically want to set up an SSH tunnel to a compute node where your job is running. Here’s how you can do it:
1. Request an Interactive Job with Port Forwarding
When you submit an interactive job with srun, you can request port forwarding using the --tcpip or --tunnel options, but Slurm itself does not directly support port forwarding. Instead, you usually combine srun with SSH tunneling.
This forwards localhost:8888 on your machine to node123:8888.
3. Use the Forwarded Port
Now, any service running on <remote_port> (e.g., a Jupyter notebook) on the compute node will be accessible on your local machine at localhost:<local_port>.
Alternative: Use srun with --tunnel (if supported)
Some Slurm setups allow you to specify --tunnel directly with srun:
bash
srun --tunnel=8888:8888 --pty bash
This is less common and depends on your cluster’s configuration.
Notes:
Ensure the port you want to forward is not blocked by the cluster’s firewall.
If you’re running a service (e.g., Jupyter), make sure it’s bound to 0.0.0.0 or the node’s hostname, not just localhost.
Feb 1, 10:08pm
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.