[PYTHON] Build a TensorFlow development environment on Amazon EC2 with command copy and paste

Introduction

This is a memo for missionary work. It is for people who want to separate the environment because it will be hard for the PC to execute local resources. The $ notation at the beginning is removed for learning copy. We emphasize the effort of rebuilding (it is not on Docker, but you can easily crush the instance even if the construction fails) and the price. If you want to focus on execution speed and rotate the GPU, please refer to Separate article.

procedure

Add Amazon EC2 instance

ssh login

chmod 600 xxxxxxxxxx.pem
ssh -v -i xxxxxxxxxx.pem [email protected]

Package update

sudo apt-get update && sudo apt-get -y upgrade

Python preparation

pip installation

sudo apt-get install -y python-pip python-dev
sudo pip install -U pip

Machine learning library + TensorFlow

Install frequently used libraries

You have the following installed:

  1. numpy: Matrix calculation library
  2. scipy: Scientific calculation library
  3. pandas: data frame library
  4. matplotlib: Graph drawing library
  5. Pillow: Image processing library
  6. scikit-learn: Machine learning library
  7. google-api-python-client: Google API Client for Python
sudo apt-get install -y libpq-dev python-matplotlib gfortran
sudo pip install --upgrade pip
sudo pip install numpy scipy pandas matplotlib Pillow scikit-learn
sudo pip install google-api-python-client

TensorFlow installation

Install the latest version as of 09/01/2016. Please check Latest version before installing.

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl

Jupyter

Jupyter installation

sudo pip install jupyter

Jupyter config change (port setting etc.)

jupyter notebook --generate-config && ipython profile create
echo "c = get_config()" >> /home/ubuntu/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.ip = '*'" >> /home/ubuntu/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False" >> /home/ubuntu/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.port = 8888" >> /home/ubuntu/.jupyter/jupyter_notebook_config.py
echo "c.InteractiveShellApp.matplotlib = 'inline'" >> /home/ubuntu/.ipython/profile_default/ipython_kernel_config.py

Jupyter login password setting

Register your login password. Make a copy of sha1 displayed after registration is completed.

python -c 'import IPython;print(IPython.lib.passwd())'

Add the copied sha1 to config.

echo "c.NotebookApp.password = 'sha1:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'" >> /home/ubuntu/.jupyter/jupyter_notebook_config.py

Start Jupyter

jupyter notebook You can log in at http://ec2-x-x-x-x.ap-northeast-1.compute.amazonaws.com:8888/ when you start with. If you want to start the EC2 instance at the same time, register the start script in /etc/rc.local.

Jupyter operation check

Log in from your browser and see 42 in TensorFlow Hello, World Sample OK

import tensorflow as tf

hello = tf.constant("Hello, TensorFlow!")
sess = tf.Session()
print(sess.run(hello))

a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))

Recommended Posts

Build a TensorFlow development environment on Amazon EC2 with command copy and paste
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Tensorflow environment with Raspberry Pi [2020]
Build a Python environment on your Mac with Anaconda and PyCharm
[Linux] Build a Docker environment with Amazon Linux 2
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Build a C language development environment with a container
Build a WardPress environment on AWS with pulumi
Build a python environment with ansible on centos6
[Python] Build a Django development environment with Docker
Build a Python development environment on your Mac
Build a virtual environment with pyenv and venv
Build a Django development environment with Doker Toolbox
Build a Kubernetes environment for development on Ubuntu
Build a Python development environment on Raspberry Pi
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Build a flask app made with tensorflow and dlib to work on centos7
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a local development environment for Laravel6.X on Mac
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build a machine learning application development environment with Python
Build a python virtual environment with virtualenv and virtualenvwrapper
How to build a development environment for TensorFlow (1.0.0) (Mac)
Build a development environment with Poetry Django Docker Pycharm
How to build a Python environment on amazon linux 2
Build a numerical calculation environment with pyenv and miniconda3
Steps to quickly create a deep learning environment on Mac with TensorFlow and OpenCV
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Build a Go development environment with VS Code's Remote Containers
[Django] Build a Django container (Docker) development environment quickly with PyCharm
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
How to build a python2.7 series development environment with Vagrant
Build a python3 environment on CentOS7
Build a Selenium environment on Amazon Linux 2 in the shortest time
# 3 Build a Python (Django) environment on AWS EC2 instance (ubuntu18.04) part2
Create an AWS Cloud9 development environment on your Amazon EC2 instance
Building a development environment with Maven on Google App Engine [Java]
Create a simple Python development environment with VS Code and Docker
Building a Python3 environment with Amazon Linux2
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
Build Python3 and OpenCV environment on Ubuntu 18.04
Build a python environment on MacOS (Catallina)
A memo with Python2.7 and Python3 on CentOS
Build a Fast API environment with docker-compose
Build an LNPP environment on Amazon Linux 2
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Build Python environment with Anaconda on Mac
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
[Linux] Build a jenkins environment with Docker
I built a TensorFlow environment on windows10
Build a python virtual environment with pyenv
Build a Python + OpenCV environment on Cloud9
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
I tried to build a Mac Python development environment with pythonz + direnv
Build a drone simulator environment and try a simple flight with Mission Planner
Build a modern Python environment with Neovim
Build Linux on a Windows environment. Steps to install Laradock and migrate
I made a webAPI! Build environment from Django Rest Framework 1 on EC2