# Jupyter on Slurm

Run JupyterLab interactively on a compute node via SSH port forwarding. For a simpler browser-based experience, see **PowerIDE**.

## Step 1: Start an Interactive Job

```bash
srun -p <partition-name> -A <account-name> --pty bash
```

Replace `<partition-name>` and `<account-name>` with your values from `check_my_partitions`. Note the compute node name you land on (e.g. `compute-0-62`) — you'll need it later.

## Step 2: Load the Jupyter Module

```bash
module load mamba-env158/jupyter
```

## Step 3: Start JupyterLab

```bash
jupyter lab --ip=* --port=8892 --no-browser
```

Once started, you'll see output containing a URL with a token:

```bash
http://localhost:8892/lab?token=<token>
```

Copy the full URL including the token.

## Step 4: SSH Port Forwarding

Open a new terminal on your local machine and run:

```bash
ssh -N -L 8892:<compute-node-name>:8892 <username>@slurmlogin.tau.ac.il
```

Replace `<compute-node-name>` with the node from Step 1 (e.g. `compute-0-62`) and `<username>` with your TAU username. Keep this terminal open.

## Step 5: Open in Browser

Paste the URL from Step 3 into your browser:

```bash
http://localhost:8892/lab?token=<token>
```

## Step 6: Closing

When finished, press `Ctrl+C` in the interactive session to stop JupyterLab, then:

```bash
exit
```

Also close the SSH tunnel terminal.

## Notes

- If port 8892 is in use, pick any other free port — use the same number in both the `jupyter lab` command and the SSH tunnel
- The SSH tunnel must stay open while you work
- For a simpler experience without SSH tunneling, use **PowerIDE** instead