본문 바로가기
...

Raspberry PI Tensorflow 설치

by GGoris 2018. 4. 13.
반응형

라즈베리파이 텐서플로우 설치


라즈베리파이 1 B

메모리 8GB

OS RASPBIAN STRETCH

Python3.5.3


라즈베리파이 2 B

메모리 64GB

OS RASPBIAN STRETCH

Python3.5.3



파이썬 설치


sudo apt-get update


sudo apt-get install python3.5


sudo apt-get install python3-pip




* 라즈베리파이 모델 확인

https://blog.ayukawa.kr/archives/1735

cat /proc/cpuinfo로 cpu정보를 확인


pi2b


pi1b




모델에 맞는 텐서플로우 다운로드


아래의 링크에서 적절한 파일을 다운로드 합니다.

https://github.com/lhelontra/tensorflow-on-arm/releases




라즈베리파이 1 B

tensorflow-1.8.0-cp35-none-linux_armv6l.whl


sudo pip3 install tensorflow-1.8.0-cp35-none-linux_arm6l.whl





라즈베리파이 2 B

tensorflow-1.8.0-cp35-none-linux_armv7l.whl


sudo pip3 install tensorflow-1.8.0-cp35-none-linux_arm7l.whl






numpy 빌드 오류시


https://www.raspberrypi.org/forums/viewtopic.php?t=203775

libatlas3-base 설치


sudo apt-get install libatlas3-base



예제 TEST

$ python3

Python 3.5.3 (default, Jan 19 2017, 14:11:04)

[GCC 6.3.0 20170124] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow as tf

>>>

>>> hello = tf.constant('Hello, TensorFlow!')

>>> sess = tf.Session()

>>> print(sess.run(hello))

b'Hello, TensorFlow!'

>>> a = tf.constant(10)

>>> b = tf.constant(94)

>>> print(sess.run(a + b))

104

>>>








sudo apt-get install pkg-config zip g++ zlib1g-dev unziphttps://m.blog.naver.com/PostView.nhn?blogId=chandong83&logNo=221118855572&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F



https://blog.naver.com/chandong83/221115327298


https://github.com/bazelbuild/bazel



https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md#2-install-a-memory-drive-as-swap-for-compiling


바젤 릴리즈

https://github.com/bazelbuild/bazel/releases


준비사항

스왑영역을 위한 1GB이상의 메모리


스왑영역 설정

sudo umount /dev/sda1

sudo mkswap



필수패키지설치

바젤

sudo apt-get install pkg-config zip g++ zlib1g-dev unzip


텐서플로우

sudo apt-get install python3-pip python3-numpy swig python3-dev

sudo pip3 install wheel

sudo pip3 uninstall mock

sudo pip3 install mock



바젤 다운로드

 wget https://github.com/bazelbuild/bazel/releases/download/0.12.0/bazel-0.12.0-dist.zip


압축해제

unzip bazel-0.12.0-dist.zip


스크립트 수정

vi scripts/bootstrap/compile.sh


run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \

      -d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \

      -encoding UTF-8 "@${paramfile}" 


뒤에 -J-Xmx500M 추가


run "${JAVAC}" -classpath "${classpath}" -sourcepath "${sourcepath}" \

      -d "${output}/classes" -source "$JAVA_VERSION" -target "$JAVA_VERSION" \

      -encoding UTF-8 "@${paramfile}" -J-Xmx500M


vi tools/cpp/cc_configure.bzl


빌드

sudo ./compile.ph


바이너리 복사

sudo cp output/bazel /usr/local/bin/bazel


설치 확인

$ bazel



텐서플로우 설치


git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git

cd tf

cd tensorflow

git checkout


설정

./configure


bazel build -c opt --copt="-mfpu=neon-vfpv4" --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package


바질을이용한 텐서플로우 빌드

 !! 몇시간 이상 걸릴수 있습니다.


bazel build -c opt --copt="-mfpu=neon-vfpv4" --copt="-funsafe-math-optimizations" --copt="-ftree-vectorize" --copt="-fomit-frame-pointer" --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package




https://github.com/samjabrahams/tensorflow-on-raspberry-pi

https://github.com/samjabrahams/tensorflow-on-raspberry-pi/blob/master/GUIDE.md

반응형

댓글