How to Run Jupyter In Any Cloud With One Command

wo pain points often faced by scientists and engineers are:

Here’s a solution!

Requirements

  1. Download the terraform CLI tool and say goodbye to ClickOps (free)
  2. Get an ngrok account for port forwarding convenience (free)
  3. Have cloud credentials, of course! (AWS, Azure, GCP, or K8s.)

Lift off! 🚀

Using this GitHub repository and TPI to do all the heavy lifting:

git clone https://github.com/iterative/blog-tpi-jupyter
cd blog-tpi-jupyter
export NGROK_TOKEN="..."  # Signup for free at https://ngrok.com
terraform init    # Setup local dependencies
terraform apply   # Create cloud resources & upload workdir
terraform refresh # Get URLs (rerun if blank)

It takes a few minutes to launch cloud resources and upload your working directory, so you might have to wait a bit before running terraform refreshagain. Soon, you’ll see:

Outputs:
urls = [
  "Jupyter Lab: https://{id}.ngrok.io/lab?token=...",
  "Jupyter Notebook: https://{id}.ngrok.io/tree?token=...",
  "TensorBoard: https://{id}.ngrok.io",
]

Click on those URLs to get to your dev environment! ✨

Image description

Download & Cleanup 📥

When done experimenting, download the shared workdir, delete the cloud storage, and terminate the cloud instance with one simple command:

terraform destroy

Benefits 🎩

It uses Terraform Provider Iterative (TPI) under-the-hood. There are a few distinct advantages to TPI:

💰 Lower cost: use your preferred cloud provider’s existing pricing, including on-demand per-second billing and bulk discounts.

🔄 Auto-recovery: spot/preemptible instances are cheap but unreliable. TPI reliably and automatically respawns such interrupted instances, caching & restoring the working directory in the cloud even when you are offline.

👓 Custom spec: full control over hardware & software requirements via a single main.tf config file - including machine types (CPU, GPU, RAM, storage) & images.

Happy coding!

Exit mobile version