728x90

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 3 (v7l)
BogoMIPS        : 108.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3
 
 ... 생략 ...
 
Hardware        : BCM2835
Revision        : b03112
Serial          : 10000000xxxxxxxx
Model           : Raspberry Pi 4 Model B Rev 1.2

instruction set architecture (ISA)

$ uname -m
armv7l

커널에 대한 정보

$ uname -a
Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

메모리, swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          1.9Gi       145Mi       1.0Gi        42Mi       751Mi       1.6Gi
Swap:          99Mi          0B        99Mi

관련 라이브러리 설치, 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)

TensorFlow 2.2.0 패키지 설치

TensorFlow 2.2.0 패키지 다운로드

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

tensorflow 2.2.0 파이썬 페키지 설치

$ pip3 install tensorflow-2.2.0-cp37-none-linux_armv7l.whl
 
 ... 생략 ...
 
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 gast-0.3.3 google-auth-1.14.2 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 h5py-2.10.0 keras-preprocessing-1.1.0 markdown-3.2.1 opt-einsum-3.2.1 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 rsa-4.0 scipy-1.4.1 setuptools-46.1.3 tensorboard-2.2.1 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.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.2.0'
728x90
728x90

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 3 (v7l)
BogoMIPS        : 108.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 3
 
 ... 생략 ...
 
Hardware        : BCM2835
Revision        : b03112
Serial          : 10000000xxxxxxxx
Model           : Raspberry Pi 4 Model B Rev 1.2

instruction set architecture (ISA)

$ uname -m
armv7l

커널에 대한 정보

$ uname -a
Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

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

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.2.0.armv7l/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.2.0
728x90
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

출처

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-cp37m-linux_armv7l.whl

tensorflow 2.1.0 파이썬 패키지 설치

$ sudo pip3 install tensorflow-2.1.0-cp37-cp37m-linux_armv7l.whl
 
... 생략 ...
 
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.0.0 gast-0.2.2 google-auth-1.11.2 google-auth-oauthlib-0.4.1 google-pasta-0.1.8 grpcio-1.27.2 h5py-2.10.0 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

출처

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

출처

Docker 설치

$ curl -fsSL get.docker.com -o get-docker.sh
$ chmod +x get-docker.sh 
$ sudo ./get-docker.sh
## Executing docker install script, commit: 442e66405c304fa92af8aadaa1d9b31bf4b0ad94
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbian buster stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
+ [ -n  ]
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sh -c docker version
Client: Docker Engine - Community
 Version:           19.03.7
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        7141c19
 Built:             Wed Mar  4 01:55:10 2020
 OS/Arch:           linux/arm
 Experimental:      false
 
Server: Docker Engine - Community
 Engine:
  Version:          19.03.7
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       7141c19
  Built:            Wed Mar  4 01:49:01 2020
  OS/Arch:          linux/arm
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
 
  sudo usermod -aG docker your-user
 
Remember that you will have to log out and back in for this to take effect!
 
WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

일반 계정으로 docker 사용 가능하게 설정하기

$ sudo usermod -aG docker pi

Docker 서비스 상태 확인

$ sudo systemctl status docker.service
[0m docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-03-07 14:27:52 GMT; 4min 6s ago
     Docs: https://docs.docker.com
 Main PID: 1968 (dockerd)
    Tasks: 13
   Memory: 32.6M
   CGroup: /system.slice/docker.service
           붴1968 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 07 14:27:49 raspberrypi dockerd[1968]: time="2020-03-07T14:27:49.910122440Z" level=warning msg="Your
Mar 07 14:27:49 raspberrypi dockerd[1968]: time="2020-03-07T14:27:49.910211138Z" level=warning msg="Your
Mar 07 14:27:49 raspberrypi dockerd[1968]: time="2020-03-07T14:27:49.910297388Z" level=warning msg="Your
Mar 07 14:27:49 raspberrypi dockerd[1968]: time="2020-03-07T14:27:49.911678268Z" level=info msg="Loading
Mar 07 14:27:51 raspberrypi dockerd[1968]: time="2020-03-07T14:27:51.512894394Z" level=info msg="Default
Mar 07 14:27:52 raspberrypi dockerd[1968]: time="2020-03-07T14:27:52.162989392Z" level=info msg="Loading
Mar 07 14:27:52 raspberrypi dockerd[1968]: time="2020-03-07T14:27:52.492641302Z" level=info msg="Docker 
Mar 07 14:27:52 raspberrypi dockerd[1968]: time="2020-03-07T14:27:52.493554631Z" level=info msg="Daemon 
Mar 07 14:27:52 raspberrypi systemd[1]: Started Docker Application Container Engine.
Mar 07 14:27:52 raspberrypi dockerd[1968]: time="2020-03-07T14:27:52.904478155Z" level=info msg="API lis
728x90
728x90

출처

Raspberry Pi 3와 4 : OpenCV - 캐니 에지(Canny Edge) 속도 비교

캐니 에지(Canny Edge)는 1986년. John F. Canny 에 의해 개발된 알고리즘으로 윤곽을 원래 영상의 회색물질과 관련된 모든 에지(Edge)들을 제거하는 함수 입니다. Raspberry Pi 3와 4 실행해서 속도 비교를 해보았는데, 실행 결과를 보면 라즈베리파이3에서 실행 한것 보다 2배 약간 못되게 빠르게 동작하고 있습니다.

소스

#include "opencv2/opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(void)
{

	VideoCapture cap("Zootopia.mp4");

	if (!cap.isOpened()) {
		cerr << "Camera open failed" << endl;
		return -1;
	}

	Mat frame, gray, blurred, edge;
	while (true) {
		//cap >> frame;
		cap.read(frame);

		if (frame.empty()) {
			break;
		}

		TickMeter tm;
		tm.start();

		cvtColor(frame, gray, COLOR_BGR2GRAY);
		bilateralFilter(gray, blurred, -1, 10, 5);
		Canny(blurred, edge, 50, 150);

		tm.stop();

		cout << tm.getTimeMilli() << "[ms]" << endl;
		
		imshow("frame", frame);
		imshow("blurred", blurred);
		imshow("edge", edge);
		
		if (waitKey(1) == 27) {
			break;
		}
	}

	return 0;
}

컴파일

$ g++ main.cpp -o main `pkg-config --cflags --libs opencv4`

실행 (라즈베리파이3와 라즈베리파이4의 실행 시간 비교)

왼쪽은 라즈베리파이3에서 오른쪽은 라즈베리파이4에서 실행한 결과 입니다. 결과를 보시면 라즈베리파이4에서 실행결과가 라즈베리파이3에서 실행 한것 보다 2배 약간 못되게 빠르게 동작하고 있습니다.

pi@raspberrypi:~$ ./main          pi@raspberrypi:~ $ ./main
585.437[ms]                       293.316[ms]              
514.686[ms]                       258.292[ms]              
538.228[ms]                       257.687[ms]              
585.28[ms]                        255.691[ms]              
525.669[ms]                       272.336[ms]              
558.1[ms]                         255.374[ms]              
501.31[ms]                        263.007[ms]              
536.957[ms]                       256.362[ms]              
546.125[ms]                       258.705[ms]              
526.227[ms]                       259.988[ms]              
592.775[ms]                       254.891[ms]              
516.922[ms]                       255.25[ms]               
558.278[ms]                       260.084[ms]              
506.094[ms]                       261.073[ms]              
563.045[ms]                       256.056[ms]              
511.093[ms]                       270.214[ms]              
514.54[ms]                        264.756[ms]              
575.578[ms]                       256.604[ms]              
510.783[ms]                       256.996[ms]              
593.594[ms]                       268.694[ms]              
508.261[ms]                       257.855[ms]              
547.456[ms]                       259.229[ms]              
521.765[ms]                       255.19[ms]               
521.937[ms]                       255.639[ms]              
539.471[ms]                       255.995[ms]              
511.757[ms]                       258.853[ms]              
585.117[ms]                       256.869[ms] 

실행 영상

728x90

+ Recent posts