Easily launch jupyter notebook on AWS and access locally

The GPU instance created in Classification of CIFAR-10 by GPU instance of AWS is usually expensive, so stop it and start jupyter notebook from time to time. I want to touch it from the browser. The assumption is an AWS super light user with only one instance in one region. (Because the settings are not general-purpose at all ...)

Launch an instance with aws CLI

You can do the same thing by flipping through the console, but the CLI is good because it takes time. If you have more than one instance in your region, it should fail if you don't change the options you pass to jq.

Bring the instance ID with describe-instances and pass it to the start-instances. There must be a better article about the know-how in this area.

aws ec2 start-instances --instance-ids `aws ec2 describe-instances | jq -r '.Reservations[].Instances[].InstanceId'` 

LocalForward settings in ~ / .ssh / config

When "ec2" is connected to Public DNS included in the domain, the user name and key file are fixed and set to Local Forward. Now, if you connect to the local 8888 while you are connected to SSH, you will be connected to the 8889 that is waiting on the EC2 side.

Host *ec2*
    User ec2-user
    LocalForward 8888 127.0.0.1:8889
    IdentityFile ~/.ssh/gpu.pem

Connect to SSH and start jupyter notebook

SSH executes the following command so that it connects to the PublicDnsName at that time.

ssh `aws ec2 describe-instances | jq -r '.Reservations[].Instances[].PublicDnsName'` 

Launch jupyter notebook so that Keras (Theano) uses GPU. The startup port is 8889.

THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 jupyter notebook --no-browser --port 8889 

Access from a local browser

Send the necessary ipynb file with scp etc. The access destination will be http: // localhost: 8888 /.

Recommended Posts

Easily launch jupyter notebook on AWS and access locally
Jupyter on AWS
Install matplotlib and display graph on Jupyter Notebook
Launch and use IPython notebook on the network
[Windows] [Python3] Install python3 and Jupyter Notebook (formerly ipython notebook) on Windows
High charts on Jupyter notebook
View PDF on Jupyter Notebook
Run Jupyter Notebook on windows
Until you create Python Virtualenv on Windows and launch Jupyter
A simple way to launch Jupyter Notebook / Lab and set a password
Formatting with autopep8 on Jupyter notebook
Use jupyter on AWS GPU instance
Run azure ML on jupyter notebook
Jupyter Notebook: 4 banal tips and tricks
Install Anaconda on Mac and upload Jupyter (IPython) notebook to Anaconda Cloud
Launch jupyter notebook (+ take security measures)
Try running Jupyter Notebook on Mac
How to set up a jupyter notebook on ssh destination (AWS EC2)
Settings when reading S3 files with pandas from Jupyter Notebook on AWS
Use Jupyter Lab and Jupyter Notebook with EC2
Make Jupyter Notebook a service on CentOS
Try SVM with scikit-learn on Jupyter Notebook
Start jupyter notebook on GPU server (remote server)
AWS EC2 instance launch and ssh connection
Install and launch k3s on Manjaro Linux
Clone the github repository on jupyter notebook
Jupyter Notebook basic operations and shortcut keys
GPU check of PC on jupyter notebook
Display histogram / scatter plot on Jupyter Notebook
Linking python and JavaScript with jupyter notebook
Build jupyter notebook on remote server (CentOS)
Use vim keybindings on Docker-launched Jupyter Notebook
Run Jupyter notebook on a remote server
Easy installation and launch of Jupyter Notebook using Docker (also supports nbextensions and Scala)
How to install Fast.ai on Alibaba Cloud GPU and run it on Jupyter notebook
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Mutual conversion between Qiita articles and Jupyter notebook
[Jupyter Notebook / Lab] 3 ways to debug on Jupyter [Pdb]
Enable Jupyter Notebook with conda on remote server
[Pythonocc] I tried using CAD on jupyter notebook
Simply display a line graph on Jupyter Notebook
Find and delete memory-hungry variables on Jupyter (IPython)
Try Apache Spark on Jupyter Notebook (on local Docker
Launch Jupyter notebook / termial by right-clicking [Win / Linux]
Remotely open Jupyter notebook launched on the server
(Bottom) Cooperation between Jupyter Notebook and running Excel
jupyter notebook does not start on mac fish
The story of launching python2.x jupyter notebook using docker (crushed on Saturday and Sunday)
Easily prepare a Jupyter Notebook environment with Docker (Tensorflow and Graphviz are also available)
Read the csv file with jupyter notebook and write the graph on top of it