728x90

출처

pip3 설치

$ sudo apt update
$ sudo apt install gfortran libopenblas-dev liblapack-dev libhdf5-dev
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

파이썬 라이브러리 설치

$ sudo pip3 install setuptools wheel h5py

swap 사이즈 설정

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          432Mi       143Mi        48Mi        14Mi       241Mi       224Mi
Swap:          99Mi        99Mi       0.0Ki

swap 서비스 종료 (swap 설정 파일 수정을 위해서)

$ sudo /etc/init.d/dphys-swapfile stop
Stopping dphys-swapfile (via systemctl): dphys-swapfile.service.

swap 설정 파일 수정

$ sudo vi /etc/dphys-swapfile

# CONF_SWAPSIZE=100
CONF_SWAPSIZE=2048

swap 서비스 시작

$ sudo /etc/init.d/dphys-swapfile start
Starting dphys-swapfile (via systemctl): dphys-swapfile.service.

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          432Mi       220Mi        40Mi        32Mi       171Mi       128Mi
Swap:         2.0Gi          0B       2.0Gi

TensorFlow 2.1.0 패키지 설치

TensorFlow 2.1.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0.armv6l/tensorflow-2.1.0-cp37-none-linux_armv6l.whl

tensorflow 2.1.0 파이썬 페키지 설치

$ pip3 install tensorflow-2.1.0-cp37-none-linux_armv6l.whl
 
 ... 생략 ...
 
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.0.0 gast-0.2.2 google-auth-1.13.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.2.1 opt-einsum-3.2.0 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 rsa-4.0 scipy-1.4.1 tensorboard-2.1.1 tensorflow-2.1.0 tensorflow-estimator-2.1.0 termcolor-1.1.0 wrapt-1.12.1

버전 확인

$ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.1.0'
728x90
728x90

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7
 
Hardware        : BCM2835
Revision        : 9000c1
Serial          : 000000002a9067d9
Model           : Raspberry Pi Zero W Rev 1.1

커널에 대한 정보

$ uname -a
Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l GNU/Linux

OS버전에 대한 정보

$ cat /etc/issue
Raspbian GNU/Linux 10 \n \l

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
2

TensorFlow C, C++ 라이브러리 설치

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0.armv6l/libtensorflow.tar.gz

TensorFlow 라이브러리 설치

$ sudo tar -C /usr/local -xzf libtensorflow.tar.gz

Linker 설정

$ sudo ldconfig

예제 hello.c

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("TensorFlow C library version %s\n", TF_Version());
  return 0;
}

예제 컴파일

$ gcc hello.c -ltensorflow -o hello

예제 실행

$ ./hello
TensorFlow C library version 2.1.0
728x90
728x90

출처

swap 사이즈 설정

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           998M        125M        814M        544K         58M        849M
Swap:          499M        141M        357M
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram1                              partition       511416  145384  5
$ sudo swapoff /dev/zram1
$ sudo zramctl --reset /dev/zram1
$ sudo zramctl --find --size 2048M
/dev/zram1
$ sudo mkswap /dev/zram1
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=2b7262ae-3011-45d4-b3b5-c1d4eec0d5b6
$ sudo swapon /dev/zram1
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           998M        217M        706M        4.7M         75M        754M
Swap:          2.0G          0B        2.0G

Bazel 설치

출처 : トマト農家のロボット創り Robot creation by tomato farmer: Build Bazel(0.29.0) on Raspberry Pi 4

Bazel 다운로드 및 설치

$ mkdir bazel
$ cd bazel
$ wget https://github.com/bazelbuild/bazel/releases/download/0.29.1/bazel-0.29.1-dist.zip
$ unzip bazel-0.29.1-dist.zip
$ sudo env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" VERBOSE=yes BAZEL_JAVAC_OPTS="-J-Xms384m -J-Xmx1024m" bash ./compile.sh
$ sudo cp output/bazel /usr/local/bin/bazel

Tensorflow Lite 빌드

Tensorflow 소스 다운로드

$ wget https://github.com/tensorflow/tensorflow/archive/v2.1.0.tar.gz
$ tar -zxvf v2.1.0.tar.gz 
$ cd tensorflow-2.1.0/

Tensorflow Lite 빌드

$ sudo tensorflow/lite/tools/make/download_dependencies.sh
tensorflow/lite/tools/make/download_dependencies.sh: line 59: 1: Usage: download_and_extract URL DIR
$ sed -i "/^EIGEN_URL=/c\EIGEN_URL=\"\$(grep -o 'https://storage.googleapis.com/mirror.tensorflow.org/gitlab.com/libeigen/eigen/.*tar.gz' \"\${BZL_FILE_PATH}\")\"" tensorflow/lite/tools/make/download_dependencies.sh
$ sudo tensorflow/lite/tools/make/download_dependencies.sh
$ sudo tensorflow/lite/tools/make/build_lib.sh 
+ set -e
+++ dirname tensorflow/lite/tools/make/build_lib.sh
++ cd tensorflow/lite/tools/make
++ pwd
+ SCRIPT_DIR=/home/pi/tensorflow-2.1.0/tensorflow/lite/tools/make
+ TENSORFLOW_DIR=/home/pi/tensorflow-2.1.0/tensorflow/lite/tools/make/../../../..
+ make -j 4 BUILD_WITH_NNAPI=false -C /home/pi/tensorflow-2.1.0/tensorflow/lite/tools/make/../../../.. -f tensorflow/lite/tools/make/Makefile
make: Entering directory '/home/pi/tensorflow-2.1.0'
make: Nothing to be done for 'all'.
make: Leaving directory '/home/pi/tensorflow-2.1.0'

Tensorflow Lite C, C++ 예제 컴파일, 실행

$ cd tensorflow/lite/examples/minimal
$ ls
BUILD  minimal.cc
$ bazel build
Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=124
INFO: Reading rc options for 'build' from /home/pi/tensorflow-2.1.0/.bazelrc:
  'build' options: --apple_platform_type=macos --define framework_shared_object=true --define open_source_build=true --java_toolchain=//third_party/toolchains/java:tf_java_toolchain --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone --strategy=Genrule=standalone -c opt --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include --config=v2
INFO: Found applicable config definition build:v2 in file /home/pi/tensorflow-2.1.0/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
WARNING: Usage: bazel build  .
Invoke `bazel help build` for full description of usage and options.
Your request is correct, but requested an empty set of targets. Nothing will be built.
DEBUG: Rule 'io_bazel_rules_docker' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1556410077 -0400"
DEBUG: Call stack for the definition of repository 'io_bazel_rules_docker' which is a git_repository (rule definition at /home/pi/.cache/bazel/_bazel_pi/1e5f7ce23473dd292c5d0e986c50b880/external/bazel_tools/tools/build_defs/repo/git.bzl:195:18):
 - /home/pi/.cache/bazel/_bazel_pi/1e5f7ce23473dd292c5d0e986c50b880/external/bazel_toolchains/repositories/repositories.bzl:37:9
 - /home/pi/tensorflow-2.1.0/WORKSPACE:37:1
INFO: Analyzed 0 targets (0 packages loaded, 0 targets configured).
INFO: Found 0 targets...
INFO: Elapsed time: 47.550s, Critical Path: 0.13s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
$ ls
BUILD  minimal.cc
$ cd ../../tools/make/gen/linux_armv7l/bin/
$ ./minimal 
minimal <tflite model>

Tensorflow Lite 패키지 빌드, 설치

$ pip3 install /tmp/tflite_pip/python3/dist/tflite_runtime-2.1.0-cp37-cp37m-linux_armv7l.whl
Defaulting to user installation because normal site-packages is not writeable
Processing /tmp/tflite_pip/python3/dist/tflite_runtime-2.1.0-cp37-cp37m-linux_armv7l.whl
Requirement already satisfied: numpy>=1.12.1 in /usr/local/lib/python3.7/site-packages (from tflite-runtime==2.1.0) (1.18.2)
Installing collected packages: tflite-runtime
Successfully installed tflite-runtime-2.1.0
728x90
728x90

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 54.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
processor       : 1
BogoMIPS        : 54.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
processor       : 2
BogoMIPS        : 54.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
processor       : 3
BogoMIPS        : 54.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

instruction set architecture (ISA) 정보

$ uname -i
aarch64

커널에 대한 정보

$ uname -a
Linux bpi-iot-ros-ai 4.9.119-BPI-M4-Kernel #1 SMP PREEMPT Tue Apr 16 10:39:33 CST 2019 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

$ cat /etc/issue
Ubuntu 18.04.4 LTS \n \l

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

spirom 펌웨어 업데이트

2020년 5월 이전 생산된 모델의 경우 1GB 보드는 spirom 펌웨어를 업데이트해야 새로운 Linux 이미지 실행 가능

부팅로그 - 디버그 USB to UART로 Serial로 확인 - 1G가 모델에서 2G로 표시되는 오류

C1:80000000
C2
?_?
C3h
hwsetting size: 00000950
C4
f 
5-5
Goto FSBL: 0x80008000
Welcome to FSBL ....

REG32(VO_SW_SEC_1)=01C00000
[FSBL] Secure: 0x0000BEEE
[FSBL] DCache Enable: 0x00000000
[FSBL] SVP = N
********** FW_TYPE_BOOTCODE **********
    FW Image to 0x00100000, size=0x000841E0 (0x001841E0)
    FW Image fr 0x881313E8 
kmcp_bypass copy audio bin
FSBL: plat_gic_setup
FSBL: plat_gic_setup_percpu
FSBL Jumps to LK


U-Boot 2015.07 (May 27 2019 - 09:38:38 +0800)

CPU  : Cortex-A53 Quad Core - AARCH64
Board: Realtek QA Board
DRAM:  2 GiB
Watchdog: Disabled
mapping memory 0x20000000-0x40000000 non-cached
flushing dcache successfully.
nor flash id [0x00ef4018]
sector 256k en: 0

Flash the spirom

1. Prepare a bootable sdcard with bpi linux image flashed.
2. Connect debug serial cable to PC terminal.
3. Prepare a udisk with fat32 format, copy the right spirom firmware, spiloader-1GB.bin or spiloader-2GB.bin to udisk. Plug udisk to board.3.Press "Esc" and power on the board to enter uboot command mode.
4. Flash the firmware to board,

Net:   Realtek PCIe GBE Family Controller mcfg = 0024
dev->name=r8168#0
Checking default environment
Hit Esc or Tab key to enter console mode or rescue linux:  3 
------------can't find tmp/factory/recovery
------------finished reboot_action

Press Esc Key

Enter console mode, disable watchdog ...

BPI-M4> usb start
starting USB...
rtk_usb_power_on:213: Realtek-usb: UFP cc2 detect type_c have power (status=0x18)
USB0:   Register 1000140 NbrPorts 1
Starting the controller
USB XHCI 1.10
scanning bus 0 for devices... Unknown request , typeReq = 0x200c 
1 USB Device(s) found
USB1:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus 1 for devices... Unknown request , typeReq = 0x200c 
unknown Description Type : b
4 USB Device(s) found
       scanning usb for storage devices...  address 4
1 Storage Device(s) found
BPI-M4>
BPI-M4> fatload usb 0:1 0x01500000 spiloader-1GB.bin
reading spiloader-1GB.bin
761248 bytes read in 60 ms (12.1 MiB/s)
BPI-M4> go 0x01500000
Starting application at 0x01500000 ...
flash_type: SPI
begin: 

nor flash id [0x00EF4018]
      sector 256k en: 0x00000000
      sector  64k en: 0x00000001
      sector  32k en: 0x00000001
      sector   4k en: 0x00000001
      page_program  : 0x00000001
      max capacity  : 0x01000000
      spi type name : WINBOND_W325Q128BV_128Mbit
init
spi : erase 0x00200000 bytes from 0x88100000
////////////////////////////////
spi : write hw setting&signature, start=0x88130800, len=0x00000BE8
..
spi : write bootcode, start=0x881313E8, len=0x00080B80
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
spi : write bootcode signature, start=0x881B1F68, len=0x00000020

spi : write fsbl, start=0x881B1F88, len=0x00007A08
..............................
spi : write parameter, start=0x88130000, len=0x00000428
.exit
Finish
reset...
C1:80000000
C2
?_?
C3h
hwsetting size: 00000950

적용 확인

C4
f 
5-5
Goto FSBL: 0x80008000
Welcome to FSBL ....

REG32(VO_SW_SEC_1)=01C00000
[FSBL] Secure: 0x0000BEEE
[FSBL] DCache Enable: 0x00000000
[FSBL] SVP = N
********** FW_TYPE_BOOTCODE **********
    FW Image to 0x00100000, size=0x00080BA0 (0x00180BA0)
    FW Image fr 0x881313E8 
kmcp_bypass copy audio bin
FSBL: plat_gic_setup
FSBL: plat_gic_setup_percpu
FSBL Jumps to LK


U-Boot 2015.07 (May 13 2020 - 17:12:53 +0800)

CPU  : Cortex-A53 Quad Core - AARCH64
Board: Realtek QA Board
DRAM:  1 GiB
Watchdog: Disabled

SD 확장

SD 확장전 용량확인

$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              269344       0    269344   0% /dev
tmpfs              58016    1752     56264   4% /run
/dev/mmcblk0p2   6993924 5948764    673500  90% /
tmpfs             290076       0    290076   0% /dev/shm
tmpfs               5120       4      5116   1% /run/lock
tmpfs             290076       0    290076   0% /sys/fs/cgroup
tmpfs             290076       4    290072   1% /tmp
tmpfs              58012      24     57988   1% /run/user/1000
overlaid           58012      24     57988   1% /run/user/1000/pi-chromium
/dev/mmcblk0p1    258095  103390    154706  41% /media/pi/BPI-BOOT

SD FDisk

pi@bpi-iot-ros-ai:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4ca45e69

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1      204800   729087   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      729088 14940159 14211072  6.8G 83 Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-62333951, default 2048): 729088
Last sector, +sectors or +size{K,M,G,T,P} (729088-62333951, default 62333951): 

Created a new partition 2 of type 'Linux' and of size 29.4 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): w
The partition table has been altered.
Syncing disks.

pi@bpi-iot-ros-ai:~$ sudo shutdown -r now

SD 확장

$ sudo resize2fs /dev/mmcblk0p2
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p2 is now 7700608 (4k) blocks long.

SD 확장 확인

$ df -l
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              269344       0    269344   0% /dev
tmpfs              58016    1740     56276   3% /run
/dev/mmcblk0p2  30323692 5966332  23041984  21% /
tmpfs             290076       0    290076   0% /dev/shm
tmpfs               5120       4      5116   1% /run/lock
tmpfs             290076       0    290076   0% /sys/fs/cgroup
tmpfs             290076       4    290072   1% /tmp
tmpfs              58012      16     57996   1% /run/user/1000
overlaid           58012      16     57996   1% /run/user/1000/pi-chromium
/dev/mmcblk0p1    258095  103390    154706  41% /media/pi/BPI-BOOT

eMMC에 OS 설치

$ sudo apt install pv
$ curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
$ sudo bpi-copy 2020-05-18-ubuntu-18.04-mate-desktop-bpi-m4-aarch64-sd-emmc.img
[sudo] password for pi: 
SRC=2020-05-18-ubuntu-18.04-mate-desktop-bpi-m4-aarch64-sd-emmc.img
DST=
COPYMODE=imagetodisk
imagetodisk
bpi-copy(v1.3.4(github)), bananapi image & disk tools
 
Usage: bpi-copy [OPTIONS]...
       bpi-copy [ --help | -v | --version ]
       bpi-copy IMGFILE
       bpi-copy IMGDIR
       bpi-copy IMGFILE DEVICE
       bpi-copy DEVICE IMGFILE
 
Warning: Try to write 2020-05-18-ubuntu-18.04-mate-desktop-bpi-m4-aarch64-sd-emmc.img to BOOTDISK /dev/mmcblk1
==============================================================
Sun May 31 21:35:03 CST 2020
*** start COPY (blue led on ) .....
INFO: /dev/mmcblk1 : SD/eMMC !!
umount device: /dev/mmcblk1
umount /dev/mmcblk1p1
umount /dev/mmcblk1p2
==============================================================
IMGFILE=2020-05-18-ubuntu-18.04-mate-desktop-bpi-m4-aarch64-sd-emmc.img
==============================================================
img
729+1 records in[10.5MiB/s] [                                            <=>          ]
729+1 records out
7650410496 bytes (7.7 GB, 7.1 GiB) copied, 563.151 s, 13.6 MB/s
7.12GiB 0:09:23 [13.0MiB/s] [                                           <=>           ]
0+58925 records in
0+58925 records out
***  end  COPY (blue led off) .....
Sun May 31 21:44:28 CST 2020
==============================================================
RUNTIME 9:25
OK!! You can remove the BOOTDISK /dev/mmcblk1 now!!

jdk 1.8 설치

$ sudo apt install openjdk-8-jdk

도커삭제 (옵션)

$ sudo apt remove docker-ce

LibreOffice 제거 (옵션)

$ sudo apt remove --purge libreoffice-core libreoffice-common
$ sudo apt autoremove

Thunderbird 제거 (옵션)

$ sudo apt remove --auto-remove thunderbird

Python 3.6 제거 (옵션)

Python 3 설치된 패키지 확인

$ aptitude search '~i' | grep python

Python 3.6 제거

$ sudo apt remove python3 python3-minimal python3.6 python3.6-minimal libpython3.6 libpython3.6-minimal
$ sudo apt autoremove

Python 3.6 제거후 키보드, 마우스가 동작하지 않는 경우 설치

$ sudo apt install xserver-xorg-input-all
728x90
728x90

출처

pip3 설치

$ sudo apt update
$ sudo apt install gfortran libopenblas-dev liblapack-dev libhdf5-dev
$ pip3 --version
pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

파이썬 라이브러리 설치

$ sudo pip3 install setuptools wheel
$ sudo pip3 install h5py

swap 사이즈 설정

현재 swap 사이즈 확인

$ free -h                      
              total        used        free      shared  buff/cache   available
Mem:           998M        182M        483M         13M        332M        772M
Swap:          499M         63M        435M
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram1                              partition       511416  65024   5
$ sudo swapoff /dev/zram1
$ sudo zramctl --reset /dev/zram1
$ sudo zramctl --find --size 2048M
/dev/zram1
$ sudo mkswap /dev/zram1
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=ce87d072-ac8e-4bd1-ba05-d362b51b6fa1
$ sudo swapon /dev/zram1
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           998M        221M        432M         16M        345M        730M
Swap:          2.0G          0B        2.0G

TensorFlow 2.1.0 패키지 설치

TensorFlow 2.1.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0/tensorflow-2.1.0-cp37-none-linux_armv7l.whl

tensorflow 2.1.0 파이썬 페키지 설치

$ export TMPDIR=/var/tmp
$ pip3 install tensorflow-2.1.0-cp37-none-linux_armv7l.whl
 
 ... 생략 ...
 
Installing collected packages: keras-preprocessing, gast, pyasn1, rsa, cachetools, pyasn1-modules, google-auth, markdown, oauthlib, certifi, chardet, idna, urllib3, requests, requests-oauthlib, google-auth-oauthlib, protobuf, absl-py, werkzeug, grpcio, tensorboard, keras-applications, tensorflow-estimator, google-pasta, wrapt, astor, scipy, opt-einsum, termcolor, tensorflow
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.0.0 certifi-2019.11.28 chardet-3.0.4 gast-0.2.2 google-auth-1.13.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 idna-2.9 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.2.1 oauthlib-3.1.0 opt-einsum-3.2.0 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.0 scipy-1.4.1 tensorboard-2.1.1 tensorflow-2.1.0 tensorflow-estimator-2.1.0 termcolor-1.1.0 urllib3-1.25.8 werkzeug-1.0.1 wrapt-1.12.1

버전 확인

$ python3
Python 3.7.7 (default, Apr  4 2020, 15:46:29) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.1.0'
728x90
728x90

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 48.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5
 
 ... 생략 ...
 
Hardware        : Allwinner sun8i Family
Revision        : 0000
Serial          : 1655415394228889

커널에 대한 정보

$ uname -a
Linux bananapim2ultra 5.1.12-sunxi #5.90 SMP Fri Jun 28 19:16:14 CEST 2019 armv7l armv7l armv7l GNU/Linux

OS버전에 대한 정보

$ cat /etc/issue
Ubuntu Bionic with Armbian Linux \l

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

TensorFlow C, C++ 라이브러리 설치

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0/libtensorflow.tar.gz

TensorFlow 라이브러리 설치

$ sudo tar -C /usr/local -xzf libtensorflow.tar.gz

Linker 설정

$ sudo ldconfig

예제 hello.c

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("TensorFlow C library version %s\n", TF_Version());
  return 0;
}

예제 컴파일

$ gcc hello.c -ltensorflow -o hello

예제 실행

$ ./hello
TensorFlow C library version 2.1.0
728x90
728x90

출처

pip3 설치

$ sudo apt-get install gfortran libopenblas-dev liblapack-dev libhdf5-dev
$ sudo apt install python3-pip python3-dev python3-h5py
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

파이썬 라이브러리 설치

$ sudo pip3 install setuptools wheel

swap 사이즈 설정

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          966Mi       254Mi       542Mi       4.0Mi       169Mi       685Mi
Swap:         483Mi          0B       483Mi
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram1                              partition       494972  0       5
$ sudo swapoff /dev/zram1
$ sudo zramctl --reset /dev/zram1
$ sudo zramctl --find --size 2048M
/dev/zram1
$ sudo mkswap /dev/zram1
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=7ad9947e-9b3a-48d7-94b3-e9a51107d18b
$ sudo swapon /dev/zram1
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           966M         86M        795M        4.2M         84M        854M
Swap:          2.0G          0B        2.0G

TensorFlow 2.1.0 패키지 설치

TensorFlow 2.1.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0/tensorflow-2.1.0-cp37-none-linux_armv7l.whl

tensorflow 2.1.0 파이썬 페키지 설치

$ export TMPDIR=/var/tmp
$ pip3 install tensorflow-2.1.0-cp37-none-linux_armv7l.whl

버전 확인

$ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.1.0'
728x90
728x90

출처

이미지 복원

이미지 복원이 완료되면 SD 메모리를 제거하고 재부팅

$ sudo dd if=Armbian_20.02.1_Bananapim2plus_buster_current_5.4.20_desktop.img of=/dev/mmcblk1 bs=10MB
269+1 records in
269+1 records out
2692743168 bytes (2.7 GB, 2.5 GiB) copied, 340.323 s, 7.9 MB/s

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 22.85
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5
 
 ... 샹략 ... 
 
Hardware        : Allwinner sun8i Family
Revision        : 0000
Serial          : 02c00042f5daa42d

커널에 대한 정보

$ uname -a
Linux bananapim2plus 5.4.20-sunxi #20.02.1 SMP Mon Feb 17 02:09:41 CET 2020 armv7l GNU/Linux

OS버전에 대한 정보

$ cat /etc/issue
Armbian 20.02.1 Buster \l 

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

TensorFlow C, C++ 라이브러리 설치

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0/libtensorflow.tar.gz

TensorFlow 라이브러리 설치

$ sudo tar -C /usr/local -xzf libtensorflow.tar.gz

Linker 설정

$ sudo ldconfig

예제 hello.c

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("TensorFlow C library version %s\n", TF_Version());
  return 0;
}

예제 컴파일

$ gcc hello.c -ltensorflow -o hello

예제 실행

$ ./hello
TensorFlow C library version 2.1.0
728x90

+ Recent posts