The commands on this page use the SSH config entry from your server’s Connect box, so
<server-name> is all you need. Set it up first: see Save the connection once.1
Connect to your server
2
Install JupyterLab
The ready-made images with PyTorch preinstalled have a Python environment at If this fails with On any other image, create an environment first, then use On Ubuntu, if
/opt/pytorch. On those, install JupyterLab into it:Permission denied, your user isn’t in the sudo group yet. This affects servers created from the current PyTorch images, and the fix is to add yourself once, then reconnect and run the install again:~/venv instead of /opt/pytorch in the commands on this page:python3 -m venv fails, install the venv module first with sudo apt install -y python3-venv.3
Start JupyterLab
Still on the server, start it inside Jupyter prints a URL containing
tmux, so Jupyter keeps running if your connection drops:token=.... Copy it. To leave tmux running in the background, press Ctrl-b, then d.4
Open the tunnel from your computer
In a new terminal on your own computer:Leave it running. It forwards port 8888 on your computer to Jupyter on the server.
5
Open Jupyter in your browser
Paste the URL Jupyter printed, for example
http://localhost:8888/lab?token=....Check that the notebook sees the GPU
In a notebook cell:Tips
- If port 8888 is already used on your computer, pick another local port, for example
ssh -N -L 9999:localhost:8888 <server-name>, and openhttp://localhost:9999. - To get back to Jupyter later, connect with
ssh <server-name>and runtmux attach -t jupyter. - To use the same Python environment in your terminal, run
source /opt/pytorch/bin/activate(orsource ~/venv/bin/activate). - Notebooks are saved on the server’s disk. See Where your data lives.
Related
SSH keys and connecting
Add a key, turn on SSH and connect.
Where your data lives
What is kept, what is lost, and how to save results.
Servers
Launch, connect, park and delete servers.
Deploy a model
Serve an open model behind an OpenAI-compatible API.