0% found this document useful (0 votes)
27 views3 pages

Deep Learning Development Environment Construction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Deep Learning Development Environment Construction

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

11/8/23, 11:17 AM Deep Learning development environment construction [Internal Event Wiki]

Internal ComCom Wiki RPP Wiki Internal Event Wiki Robotics Tips Wiki Tsukuba Challenge Wiki

present location / / study group / Deep Learning Study Group / Deep Learning development environment construction

[[ study:deeplearning:install ]]

Deep Learning development environment construction


# 2017-05-08 UMA

Build the environment using pyenv and Anaconda.


By building a new Python environment without having to modify the originally installed Python environment, even if the environment breaks down, it
will be easy to rebuild it.
The original Python environment may be tied to ROS, so there is a reason why we cannot destroy this environment. No, NewPC.

Please note that the following assumptions are made when building the environment.
- Using Roboken's PC
- Runs only in CPU mode

pyenv
This is a tool that allows you to easily switch which Python to use.

The following is how to build an environment on ubuntu. You can also do this on a Mac, but you can find a lot of information about the Mac version by
googling it.

Type the following command to install pyenv and set environment variables.

$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv


$ git clone https://github.com/yyuu/pyenv-pip-rehash.git ~/.pyenv/plugins/pyenv-pip-rehash
$ export PYENV_ROOT=$HOME/.pyenv
$ export PATH=$PYENV_ROOT/bin:$PATH
$ eval "$(pyenv init -)"

Now, when you type pyenv on the terminal, pyenv will start.

Let's actually type the following command.

$pyenv

It's OK if the output looks like the one below!

pyenv 1.0.10
Usage: pyenv <command> [<args>]
Some useful pyenv commands are:
commands List all available pyenv commands
local Set or show the local application-specific Python version
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install a Python version using python-build
uninstall a specific Python version
rehash Rehash pyenv shims (run this after installing executables)
version Show the current Python version and its origin
versions List all Python versions available to pyenv
which Display the full path to an executable
whence List all Python versions that contain the given executable
See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme

By the way, the following version will display a list of the python versions installed on your PC.

$ pyenv versions

The version marked with an asterisk (*) in the displayed list is the currently selected version.

Anaconda
Anaconda is an excellent tool that not only builds a Python environment but also downloads commonly used modules.

Although it covers most of the tools we might need, such as the matrix calculation library numpy, the scientific calculation (optimization calculation,
etc.) library scipy, the graph drawing library matplotlib, the machine learning library scikit-learn, etc. It is no exaggeration.

Type the following command. Then, the latest Anaconda (Python3 series) version will appear.

$ pyenv install -l | grep anaconda3

Below is the expected output

https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 1/3
11/8/23, 11:17 AM Deep Learning development environment construction [Internal Event Wiki]

anaconda3-2.0.0
anaconda3-2.0.1
anaconda3-2.1.0
anaconda3-2.2.0
anaconda3-2.3.0
anaconda3-2.4.0
anaconda3-2.4.1
anaconda3-2.5.0
anaconda3-4.0.0
anaconda3-4.1.0
anaconda3-4.1.1
anaconda3-4.2.0
anaconda3-4.3.0
anaconda3-4.3.1

This is output on a Mac, so the version may be different. For now, download the latest version. Answer yes to all yes/no questions.

$ pyenv install anaconda3-(latest version number)


$ pyenv global anaconda3-(latest version number)
$ source activate
$ echo 'export PATH="$PYENV_ROOT/versions/anaconda3(latest version number)-4.1.0/bin:$PATH"' >> ~/.bashrc

If this does not work, please contact UMA. I only vaguely remember, so I may have forgotten something.

Maybe the terminal disappears for some reason. Please try starting it again without worrying.

$ python --version

If you type and the Python version and Anaconda version are displayed, it is working without any problems. By the way, if you want to return to the
original Python environment,

$ source deactivate

If you type, it will return.

By the way, if your Python version is 3.5.x, you can proceed to the next installation of opencv, but as of April 2017, opencv3 cannot be installed with
Python3.6.x. As I remember, if you have 3.6.x installed, you must install 3.5 series. in this case,

$ conda create -n py35 python=3.5 anaconda

Type , build a 3.5 environment,

$ source activate py35

By typing, you can enter the 3.5 environment that you have created.

Next, install opencv3 to call OpenCV from python. Installing opencv is also easy. Answer yes to all yes/no questions.

$ conda install -c https://conda.anaconda.org/menpo opencv3

Now you can enter freely. Let's check it first. Enter the following command to enter the interactive environment.

$python
>> import cv2
>> import numpy
>> import scipy
>> import matplotlib

If you try importing a well-known module and don't get scolded, there is no problem. If you get scolded, it's a little weird, so please talk to me. (I don't
think I've done anything bad)

The final phase is to download the Deep Learning tools.

$ pip install tensorflow==1.0


$ pip install keras==1.2.2

The installation should be successful with the above command on your Roboken PC.
The operation was confirmed using the code below. (However, the environment is Ubuntu14)
http://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/sample_code (http://www.roboken.iit.tsukuba.ac.jp/internal/event-
wiki/study/deeplearning/sample_code)

I'll check it out.

$python
>> import tensorflow
>> import keras
>> from keras import backend
(Output:) using Theano backend

Initially Theano should be selected as the backend. Theano is a deep learning tool created by the University of Montreal, and tensorflow is a tool
created by Google. Keras serves as an interface to make these tools easier to use. Keras is also called a wrapper library. As the name suggests, it
wraps Theano and tensorflow.

https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 2/3
11/8/23, 11:17 AM Deep Learning development environment construction [Internal Event Wiki]
This time I would like to select tensorflow as the backend. This is because Google created it and actually uses it, so its quality is guaranteed.

$ vim $HOME/.keras/keras.json

Use the above command to slightly rewrite the keras configuration file. There should be no problem if you change it as follows.

{
"image_dim_ordering": "tf",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}

image_dim_ordering specifies how the data is represented. This is a source of trouble, and many people still suffer from this difference in settings.

When set to “tf”, it is interpreted that the image dataset is treated as (number of data, image height, image width, number of image channels).
Setting "th" means that the image dataset is treated as (number of data, number of image channels, image height, image width).

If you actually set it to "th" but run a program that assumes "tf", keras will throw an error. This takes up a lot of your valuable time. It was stolen.
Everyone please be careful.

By setting the backend to “tensorflow”, you are expressing your intention to use tensorflow.

$python
>> from keras import backend
(Output:) using Tensorflow backend

If so, consider that the settings change was successful.

The settings are now complete. All you have to do now is write a suitable learning program in python and run it.

References
pyenv and Anaconda installation on ubuntu16.04
http://blog.algolab.jp/post/2016/08/21/pyenv-anaconda-ubuntu/ (http://blog.algolab.jp/post/2016/08/21/pyenv-anaconda-ubuntu/)

Python environment construction


http://qiita.com/shizuma/items/027167c6257f1c9d2a6f (http://qiita.com/shizuma/items/027167c6257f1c9d2a6f)

study/deeplearning/install.txt Last updated: 2017/11/29 14:49 by127.0.0.1

Internal Event Wiki

Unless otherwise stated, content on this Wiki is subject to the following license:
CC Attribution-Share Alike 4.0 International

https://www.roboken.iit.tsukuba.ac.jp/internal/event-wiki/study/deeplearning/install 3/3

You might also like