How to Get Jupyter Notebook Running on AWS

1 minute read


In case you need more processing power to run your model, it might be a good option to use some cloud infrastructure. During my H-1B project I gave it a try on AWS. Although I ended up training the model locally for various reasons, having a quick guide on how to implement the notebook in AWS proved to be helpful.

Also, make sure you use a powerful EC2 instance. I wasn’t able to run the full database only using the free tier so I needed to request a limit increase to p2.xlarge, which should be more powerful to run ML models. After finishing, remember to stop all spot instances, cancel requests and delete any snapshots and volumes. Otherwise, it will keep generating extra charges.

Steps on Local Machine:

Select the instance in AWS

Configure security group ——

SSH TCP 22 Custom TCP Rule TCP 8888

Create a new pair of keys and keep the private secure ——


Adjust the access privileges for your key ——

chmod 400 AWS_private_key.pem ssh-add AWS_private_key.pem

Connect via SSH using your IP ——

ssh -i "AWS_private_key.pem" ec2-user@ec2-[IP]

Steps on AWS Machine ======

Perform updates

sudo yum update

Download and Install Anaconda ——

wget <br />

Set PATH —— In order to execute anaconda’s commands, import numpy, kill jupyter, and launch again

export PATH="/home/ec2-user/anaconda2/bin:$PATH"

Install gcc ——

sudo yum install gcc

Install Jupyter notebook ——

sudo yum install python-pip sudo -H pip install jupyter

Define password hash ——

Pass: this is my password Sha1: sha1:18dfaae5d0f8:cdd4683f2918e8482311e24adc22166d29489204

Install cert pem ——

jupyter notebook --generate-config mkdir certs cd certs sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

Edit jupyter notebook configuration file ——

vim ~/.jupyter/

c = get_config() c.IPKernelApp.pylab = 'inline' c.NotebookApp.certfile = u'/home/ec2-user/certs/mycert.pem' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False

Your password below ——

c.NotebookApp.password = u'sha1:18dfaae5d0f8:cdd4683f2918e8482311e24adc22166d29489204' c.NotebookApp.port = 8888

Run jupyter notebook in background ——

jupyter notebook &

Go to browser and accept the connection and insert password (not sha1) ——


Upload ipynb and dataset and you’re all set!