This quick guide describes how to create a Jupyter Notebook in AWS EC2 then how to access it remotely using SSH tunneling. This method is preferred since you do not open any additional ports besides 22, requires little-to-no configuration, and is generally more straight-forward.
This current version assumes basic familiarity with cloud computing, AWS services, and Jupyter Notebook. Mostly because this version won't have images and won't dive too deep into each individual step.
- Log into EC2 console and click "Launch Instance" button.
- Inside "AWS Marketplace", select the "Deep Learning AMI" from AWS. I use this AMI because most of the stuff you'll need is installed already.
- Select instance type depending on your use case. The "Deep Learning AMI" has support for GPU-backed instance (e.g. g2 and p2) but it's not necessary to use these. Use the cheapest one for your workload (likely memory needed for your dataset).
- In most cases you can use default settings throughout the rest.
- Ensure the instance is assigned to a security group with SSH access.
- Launch your instance
- Tunnel into your instance by adding
-D -L localhost:8888:localhost:8888
to your SSH connection string. This should look likessh -i "key.pem" [email protected] -D -L localhost:8888:localhost:8888
. - Start Jupyter Notebook in the background.
- We recommend using something like screen, tmux, or nohup to keep your notebook in the background even if you lose connection to your instance. Otherwise you may lose your in-progress models.
- Launch Jupyter Notebook using
jupyter notebook --no-browser
. The --no-browser flag prevents the server from launching a browser.
- Open up any web browser and point it to http://localhost:8888 .
That's it! Remember to spin-down your EC2 instance after you're done with it.