HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2018/08/15

Raspberry Piで Deep Learningフレームワーク Chainerをインストールしてみる Raspberry Piで Deep Learningフレームワーク Chainerをインストールしてみる

(ラズパイに Deep Learningのフレームワーク Chainerを入れてみた)

Tags: [Raspberry Pi], [電子工作], [ディープラーニング]





● Raspberry Piで Deep Learningのフレームワーク Chainerを動かす方法

 Chainer - A flexible framework of neural networks
 Chainer is a powerful, flexible and intuitive deep learning framework.

2015-06-09 Deep Learning のフレームワーク Chainer を公開しました

Chainer - A flexible framework for neural networks
chainer/chainer - A flexible framework of neural networks for deep learning
Docs - Chainer


●今回動かした Raspberry Pi Raspbian OSのバージョン

 RASPBIAN STRETCH WITH DESKTOP
 Version:June 2018
 Release date: 2018-06-27
 Kernel version: 4.14
pi@raspberrypi:~/pytorch $ uname -a
Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l GNU/Linux


● Raspberry Piで Chainerを pipコマンドでインストールする。

chainer/chainer
 A flexible framework of neural networks for deep learning
 Stable version v4

 Chainerのインストール方法は Docsに記載が有ります。
Chainer - Installation

# お決まりの sudo apt-get updateで最新状態に更新する
sudo apt-get update

# recommend you to upgrade setuptools and pip
# pip install -U setuptools pip
# Successfully installed pip-18.0 setuptools-40.0.0

# pip install -U pip
# を実行すると pipコマンドが壊れるので実行しない事
# pi@raspberrypi:~ $ pip
# Traceback (most recent call last):
#   File "/usr/bin/pip", line 9, in <module>
#     from pip import main
# ImportError: cannot import name main
# この「バグ」に関しての詳細な解説記事
# 2018-04-17 pip install --upgrade pip (10.0.0) 後の奇妙な挙動について
# http://icchy.hatenablog.jp/entry/2018/04/17/064443

# pi@raspberrypi:~ $ sudo apt-get install python-setuptools
# python-setuptools is already the newest version (33.1.1-1).
# 0 upgraded, 0 newly installed, 0 to remove and 61 not upgraded.
# pi@raspberrypi:~ $ sudo apt-get install python-pip
# python-pip is already the newest version (9.0.1-2+rpt2).
# 0 upgraded, 0 newly installed, 0 to remove and 61 not upgraded.

# setuptoolsも既に存在しているので pipではインストールしない
# pip install -U setuptools
# Successfully installed setuptools-40.0.0

# Pillowで必要なのでインストールする
sudo apt-get install libjpeg-dev
# Setting up libjpeg-dev (1:1.5.1-2) ...
# sudo apt-get install zlib1g-dev

# Optional Features
# Image dataset support
# pillow 2.3+
# https://pillow.readthedocs.io/en/latest/installation.html
pip install Pillow
# Successfully installed Pillow-5.2.0

# HDF5 serialization support
# https://pypi.org/project/h5py/
# h5py 2.5+
# pip install h5py
# Exception: TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
# h5py installation failed
# sudo apt-get install libhdf5-dev
# pip install h5pyは失敗するので apt-getで libhdf5をインストールする
sudo apt-get -y install libhdf5-serial-dev

# Installation
# Install Chainer
# Using pip
pip install chainer
#  Could not find a version that satisfies the requirement chainer (from versions: )
# No matching distribution found for chainer

# chainerのバージョンがどうたらのエラーが出ているのでバージョンを指定してインストールする
# まず chainerのバージョンは何が存在するのかを調べる
# pipコマンドでありえないバージョンを指定すると存在するバージョンの一覧が出てくるのでそれを利用する)
# pi@raspberrypi:~/Chainer $ pip install chainer==000
# Collecting chainer==000
#   Could not find a version that satisfies the requirement chainer==000 (from versions: 1.6.2.linux-x86_64, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.5.0, 1.5.0.1, 1.5.0.2, 1.5.0.3, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.6.2.1, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.10.0, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.15.0, 1.15.0.1, 1.16.0, 1.17.0, 1.18.0, 1.19.0, 1.20.0, 1.20.0.1, 1.21.0, 1.22.0, 1.23.0, 1.24.0, 2.0.0a1, 2.0.0b1, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 3.0.0a1, 3.0.0b1, 3.0.0rc1, 3.0.0, 3.1.0, 3.2.0, 3.3.0, 3.4.0, 3.5.0, 4.0.0a1, 4.0.0b1, 4.0.0b2, 4.0.0b3, 4.0.0b4, 4.0.0rc1, 4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.3.1, 5.0.0a1, 5.0.0b1, 5.0.0b2, 5.0.0b3)
# No matching distribution found for chainer==000

# pip install chainer==1.24.0
# pip install chainer==2.1.0
# pip install chainer==3.5.0
# とりあえずメジャーバージョンが一つ手前の最終版の 4.3.1をインストールする
pip install chainer==4.3.1
Successfully installed chainer-4.3.1 filelock-3.0.4 numpy-1.15.0 protobuf-3.6.1 setuptools-40.0.0 six-1.11.0

# pip install chainer==4.3.1でインストールできた
# Using Git(未確認)
cd
mkdir Chainer
cd Chainer
git clone https://github.com/chainer/chainer.git
cd chainer
pip install .
# Chainerの動作確認
pi@raspberrypi:~/Chainer $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import chainer
>>> print (chainer.__version__)
4.3.1
>>> quit()


● Chainer - Neural Net Examples

Chainer - Neural Net Examples

# Chainerの動作確認
cd
mkdir Chainer
cd Chainer
git clone https://github.com/chainer/chainer.git
cd chainer

# Multi-Layer Perceptron for MNIST Classification
cd examples/mnist/
python train_mnist.py

# ---
# Word Embedding
cd examples/word2vec/
python train_word2vec.py

pi@raspberrypi:~/Chainer/chainer/examples/mnist $ python train_mnist.py
GPU: -1
# unit: 1000
# Minibatch-size: 100
# epoch: 20
Downloading from http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz...

pi@raspberrypi:~/Chainer/chainer/examples/word2vec $ python train_word2vec.py
GPU: -1
# unit: 100
Window: 5
Minibatch-size: 1000
# epoch: 20
Training model: skipgram
Output type: hsm

Downloading from https://raw.githubusercontent.com/wojzaremba/lstm/master/data/ptb.train.txt...
Downloading from https://raw.githubusercontent.com/wojzaremba/lstm/master/data/ptb.valid.txt...
Downloading from https://raw.githubusercontent.com/wojzaremba/lstm/master/data/ptb.test.txt...
n_vocab: 10000
data length: 929589
epoch       main/loss   validation/main/loss


● ChainerCV

ChainerCV - a Library for Deep Learning in Computer Vision



Tags: [Raspberry Pi], [電子工作], [ディープラーニング]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

NVIDIA Jetson Nano 開発者キットを買ってみた。メモリ容量 4GB LPDDR4 RAM
NVIDIA Jetson Nano 開発者キットを買ってみた。メモリ容量 4GB LPDDR4 RAM

  Jetson Nanoで TensorFlow PyTorch Caffe/Caffe2 Keras MXNet等を GPUパワーで超高速で動かす!

Raspberry Piでメモリを馬鹿食いするアプリ用に不要なサービスを停止してフリーメモリを増やす方法
Raspberry Piでメモリを馬鹿食いするアプリ用に不要なサービスを停止してフリーメモリを増やす方法

  ラズパイでメモリを沢山使用するビルドやアプリ用に不要なサービス等を停止して使えるメインメモリを増やす

【成功版】最新版の Darknetに digitalbrain79版の Darknet with NNPACKの NNPACK処理を適用する
【成功版】最新版の Darknetに digitalbrain79版の Darknet with NNPACKの NNPACK処理を適用する

  ラズパイで NNPACK対応の最新版の Darknetを動かして超高速で物体検出や DeepDreamの悪夢を見る

【成功版】Raspberry Piで NNPACK対応版の Darknet Neural Network Frameworkをビルドする方法
【成功版】Raspberry Piで NNPACK対応版の Darknet Neural Network Frameworkをビルドする方法

  ラズパイに Darknet NNPACK darknet-nnpackをソースからビルドして物体検出を行なう方法

【成功版】Raspberry Piで Darknet Neural Network Frameworkをビルドする方法
【成功版】Raspberry Piで Darknet Neural Network Frameworkをビルドする方法

  ラズパイに Darknet Neural Network Frameworkを入れて物体検出や悪夢のグロ画像を生成する

【成功版】Raspberry Piに TensorFlow Deep Learning Frameworkをインストールする方法
【成功版】Raspberry Piに TensorFlow Deep Learning Frameworkをインストールする方法

  ラズパイに TensorFlow Deep Learning Frameworkを入れて Google DeepDreamで悪夢を見る方法

Raspberry Piで TensorFlow Deep Learning Frameworkを自己ビルドする方法
Raspberry Piで TensorFlow Deep Learning Frameworkを自己ビルドする方法

  ラズパイで TensorFlow Deep Learning Frameworkを自己ビルドする方法

Raspberry Piで Caffe Deep Learning Frameworkで物体認識を行なってみるテスト
Raspberry Piで Caffe Deep Learning Frameworkで物体認識を行なってみるテスト

  ラズパイで Caffe Deep Learning Frameworkを動かして物体認識を行なってみる

【ビルド版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning Framework
【ビルド版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning Framework

  ラズパイで Caffe Deep Learning Frameworkをビルドして Deep Dreamを動かしてキモイ絵を生成する

【インストール版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning
【インストール版】Raspberry Piで DeepDreamを動かしてキモイ絵をモリモリ量産 Caffe Deep Learning

  ラズパイで Caffe Deep Learning Frameworkをインストールして Deep Dreamを動かしてキモイ絵を生成する

Raspberry Piで Caffe2 Deep Learning Frameworkをソースコードからビルドする方法
Raspberry Piで Caffe2 Deep Learning Frameworkをソースコードからビルドする方法

  ラズパイで Caffe 2 Deep Learning Frameworkをソースコードから自己ビルドする方法

Orange Pi PC 2の 64bitのチカラで DeepDreamしてキモイ絵を高速でモリモリ量産してみるテスト
Orange Pi PC 2の 64bitのチカラで DeepDreamしてキモイ絵を高速でモリモリ量産してみるテスト

  OrangePi PC2に Caffe Deep Learning Frameworkをビルドして Deep Dreamを動かしてキモイ絵を生成する

Raspberry Piに Jupyter Notebookをインストールして拡張子 ipynb形式の IPythonを動かす
Raspberry Piに Jupyter Notebookをインストールして拡張子 ipynb形式の IPythonを動かす

  ラズパイに IPython Notebookをインストールして Google DeepDream dream.ipynbを動かす

Raspberry Piで DeepBeliefSDKをビルドして画像認識フレームワークを動かす方法
Raspberry Piで DeepBeliefSDKをビルドして画像認識フレームワークを動かす方法

  ラズパイに DeepBeliefSDKを入れて画像の物体認識を行なう

Raspberry Piで Microsoftの ELLをビルドする方法
Raspberry Piで Microsoftの ELLをビルドする方法

  ラズパイで Microsoftの ELL Embedded Learning Libraryをビルドしてみるテスト、ビルドするだけ

Raspberry Piで MXNet port of SSD Single Shot MultiBoxを動かして画像の物体検出をする方法
Raspberry Piで MXNet port of SSD Single Shot MultiBoxを動かして画像の物体検出をする方法

  ラズパイで MXNet port of SSD Single Shot MultiBox Object Detectorで物体検出を行なってみる

Raspberry Piで Apache MXNet Incubatingをビルドする方法
Raspberry Piで Apache MXNet Incubatingをビルドする方法

  ラズパイで Apache MXNet Incubatingをビルドしてみるテスト、ビルドするだけ

Raspberry Piで OpenCVの Haar Cascade Object Detectionでリアルタイムにカメラ映像の顔検出を行なってみる
Raspberry Piで OpenCVの Haar Cascade Object Detectionでリアルタイムにカメラ映像の顔検出を行なってみる

  ラズパイで OpenCVの Haar Cascade Object Detection Face & Eyeでリアルタイムでカメラ映像の顔検出をする方法

Raspberry Piで NNPACKをビルドする方法
Raspberry Piで NNPACKをビルドする方法

  ラズパイで NNPACKをビルドしてみるテスト、ビルドするだけ

Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ

  ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も




[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2018 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_install_chainer_flexible_framework_neural_networks/