Jupyter Lab
Note
This guide is applicable only to those who requested Jupyter Lab. The examples use roselab1, but the same principles apply to roselab2~4.
Quick Start
Setting Up Permanent Port Mapping
To set up a permanent HTTPS port mapping for JupyterLab using the common utilities:
Navigate to the common utilities directory:
bashcd /public/common-utilities/
Run the client script:
bashpython client.py
Choose option 1: "Add or delete port mapping"
Select "Add a new port mapping"
When prompted, enter the following details:
- Source port: Choose an available port within your assigned port range (e.g., 25308, if your range is 25300-25399)
- Destination port: 8888 (JupyterLab's default port)
- Protocol: HTTPS
Confirm your choices when prompted
After setting up the HTTPS mapping, you can access JupyterLab securely via https://roselab1.ucsd.edu:25308
(replace 25308 with your chosen port number).
Note
HTTPS mapping adds a security layer and is more browser-friendly, but it only supports hosted HTTP web services.
SSH Port Forwarding
If you didn't request port mapping, you'll need to use SSH port forwarding to access your Jupyter service. After confirming successful SSH access to the server:
If you've configured your
.ssh/config
file:bashlaptop$ ssh -fN -L 8888:localhost:8888 roselab1
If you haven't configured
.ssh/config
:bashlaptop$ ssh -fN -L 8888:localhost:8888 ubuntu@roselab1.ucsd.edu -p <ssh-port> -i path/to/keyfile
These commands initiate a background connection forwarding your local port 8888 to the remote Jupyter service. Access your server at http://localhost:8888
. You may need to rerun the command if the network environment changes.
Using Visual Studio Code
If you're using Visual Studio Code with the Remote SSH extension:
- Connect to your RoseLab server.
- Go to the "Ports" view in the left or bottom sidebar.
- Click on "Forward a Port" and enter 8888.
- Access Jupyter Lab at
http://localhost:8888
.
Troubleshooting Port Occupancy
If you encounter a "port already in use" error:
For macOS/Linux:
sudo lsof -i :8888
For Windows (PowerShell):
Get-NetTCPConnection -LocalPort 8888
These commands will show processes using port 8888. You can then close the conflicting process or choose a different port.
Configuration
Jupyter Lab runs as a service on localhost:8888
, configured in /etc/systemd/system/jupyterlab.service
. If killed, it will restart within seconds.
To change the default password, edit ~/.jupyter/jupyter_lab_config.py
:
c.ServerApp.token = 'your-new-password'
Save the file and run sudo systemctl restart jupyterlab
to apply changes.
WARNING
Use a strong password, especially for publicly accessible services. Jupyter Lab will remember your login.
Adding Environments
Jupyter Lab uses the Anaconda base environment. To add a new environment:
(base)$ conda create -n py38 python=3.8
(base)$ conda activate py38
(py38)$ conda install -c anaconda ipykernel
(py38)$ python -m ipykernel install --user --name=py38
To remove an environment's kernel configuration:
rm -rf /home/ubuntu/.local/share/jupyter/kernels/py38
Debugging
If Jupyter Lab malfunctions, check the service log:
$ journalctl -u jupyterlab -n 100
Common issues include out-of-memory errors. Monitor your GPU and memory usage regularly at Grafana.
Note
Replace roselab1 with your assigned server (roselab2, roselab3, or roselab4) in all examples.