How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS with anaconda

Introduction

I wrote a similar article before, but it was easier with pyenv, so I will reorganize the procedure. By the way, depending on the environment, some people may not be able to use pyenv or do not want to use it. In such a case, please refer to the following URL.

http://qiita.com/mix_dvd/items/7d2f11fa090cf39a5b31

Ubuntu Server installation

Download the iso file from the following URL and install it because it does not matter whether it is a real machine or a virtual environment.

http://www.ubuntu.com/download/server

For the detailed procedure, please refer to the site that explained the details.

http://webkaru.net/linux/ubuntu-14-04-lts-install/

Login as initial user

Log in as the initial user created during installation.

Hit the command earnestly!

The following is the procedure for using the environment only with the logged-in user.

Environmental preparation

The following commands are not required to run Jupyter Notebook itself, but you may get an error when installing or running the library, so install them in advance.

$ sudo apt install -y build-essential
$ sudo apt install -y libsm6
$ sudo apt install -y libxrender1

When you run the first command, if you are prompted for a password, enter the password you use to log in.

Install pyenv

https://github.com/yyuu/pyenv

pyenv is a tool for installing multiple versions of Python in one environment.

$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ source ~/.bashrc

By the way, to update pyenv, use the following command.

$ cd ~/.pyenv
$ git pull

Installation of Anaconda

https://www.continuum.io/why-anaconda

Version confirmation

Check the version of Anaconda that can be installed.

$ pyenv install -l | grep anaconda

As of June 10, 2016, the latest version was 4.0.0. Since there are many differences between version 2.x and version 3.x of Python, please select one of the following according to your environment. Unless otherwise specified, I think you can choose the 3.x series.

Python 2 series

$ pyenv install anaconda2-4.0.0
$ pyenv rehash
$ pyenv global anaconda2-4.0.0
$ echo 'export PATH="$PYENV_ROOT/versions/anaconda2-4.0.0/bin/:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Python 3 series

$ pyenv install anaconda3-4.0.0
$ pyenv rehash
$ pyenv global anaconda3-4.0.0
$ echo 'export PATH="$PYENV_ROOT/versions/anaconda3-4.0.0/bin/:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

By the way, it seems that the following message may appear depending on the environment.

$ pyenv install anaconda3-4.2.0 
Downloading Anaconda3-4.2.0-Linux-x86.sh...
-> https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86.sh
error: failed to download Anaconda3-4.2.0-Linux-x86.sh

BUILD FAILED (Ubuntu 16.04 using python-build 1.0.7-1-g99d1670)

The solution is as follows.

$ sudo apt-get install ca-certificates
$ sudo mkdir -p /etc/pki/tls/certs
$ sudo cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt

After executing the above, install Anaconda with pyenv.

Additional libraries

Seaborn

Headquarters site https://web.stanford.edu/~mwaskom/software/seaborn/

$ pip install seaborn

XGBoost

Headquarters site https://xgboost.readthedocs.io/

Reference URL https://xgboost.readthedocs.io/en/latest/build.html#python-package-installation

$ git clone --recursive https://github.com/dmlc/xgboost
$ cd xgboost
$ make -j4
$ cd python-package
$ python setup.py install

I can install it with pip, but even if I could install it, an error sometimes occurred at runtime, so the procedure for installing by compiling from the source code is shown.

TensorFlow (64bit version only)

Reference URL https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#pip-installation

Python 2

Ubuntu/Linux 64-bit, CPU only, Python 2.7

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0rc0-cp27-none-linux_x86_64.whl
$ sudo pip install --upgrade $TF_BINARY_URL

Python 3

Ubuntu/Linux 64-bit, CPU only, Python 3.5

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0rc0-cp35-cp35m-linux_x86_64.whl
$ sudo pip3 install --upgrade $TF_BINARY_URL

Jupyter Notebook

Headquarters site http://jupyter.org

Setting

$ cd
$ jupyter notebook --generate-config
$ echo "c.NotebookApp.ip = '*'" >> ~/.jupyter/jupyter_notebook_config.py
$ echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/jupyter_notebook_config.py
$ echo "c.NotebookApp.port = 8888" >> ~/.jupyter/jupyter_notebook_config.py

Start-up

Execute the following command in the home directory of the initial user.

$ jupyter notebook

Operation check

If it seems to work, start a web browser on another machine and access the following URL.

http://xxx.xxx.xxx.xxx:8888

Please replace "xxx.xxx.xxx.xxx" with the IP address of the Ubuntu machine.

When the Jupyter Notebook page is displayed, OK!

Postscript (2016.7.11)

Japanese may not be displayed when drawing a graph with matplotlib, so please refer to the corresponding procedure as well.

http://qiita.com/mix_dvd/items/1c192bd8c852c4aaa413

Postscript (2016.7.25)

There is a desire to easily retrieve the files saved in the home directory, so I will add the procedure to make it accessible from other PCs using Samba.

First, install Samba.

$ sudo apt install -y samba
$ sudo pdbedit -a [Login user name]
new password: [Any password]
retype new password: [Any password]

Next is editing the configuration file.

$ sudo vi /etc/samba/smb.conf

Search for the following parts and correct the parts that are commented out or have different contents.

smb.conf


[homes]
  comment = %U's Home directory
  browseable = Yes
  read only = No
  writable = Yes

Restart Samba.

$ sudo systemctl restart smbd nmbd

that's all.

Recommended Posts

How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS with anaconda
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS
How to quickly create a machine learning environment using Jupyter Notebook on macOS Sierra with anaconda
How to create a serverless machine learning API with AWS Lambda
How to build Anaconda virtual environment used in Azure Machine Learning and link with Jupyter
How to quickly create a morphological analysis environment using Elasticsearch on macOS Sierra
Create a machine learning environment from scratch with Winsows 10
How to set up a Google Colab environment with Coursera's advanced machine learning courses
Steps to quickly create a deep learning environment on Mac with TensorFlow and OpenCV
Machine learning with Jupyter Notebook in OCI Always Free environment (2019/12/17)
I want to use a virtual environment with jupyter notebook!
How to batch start a python program created with Jupyter notebook
How about Anaconda for building a machine learning environment in Python?
I wanted to create a smart presentation with Jupyter Notebook + nbpresent
How to use jupyter notebook without polluting your environment with Docker
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Create an arbitrary machine learning environment with GCP + Docker + Jupyter Lab
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
[Python] Create a virtual environment with Anaconda
How to use jupyter notebook with ABCI
How to debug with Jupyter or iPython Notebook
How to create a Python virtual environment (venv)
Try using conda virtual environment with Jupyter Notebook
[Note] How to create a Ruby development environment
How to create a multi-platform app with kivy
Try using Jupyter Notebook of Azure Machine Learning
[Note] How to create a Mac development environment
Build a Python machine learning environment with a container
Install and set Jupyter Notebook to create a study note creation environment [Mac]
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
How to create a face image data set used in machine learning (1: Acquire candidate images using WebAPI service)
Easy Machine Learning with AutoAI (Part 4) Jupyter Notebook Edition
How to set up a Python environment using pyenv
How to create a submenu with the [Blender] plugin
Create a virtual environment with Anaconda installed via Pyenv
How to hold a hands-on seminar using Jupyter using docker
Build a machine learning application development environment with Python
[Python] How to create a 2D histogram with Matplotlib
Create a Japanese OCR environment with Anaconda (tesseract + pyocr)
Memo for building a machine learning environment using Python
I tried to create a reinforcement learning environment for Othello with Open AI gym
You don't need to install Anaconda to build a machine learning environment. Let's use Miniconda
Until you create a machine learning environment with Python on Windows 7 and run it
Using Graphviz with Jupyter Notebook
How to import NoteBook as a module in Jupyter (IPython)
Build a machine learning scikit-learn environment with VirtualBox and Ubuntu
Building a Jupyter Lab development environment on WSL2 using Anaconda3
Create a machine learning app with ABEJA Platform + LINE Bot
I want to start a jupyter environment with one command
How to interactively draw a machine learning pipeline with scikit-learn and save it in HTML
How to create a flow mesh around a cylinder with snappyHexMesh
Launching a machine learning environment using Google Compute Engine (GCE)
Build a machine learning environment
How to build a python2.7 series development environment with Vagrant
Create a python machine learning model relearning mechanism with mlflow
The usual way to add a Kernel with Jupyter Notebook
Building a pyhon environment without using Anaconda (with easy startup)
How to import NoteBook as a module in Jupyter (IPython)
How to use Jupyter Notebook
I wrote a script to create a Twitter Bot development environment quickly with AWS Lambda + Python 2.7
Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-