Skip to content

Jupyter Notebook

Deploy GPU instances with Jupyter Notebook pre-configured for interactive AI/ML development.

What's included

Jupyter environment:
  • Jupyter Notebook and JupyterLab
  • IPython kernel
  • GPU support enabled
Pre-installed libraries:
  • PyTorch or TensorFlow (depending on environment)
  • NumPy, Pandas, Matplotlib, Seaborn
  • scikit-learn, SciPy
  • CUDA toolkit and GPU drivers
System:
  • Ubuntu 22.04 or 24.04 LTS
  • Python 3.9 to 3.11
  • pip and conda

Deploy a Jupyter environment

Select an environment

  1. Go to app.spheron.aiDeploy
  2. Choose your GPU
  3. Select an OS image:
    • Ubuntu 24.04 LTS ML Everything: includes PyTorch and TensorFlow
    • Ubuntu 24.04 LTS ML PyTorch: PyTorch-focused environment
    • Ubuntu 24.04 LTS ML TensorFlow: TensorFlow-focused environment
  4. Click Deploy

Connect via SSH

ssh root@<your-instance-ip>

Start Jupyter Notebook

Basic setup

# Start Jupyter on all interfaces
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root
 
# Start with a custom password
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='your-password'

Access Jupyter

Open your browser and navigate to:

http://<your-instance-ip>:8888

Retrieve the token if you did not set a custom password:

jupyter notebook list

Run in background

# Using nohup
nohup jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root &
 
# Using screen
screen -S jupyter
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root
# Press Ctrl+A then D to detach

Configuration

Set a password

# Generate a hashed password interactively
jupyter notebook password
 
# Or generate the config file first
jupyter notebook --generate-config

Edit ~/.jupyter/jupyter_notebook_config.py:

c.NotebookApp.password = 'your-hashed-password'
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False
c.NotebookApp.allow_root = True

Enable GPU in notebooks

For PyTorch:
import torch
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"GPU count: {torch.cuda.device_count()}")
print(f"GPU name: {torch.cuda.get_device_name(0)}")
For TensorFlow:
import tensorflow as tf
print(f"GPU devices: {tf.config.list_physical_devices('GPU')}")

Quick examples

Create a new notebook

  1. Open Jupyter in your browser
  2. Click NewPython 3
  3. Start coding

Install additional packages

# In a notebook cell
!pip install transformers accelerate bitsandbytes
 
# Or from the terminal
pip install package-name

Monitor GPU usage

# In a notebook
!nvidia-smi
 
# Or use gpustat
!pip install gpustat
!gpustat -i 1

Troubleshooting

Cannot access Jupyter in browser:
  • Verify Jupyter is running: ps aux | grep jupyter
  • Check that port 8888 is open
  • Use the instance public IP, not localhost
  • Verify the token or password
GPU not detected in notebook:
# Check CUDA installation
!nvcc --version
!nvidia-smi
 
# Reinstall PyTorch with CUDA
!pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Notebook server crashed:
# Check logs
tail -f ~/.jupyter/*.log
 
# Restart Jupyter
pkill jupyter
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root
Port already in use:
# Use a different port
jupyter notebook --ip=0.0.0.0 --port=8889 --no-browser --allow-root

What's next