[PYTHON] I tried to start Jupyter with Amazon lightsail

A VPS service called "lightsail" has started from AWS, so I tried using it as a trial. I wanted to use it as a learning environment for deep learning. I put Jupyter in and started it. The procedure is summarized here.

By the way, what you learn is O'Reilly's "Deep Learning from scratch". Recommended because it is very easy to understand! picture978-4-87311-758-4.gif https://www.oreilly.co.jp/books/9784873117584/

Premise

If you have an AWS account

Launch lightsail

Go to lightsail page chrome_2016-12-01_20-45-27.png

Click "Base OS". Select "Ubuntu" and click "Apps + OS" chrome_2016-12-01_20-47-06.png

I want to use "Nginx" as a reverse proxy, so select "Nginx" chrome_2016-12-01_20-47-31.png

The price plan is of course the cheapest "$ 5"! chrome_2016-12-01_20-48-58.png

Specify the name of the instance to be created this time. This time, I created it with "python-deeplarning-jupyter" (when I actually made it, I misspelled it as depplarning ...) Once you have decided on a name, click "Create"! chrome_2016-12-01_20-49-58.png

You have an instance! Click the link of the created instance. chrome_2016-12-01_20-51-07_Ink_LI.jpg

Instance settings

I want to see Jupyter in the browser, so I will make settings for that.

Granting Elastic IP

If the IP changes every time, it will be troublesome to access the browser, so give an Elastic IP (fixed IP) to the instance.

Click Networking on the screen below. chrome_2016-12-01_20-52-09_Ink_LI.jpg

Click "Create Static IP" under Public IP chrome_2016-12-01_21-09-23.png

It is said that you should name the Static IP, so name it appropriately and click "Create"! chrome_2016-12-03_20-08-35.png

Now you have a fixed IP!

Nginx settings

Now, let's go into the server and set up Nginx!

I want to SSH to log in to the server, but it's annoying so let's log in from the web console. Click "Connect using SSH" on the screen below. chrome_2016-12-01_20-52-09.png

From here on, work on the console. Rewrite the Nginx configuration file as follows.

sudo vim /opt/bitnami/nginx/conf/bitnami/bitnami.conf
===
upstream jupyter {
    server localhost:8888;
}

server {
    listen      80;
    server_name localhost;
    
    allow xxx.xxx.xxx.xxx;
    deny all;
    
    location / {
        proxy_pass http://jupyter;
        
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Origin "";
    }
}
===

Settings for viewing Jupyter via Nginx. Of course I don't want to be seen by others

allow xxx.xxx.xxx.xxx;

By the way, specify the global IP address of your PC.

As for the setting of location, Jupyter uses WebSocket, so set WebSocket.

If you can do this, restart Nginx. If you don't get an error

sudo /opt/bitnami/ctlscript.sh restart nginx

If you can do so, try accessing Elastic IP (fixed IP) with a browser.

http://xxx.xxx.xxx.xxx

Success when the following screen is displayed! chrome_2016-12-01_20-57-32.png

Jupyter settings

First, install pip before installing Jupyter. O'Reilly's deep learning book is based on Python3, so I will use it for Python3.

curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
curl -kL https://bootstrap.pypa.io/get-pip.py | sudo python3

Next, install Jupyter.

pip3 install jupyter

Create a save destination for files generated within Jupyter. It can be anywhere.

mkdir ~/jupyter

Generate Jupyter configuration file. And edit the configuration file.

jupyter notebook --generate-config

vim ~/.jupyter/jupyter_notebook_config.py
===
#Line 179 Specify the Jupyter file save destination directory. The directory created above.
c.NotebookApp.notebook_dir = '/home/bitnami/jupyter'
#Line 185 When you start Jupyter, the browser starts and it gets in the way, so it is OFF
c.NotebookApp.open_browser = False
===

At this point, start Jupyter.

jupyter notebook

Access the page you saw when checking the operation of Nginx with a browser

http://xxx.xxx.xxx.xxx

Complete when the screen below appears! chrome_2016-12-03_20-07-16.png

Finally

So I was able to start Jupter with lightsail. Other AWS services are pay-as-you-go, but this lightsail is a flat rate, so even beginners can rest assured. Recommended for people who don't like VMs because they are heavy.

Recommended Posts

I tried to start Jupyter with Amazon lightsail
I tried to touch jupyter
I want to start a jupyter environment with one command
I tried using Amazon SQS with django-celery
I tried to implement Autoencoder with TensorFlow
I tried to visualize AutoEncoder with TensorFlow
I want to blog with Jupyter Notebook
I tried to implement CVAE with PyTorch
I tried to solve TSP with QAOA
I tried to predict next year with AI
I tried to detect Mario with pytorch + yolov3
I tried to implement reading Dataset with PyTorch
I tried to use lightGBM, xgboost with Boruta
I tried to learn logical operations with TF Learn
I tried to move GAN (mnist) with keras
I tried to detect motion quickly with OpenCV
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
I tried to debug.
I tried to automate sushi making with python
I tried to predict Titanic survival with PyCaret
I tried to paste
I tried using Jupyter
I want to start over with Django's Migrate
I tried to operate Linux with Discord Bot
I tried to study DP with Fibonacci sequence
I tried to judge Tsundere with Naive Bayes
I tried to create a model with the sample of Amazon SageMaker Autopilot
I tried to learn the sin function with chainer
I tried to move machine learning (ObjectDetection) with TouchDesigner
I tried to create a table only with Django
I tried to extract features with SIFT of OpenCV
I tried to move Faster R-CNN quickly with pytorch
I tried to read and save automatically with VOICEROID2 2
I tried to implement and learn DCGAN with PyTorch
I tried to implement Minesweeper on terminal with python
I tried Amazon Comprehend sentiment analysis with AWS CLI.
I tried to get started with blender python script_Part 01
I tried to draw a route map with Python
I tried to solve the soma cube with python
I tried to automatically read and save with VOICEROID2
I tried to get started with blender python script_Part 02
I tried to generate ObjectId (primary key) with pymongo
I tried to implement an artificial perceptron with python
I tried to build ML Pipeline with Cloud Composer
I tried to implement time series prediction with GBDT
I tried to uncover our darkness with Chatwork API
I tried to automatically generate a password with Python3
[Introduction to Pytorch] I tried categorizing Cifar10 with VGG16 ♬
I tried to solve the problem with Python Vol.1
I tried to analyze J League data with Python
I tried to make an OCR application with PySimpleGUI
I tried to implement SSD with PyTorch now (Dataset)
I tried to interpolate Mask R-CNN with Optical Flow
I tried to step through Bayesian optimization. (With examples)
I tried to find an alternating series with tensorflow
[Introduction to AWS] I tried playing with voice-text conversion ♪
I tried to solve AOJ's number theory with Python
I tried fp-growth with python
I tried scraping with Python
I tried to learn PredNet