NanoPi M4V2 : GStreamer HLS 스트리밍 서버 구축

OS/NanoPi 2021. 3. 1. 15:32 Posted by 파란크리스마스

출처

임시 디렉토리 생성

GStreamer HLS 관련 임시 파일 생성을 위한 디렉토리 생성합니다.

pi@NanoPi-M4v2:~$ mkdir hlstest

GStreamer 실행

playlist-root 옵션은 playlist.m3u8 파일 내 호출 주소를 전달 하기 위해서 외부 플레이어에서 접근 가능한 주소를 설정하고, location 옵션은 hls 관련 파일이 생성될 임시 작업 폴더를 지정합니다.

pi@NanoPi-M4v2:~$ gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 \
  ! videoconvert ! clockoverlay ! x264enc tune=zerolatency ! mpegtsmux \
  ! hlssink playlist-root=http://192.168.0.5:8080 location=/home/pi/hlstest/segment_%05d.ts target-duration=5 max-files=5
Setting pipeline to PAUSED ...
media get entity by name: lens is null
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR rkisp_control_loop_impl.cpp:99: failed to get camera module info
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
XCAM ERROR rkisp_device.cpp:72: atomisp device(/dev/video1) try subdev format failed
Redistribute latency...
 
(gst-launch-1.0:2254): GStreamer-CRITICAL **: 09:06:59.673: gst_object_unref: assertion 'object != NULL' failed

윕서버 실행

HLS는 웹 스트리밍 프로토콜로 웹서버를 통해서 스트리밍 관련 파일을 전달하는데 GStreamer는 웹서버 기능이 없어서 python으로 웹서버를 이용하게 됩니다. 웹서비스 root 디렉토리로 이동하고 간이 웹서버를 실행합니다.

pi@NanoPi-M4v2:~$ cd hlstest/
pi@NanoPi-M4v2:~/hlstest$ python --version
Python 2.7.17
pi@NanoPi-M4v2:~/hlstest$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...

hls 주소

http://192.168.0.5:8080/playlist.m3u8

hls 재생

임시 디렉토리 목록 조회

pi@NanoPi-M4v2:~/hlstest$ ls 
playlist.m3u8 segment_00180.ts segment_00181.ts segment_00182.ts segment_00183.ts segment_00184.ts

댓글을 달아 주세요

NanoPi M4V2 : 카메라(OV13850) 사용하기

OS/NanoPi 2021. 2. 21. 00:51 Posted by 파란크리스마스

출처

NanoPi M4V2 : 카메라(ov13850)

이지미출처 : File:M4-mipi-single-camera.jpg - FriendlyARM WiKi

카메라(ov13850) 모듈 확인

pi@NanoPi-M4v2:~$ dmesg | grep ov13850
[    1.137232] ov13850 1-0010: driver version: 00.01.01
[    1.137688] ov13850 1-0010: could not get module information!
[    1.138295] ov13850 1-0010: GPIO lookup for consumer reset
[    1.138308] ov13850 1-0010: using device tree for GPIO lookup
[    1.138344] of_get_named_gpiod_flags: parsed 'reset-gpios' property of node '/i2c@ff110000/ov13850@10[0]' - status (0)
[    1.138380] ov13850 1-0010: GPIO lookup for consumer pwdn
[    1.138391] ov13850 1-0010: using device tree for GPIO lookup
[    1.138423] of_get_named_gpiod_flags: parsed 'pwdn-gpios' property of node '/i2c@ff110000/ov13850@10[0]' - status (0)
[    1.142534] ov13850 1-0010: Detected OV00d850 sensor, REVISION 0xb1
[    1.143438] ov13850 2-0010: driver version: 00.01.01
[    1.143893] ov13850 2-0010: could not get module information!
[    1.144472] ov13850 2-0010: GPIO lookup for consumer reset
[    1.144484] ov13850 2-0010: using device tree for GPIO lookup
[    1.144519] of_get_named_gpiod_flags: parsed 'reset-gpios' property of node '/i2c@ff120000/ov13850@10[0]' - status (0)
[    1.144556] ov13850 2-0010: GPIO lookup for consumer pwdn
[    1.144567] ov13850 2-0010: using device tree for GPIO lookup
[    1.144597] of_get_named_gpiod_flags: parsed 'pwdn-gpios' property of node '/i2c@ff120000/ov13850@10[0]' - status (0)
[    1.149264] ov13850 2-0010: Unexpected sensor id(000000), ret(-5)

카메라(ov13850) 모듈 확인

pi@NanoPi-M4v2:~$ v4l2-ctl -V -d /dev/video0
Format Video Capture Multiplanar:
        Width/Height      : 640/480
        Pixel Format      : 'YUYV'
        Field             : None
        Number of planes  : 1
        Flags             : 
        Colorspace        : Default
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Full Range
        Plane 0           :
           Bytes per Line : 1280
           Size Image     : 614400
pi@NanoPi-M4v2:~$ v4l2-ctl -V -d /dev/video1
Format Video Capture Multiplanar:
        Width/Height      : 1920/1568
        Pixel Format      : 'YUYV'
        Field             : None
        Number of planes  : 1
        Flags             : 
        Colorspace        : Default
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Full Range
        Plane 0           :
           Bytes per Line : 3840
           Size Image     : 6021120
pi@NanoPi-M4v2:~$ v4l2-ctl -d /dev/v4l-subdev0 --all
Driver Info (not using libv4l2):
        Driver name   : 
        Card type     : 
        Bus info      : 
        Driver version: 0.0.0
        Capabilities  : 0x00000000
 
User Controls
 
                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1536
 
Image Source Controls
 
              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16
 
Image Processing Controls
 
                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=0 step=0 default=0 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
pi@NanoPi-M4v2:~$ v4l2-ctl -d /dev/v4l-subdev1 --all
Driver Info (not using libv4l2):
        Driver name   : 
        Card type     : 
        Bus info      : 
        Driver version: 0.0.0
        Capabilities  : 0x00000000
 
User Controls
 
                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1536
 
Image Source Controls
 
              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16
 
Image Processing Controls
 
                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=0 step=0 default=0 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0
pi@NanoPi-M4v2:~$ v4l2-ctl -d /dev/v4l-subdev2 --all
Driver Info (not using libv4l2):
        Driver name   : 
        Card type     : 
        Bus info      : 
        Driver version: 0.0.0
        Capabilities  : 0x00000000
 
User Controls
 
                       exposure 0x00980911 (int)    : min=4 max=1660 step=1 default=1536 value=1536
 
Image Source Controls
 
              vertical_blanking 0x009e0901 (int)    : min=96 max=31199 step=1 default=96 value=96
            horizontal_blanking 0x009e0902 (int)    : min=2688 max=2688 step=1 default=2688 value=2688 flags=read-only
                  analogue_gain 0x009e0903 (int)    : min=16 max=248 step=1 default=16 value=16
 
Image Processing Controls
 
                 link_frequency 0x009f0901 (intmenu): min=0 max=0 default=0 value=0 flags=read-only
                     pixel_rate 0x009f0902 (int64)  : min=0 max=0 step=0 default=0 value=120000000 flags=read-only
                   test_pattern 0x009f0903 (menu)   : min=0 max=4 default=0 value=0

카메라(ov13850) 모듈 확인

pi@NanoPi-M4v2:~$ media-ctl -d /dev/media0 -p
Media controller API version 0.1.0
 
Media device information
------------------------
driver          rkisp1
model           rkisp1
serial          
bus info        
hw revision     0x0
driver version  0.0.0
 
Device topology
- entity 1: rkisp1-isp-subdev (4 pads, 6 links)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        pad0: Sink
                [fmt:SBGGR10_1X10/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                <- "rkisp1_dmapath":0 []
                <- "rockchip-mipi-dphy-rx":1 [ENABLED]
        pad1: Sink
                <- "rkisp1-input-params":0 [ENABLED]
        pad2: Source
                [fmt:YUYV8_2X8/2112x1568 field:none
                 crop.bounds:(0,0)/2112x1568
                 crop:(0,0)/2112x1568]
                -> "rkisp1_selfpath":0 [ENABLED]
                -> "rkisp1_mainpath":0 [ENABLED]
        pad3: Source
                -> "rkisp1-statistics":0 [ENABLED]
 
- entity 2: rkisp1_mainpath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
        pad0: Sink
                <- "rkisp1-isp-subdev":2 [ENABLED]
 
- entity 3: rkisp1_selfpath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
        pad0: Sink
                <- "rkisp1-isp-subdev":2 [ENABLED]
 
- entity 4: rkisp1_dmapath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video2
        pad0: Source
                -> "rkisp1-isp-subdev":0 []
 
- entity 5: rkisp1-statistics (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video3
        pad0: Sink
                <- "rkisp1-isp-subdev":3 [ENABLED]
 
- entity 6: rkisp1-input-params (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video4
        pad0: Source
                -> "rkisp1-isp-subdev":1 [ENABLED]
 
- entity 7: rockchip-mipi-dphy-rx (2 pads, 2 links)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev1
        pad0: Sink
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                <- "ov13850 1-0010":0 [ENABLED]
        pad1: Source
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                -> "rkisp1-isp-subdev":0 [ENABLED]
 
- entity 8: ov13850 1-0010 (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev2
        pad0: Source
                [fmt:SBGGR10_1X10/2112x1568@10000/300000 field:none]
                -> "rockchip-mipi-dphy-rx":0 [ENABLED]

카메라(ov13850) 연결 확인

pi@NanoPi-M4v2:~$ dmesg | grep Async
[    1.839621] rkisp1: Async subdev notifier completed

gst-camera 설치

pi@NanoPi-M4v2:~$ cd /tmp/
pi@NanoPi-M4v2:/tmp$ git clone https://github.com/friendlyarm/gst-camera-sh.git
Cloning into 'gst-camera-sh'...
remote: Enumerating objects: 36, done.
remote: Total 36 (delta 0), reused 0 (delta 0), pack-reused 36
Unpacking objects: 100% (36/36), done.
pi@NanoPi-M4v2:/tmp$ sudo cp gst-camera-sh/*.sh /usr/bin/

카메라(ov13850) 캡쳐

pi@NanoPi-M4v2:/tmp$ gst-camera.sh -a photo -o 1.jpg
gst-launch-1.0: no process found
====================================================
=== GStreamer 1.1 command:
=== gst-launch-1.0 rkisp num-buffers=20 device=/dev/video0 io-mode=1 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=10/1 ! jpegenc ! multifilesink location="/tmp/isp-frame%d.jpg"
====================================================
{{{{{{ start take photo
Setting pipeline to PAUSED ...
media get entity by name: lens is null
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR rkisp_control_loop_impl.cpp:99: failed to get camera module info
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
XCAM ERROR rkisp_device.cpp:72: atomisp device(/dev/video0) try subdev format failed
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:00.759673858
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
}}}}}} end take photo

Image sensors OV13850 & OV4689 at the i2c ports 1 & 2

pi@NanoPi-M4v2:~/mjpg-streamer/mjpg-streamer-experimental$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- -- 
10: UU -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@NanoPi-M4v2:~/mjpg-streamer/mjpg-streamer-experimental$ ls -l /sys/class/video4linux/
total 0
lrwxrwxrwx 1 root root 0 Feb 28 17:30 v4l-subdev0 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev0
lrwxrwxrwx 1 root root 0 Feb 28 17:30 v4l-subdev1 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev1
lrwxrwxrwx 1 root root 0 Feb 28 17:30 v4l-subdev2 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev2
lrwxrwxrwx 1 root root 0 Feb 28 17:30 v4l-subdev3 -> ../../devices/platform/ff920000.rkisp1/video4linux/v4l-subdev3
lrwxrwxrwx 1 root root 0 Feb 28 17:30 v4l-subdev4 -> ../../devices/platform/ff920000.rkisp1/video4linux/v4l-subdev4
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video0 -> ../../devices/platform/ff910000.rkisp1/video4linux/video0
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video1 -> ../../devices/platform/ff910000.rkisp1/video4linux/video1
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video2 -> ../../devices/platform/ff910000.rkisp1/video4linux/video2
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video3 -> ../../devices/platform/ff910000.rkisp1/video4linux/video3
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video4 -> ../../devices/platform/ff910000.rkisp1/video4linux/video4
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video5 -> ../../devices/platform/ff920000.rkisp1/video4linux/video5
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video6 -> ../../devices/platform/ff920000.rkisp1/video4linux/video6
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video7 -> ../../devices/platform/ff920000.rkisp1/video4linux/video7
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video8 -> ../../devices/platform/ff920000.rkisp1/video4linux/video8
lrwxrwxrwx 1 root root 0 Feb 28 17:30 video9 -> ../../devices/platform/ff920000.rkisp1/video4linux/video9

화이트 밸런스 조정 (실패)

pi@NanoPi-M4v2:~$ v4l2-ctl -d 1 --set-ctrl=white_balance_temperature_auto=1
unknown control 'white_balance_temperature_auto'

댓글을 달아 주세요

NanoPi NEO2 Black

OS/NanoPi 2021. 1. 16. 02:18 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

pi@NanoPi-NEO2-Black:~$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
 ... 생략 ...
 
Hardware        : Allwinnersun50iw2Family
Revision        : 0000
Serial          : 0000000000000000

instruction set architecture (ISA)

pi@NanoPi-NEO2-Black:~$ uname -i
aarch64

eMMC에 OS 설치

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

eMMC 확인

pi@NanoPi-NEO2-Black:~$ sudo fdisk -l | grep Disk
Disk /dev/mmcblk0: 59.5 GiB, 63864569856 bytes, 124735488 sectors
Disklabel type: dos
Disk identifier: 0xd70475ff
Disk /dev/mmcblk1: 29.1 GiB, 31268536320 bytes, 61071360 sectors
Disk /dev/mmcblk1boot1: 4 MiB, 4194304 bytes, 8192 sectors
Disk /dev/mmcblk1boot0: 4 MiB, 4194304 bytes, 8192 sectors

eMMC에 OS 설치

pi@NanoPi-NEO2-Black:~$ sudo dd if=nanopi-neo2-black_sd_friendlycore-xenial_4.14_arm64_20191219.img of=/dev/mmcblk1 bs=10MB
278+1 records in
278+1 records out
2787115008 bytes (2.8 GB, 2.6 GiB) copied, 123.871 s, 22.5 MB/s

원격 데스크톱 설치

desktop environment 설치

pi@NanoPi-NEO2-Black:~$ sudo apt install xfce4

Xrdp 설치

pi@NanoPi-NEO2-Black:~$ sudo apt install xrdp

xrdp 서비스 상태 확인

pi@NanoPi-NEO2-Black:~$ systemctl status xrdp
● xrdp.service - LSB: Start xrdp and sesman daemons
   Loaded: loaded (/etc/init.d/xrdp; bad; vendor preset: enabled)
   Active: active (running) since Fri 2021-01-15 16:59:06 UTC; 11s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/xrdp.service
           ├─15133 /usr/sbin/xrdp
           └─15135 /usr/sbin/xrdp-sesman

~/.xsession 생성 및 확인

pi@NanoPi-NEO2-Black:~$ ls /usr/bin/*session
/usr/bin/dbus-run-session  /usr/bin/xfce4-session
pi@NanoPi-NEO2-Black:~$ echo "xfce4-session" > ~/.xsession
pi@NanoPi-NEO2-Black:~$ cat ~/.xsession
xfce4-session

웹브라우저 설치

pi@NanoPi-NEO2-Black:~$ sudo apt install chromium-browser

댓글을 달아 주세요

NanoPi M4V2 : Armbian Linux 버전

OS/NanoPi 2021. 1. 3. 23:54 Posted by 파란크리스마스

출처

eMMC에 OS 설치

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

eMMC 확인

pi@nanopim4v2:~$ fdisk -l | grep Disk
The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Disk /dev/mmcblk2: 29.12 GiB, 31268536320 bytes, 61071360 sectors
Disklabel type: gpt
Disk identifier: 73987B6B-4974-4C94-A3E8-58AB2EB7A946
Disk /dev/mmcblk1: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disklabel type: dos
Disk identifier: 0x75c728fe
Disk /dev/zram0: 50 MiB, 52428800 bytes, 12800 sectors
Disk /dev/zram1: 1.88 GiB, 1992282112 bytes, 486397 sectors

eMMC에 OS 설치

pi@nanopim4v2:~$ sudo dd if=Armbian_20.11.3_Nanopim4v2_focal_current_5.9.14_desktop.img of=/dev/mmcblk2 bs=10MB
368+1 records in
368+1 records out
3686793216 bytes (3.7 GB, 3.4 GiB) copied, 68.1611 s, 54.1 MB/s

원격 데스크톱 설치

Xrdp 설치

pi@nanopim4v2:~$ sudo apt install xrdp xorgxrdp

xrdp 서비스 상태 확인

pi@nanopim4v2:~$ sudo systemctl status xrdp
● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-01-04 00:48:08 KST; 24s ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
   Main PID: 9093 (xrdp)
      Tasks: 1 (limit: 4383)
     Memory: 712.0K
     CGroup: /system.slice/xrdp.service
             └─9093 /usr/sbin/xrdp
 
 1월 04 00:48:07 nanopim4v2 xrdp[9092]: (9092)(281473703223312)[INFO ] address [0.0.0.0] port [3389] mode 1
 1월 04 00:48:07 nanopim4v2 xrdp[9092]: (9092)(281473703223312)[INFO ] listening to port 3389 on 0.0.0.0
 1월 04 00:48:07 nanopim4v2 xrdp[9092]: (9092)(281473703223312)[INFO ] xrdp_listen_pp done
 1월 04 00:48:07 nanopim4v2 xrdp[9092]: (9092)(281473703223312)[DEBUG] Closed socket 7 (AF_INET6 :: port 338>
 1월 04 00:48:07 nanopim4v2 systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after st>
 1월 04 00:48:08 nanopim4v2 systemd[1]: Started xrdp daemon.
 1월 04 00:48:09 nanopim4v2 xrdp[9093]: (9093)(281473703223312)[INFO ] starting xrdp with pid 9093
 1월 04 00:48:09 nanopim4v2 xrdp[9093]: (9093)(281473703223312)[INFO ] address [0.0.0.0] port [3389] mode 1
 1월 04 00:48:09 nanopim4v2 xrdp[9093]: (9093)(281473703223312)[INFO ] listening to port 3389 on 0.0.0.0
 1월 04 00:48:09 nanopim4v2 xrdp[9093]: (9093)(281473703223312)[INFO ] xrdp_listen_pp done

~/.xsession 생성 및 확인

pi@nanopim4v2:~$ ls /usr/bin/*session
/usr/bin/dbus-run-session  /usr/bin/xfce4-session
pi@NanoPi-M4v2:~$ echo "xfce4-session" > ~/.xsession
pi@NanoPi-M4v2:~$ cat ~/.xsession
xfce4-session

한글폰트 설치

pi@orangepi4:~$ sudo apt install language-pack-ko fonts-nanum fonts-nanum-extra

댓글을 달아 주세요

NanoPi M4V2 : TensorFlow 2.2.0 (aarch64) 설치 (Python 3.7)

OS/NanoPi 2020. 5. 13. 01:15 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.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
 
 ... 생략 ...
 
Serial          : ca0a2ef4e6xxxxxx

instruction set architecture (ISA)

$ uname -i
aarch64

커널에 대한 정보

$ uname -a
Linux NanoPi-M4v2 4.4.179 #1 SMP Tue Mar 17 16:51:26 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
6

메모리, swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.8G         76M        2.9G        8.8M        803M        3.6G
Swap:            0B          0B          0B

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

TensorFlow 2.2.0 패키지 설치

TensorFlow 2.2.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.2.0.aarch64/tensorflow-2.2.0-cp37-cp37m-linux_aarch64.whl

tensorflow 2.2.0 파이썬 페키지 설치

$ pip3 install tensorflow-2.2.0-cp37-cp37m-linux_aarch64.whl
 
Defaulting to user installation because normal site-packages is not writeable
Processing ./tensorflow-2.2.0-cp37-cp37m-linux_aarch64.whl
Requirement already satisfied: numpy<2.0,>=1.16.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==2.2.0) (1.18.4)
Collecting protobuf>=3.8.0
  Downloading protobuf-3.11.3-py2.py3-none-any.whl (434 kB)
     |████████████████████████████████| 434 kB 223 kB/s 
Collecting grpcio>=1.8.6
  Downloading grpcio-1.28.1.tar.gz (19.5 MB)
     |████████████████████████████████| 19.5 MB 154 kB/s 
Collecting keras-preprocessing>=1.1.0
  Downloading Keras_Preprocessing-1.1.1-py2.py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 344 kB/s 
Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==2.2.0) (1.14.0)
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Requirement already satisfied: h5py<2.11.0,>=2.10.0 in /usr/local/lib/python3.7/site-packages (from tensorflow==2.2.0) (2.10.0)
Collecting tensorboard<2.3.0,>=2.2.0
  Downloading tensorboard-2.2.1-py3-none-any.whl (3.0 MB)
     |████████████████████████████████| 3.0 MB 5.7 MB/s 
Collecting tensorflow-estimator<2.3.0,>=2.2.0
  Downloading tensorflow_estimator-2.2.0-py2.py3-none-any.whl (454 kB)
     |████████████████████████████████| 454 kB 6.2 MB/s 
Collecting wrapt>=1.11.1
  Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting scipy==1.4.1; python_version >= "3"
  Downloading scipy-1.4.1.tar.gz (24.6 MB)
     |████████████████████████████████| 24.6 MB 540 kB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting google-pasta>=0.1.8
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 2.3 MB/s 
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.2.1-py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 1.0 MB/s 
Collecting absl-py>=0.7.0
  Downloading absl-py-0.9.0.tar.gz (104 kB)
     |████████████████████████████████| 104 kB 7.4 MB/s 
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /usr/local/lib/python3.7/site-packages (from tensorflow==2.2.0) (0.34.2)
Collecting gast==0.3.3
  Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting astunparse==1.6.3
  Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from protobuf>=3.8.0->tensorflow==2.2.0) (46.2.0)
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 6.4 MB/s 
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting markdown>=2.6.8
  Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 3.1 MB/s 
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.6.0.post3-py3-none-any.whl (777 kB)
     |████████████████████████████████| 777 kB 6.3 MB/s 
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.14.3-py2.py3-none-any.whl (89 kB)
     |████████████████████████████████| 89 kB 3.2 MB/s 
Collecting requests<3,>=2.21.0
  Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 3.0 MB/s 
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting importlib-metadata; python_version < "3.8"
  Downloading importlib_metadata-1.6.0-py2.py3-none-any.whl (30 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 7.6 MB/s 
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting rsa<4.1,>=3.1.4
  Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 8.2 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 7.9 MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
     |████████████████████████████████| 126 kB 8.2 MB/s 
Collecting idna<3,>=2.5
  Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.6 MB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 8.1 MB/s 
Collecting zipp>=0.5
  Downloading zipp-3.1.0-py3-none-any.whl (4.9 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 2.4 MB/s 
Building wheels for collected packages: grpcio, termcolor, wrapt, scipy, absl-py
  Building wheel for grpcio (setup.py) ... 
  Created wheel for grpcio: filename=grpcio-1.28.1-cp37-cp37m-linux_aarch64.whl size=21720921 sha256=1c5d524edfe612fb392cb50ebacab9ec390e75cadf4113a2b8fce767d5b3c673
  Stored in directory: /home/pi/.cache/pip/wheels/1a/57/84/d91cbd4882f6ae0adc3acba56cbf0c2c75e0263118614d1fcf
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=8b1f16963d32824d08c381271c4fe32337c5f127e36d4dd04e9e380ab1152e66
  Stored in directory: /home/pi/.cache/pip/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
  Building wheel for wrapt (setup.py) ... done
  Created wheel for wrapt: filename=wrapt-1.12.1-cp37-cp37m-linux_aarch64.whl size=71545 sha256=f927060b151c53873a685a59f13015e5aaf6da67da4f741c02598f26bb308af0
  Stored in directory: /home/pi/.cache/pip/wheels/62/76/4c/aa25851149f3f6d9785f6c869387ad82b3fd37582fa8147ac6
  Building wheel for scipy (PEP 517) ... done
  Created wheel for scipy: filename=scipy-1.4.1-cp37-cp37m-linux_aarch64.whl size=45319976 sha256=e7af6941572f5cdea50661ee1134b471727bf6d4815695d2f3461af3930edcdc
  Stored in directory: /home/pi/.cache/pip/wheels/ff/bd/f9/ac5a9a019da5be2072e8a283f36d28b219762cebdd21ff3c68
  Building wheel for absl-py (setup.py) ... done
  Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121931 sha256=72ad0ed75f329456194bb9d3dce7390916534f26b08a15c81c480904644fd4ba
  Stored in directory: /home/pi/.cache/pip/wheels/cc/af/1a/498a24d0730ef484019e007bb9e8cef3ac00311a672c049a3e
Successfully built grpcio termcolor wrapt scipy absl-py
Installing collected packages: protobuf, grpcio, keras-preprocessing, termcolor, werkzeug, chardet, certifi, urllib3, idna, requests, oauthlib, requests-oauthlib, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, google-auth-oauthlib, absl-py, zipp, importlib-metadata, markdown, tensorboard-plugin-wit, tensorboard, tensorflow-estimator, wrapt, scipy, google-pasta, opt-einsum, gast, astunparse, tensorflow
  WARNING: The script chardetect is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script google-oauthlib-tool is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown_py is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tensorboard is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts estimator_ckpt_converter, saved_model_cli, tensorboard, tf_upgrade_v2, tflite_convert, toco and toco_from_protos are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 gast-0.3.3 google-auth-1.14.3 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 idna-2.9 importlib-metadata-1.6.0 keras-preprocessing-1.1.1 markdown-3.2.2 oauthlib-3.1.0 opt-einsum-3.2.1 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.2.1 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wrapt-1.12.1 zipp-3.1.0
WARNING: You are using pip version 20.0.2; however, version 20.1 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.

버전 확인

$ python3
Python 3.7.7 (default, May 12 2020, 15:55:46) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.2.0'

댓글을 달아 주세요

NanoPi M4V2 : TensorFlow 2.2.0 (aarch64) - C, C++ 라이브러리 설치

OS/NanoPi 2020. 5. 13. 01:02 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.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
 
 ... 생략 ...
 
Serial          : ca0a2ef4e6xxxxxx

instruction set architecture (ISA)

$ uname -i
aarch64

커널에 대한 정보

$ uname -a
Linux NanoPi-M4v2 4.4.179 #1 SMP Tue Mar 17 16:51:26 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
6

메모리, swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.8G         76M        2.9G        8.8M        803M        3.6G
Swap:            0B          0B          0B

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

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.2.0.aarch64/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

댓글을 달아 주세요

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.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
 
 ... 생략 ...
 
Serial          : ca0a2ef4e6xxxxxx

instruction set architecture (ISA)

$ uname -i
aarch64

커널에 대한 정보

$ uname -a
Linux NanoPi-M4v2 4.4.179 #1 SMP Tue Mar 17 16:51:26 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
6

메모리, swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.8G         76M        2.9G        8.8M        803M        3.6G
Swap:            0B          0B          0B

swap 사이즈 설정 (tensorflow 빌드시 4G가 이상 필요)

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.8G        1.1G        2.3G        8.8M        391M        2.6G
Swap:            0B          0B          0B
$ sudo swapon -s
$ sudo dd if=/dev/zero of=/mnt/2G.swap bs=1M count=2048 oflag=append conv=notrunc
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 27.6497 s, 77.7 MB/s
$ sudo mkswap /mnt/2G.swap
mkswap: /mnt/2G.swap: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=0fb271af-7185-4636-91f8-49ac5de6451f
$ sudo swapon /mnt/2G.swap
swapon: /mnt/2G.swap: insecure permissions 0644, 0600 suggested.
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.8G        1.1G        207M        8.8M        2.4G        2.5G
Swap:          2.0G          0B        2.0G
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/mnt/2G.swap

Bazel 설치

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

javac 1.8 버전으로 변경(심볼릭 링크 변경)

$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
 
  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac   1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-armhf/bin/javac    1081      manual mode
 
Press  to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-armhf/bin/javac to provide /usr/bin/javac (javac) in manual mode
$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
 
  Selection    Path                                          Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-armhf/bin/javac   1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-armhf/bin/javac    1081      manual mode

Bazel 다운로드 및 설치

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

Tensorflow 설치

필수 패키지 설치

$ sudo apt-get install curl libcurl3-dev wget zip unzip git vim build-essential ca-certificates ca-certificates-java pkg-config rsync libatlas-base-dev liblapack-dev libpng-dev libjpeg-dev gfortran python2.7 python-dev python-setuptools gdb openjdk-8-jdk openjdk-8-jre-headless g++ zlib1g-dev libio-all-perl libsnappy-dev libyaml-0-2 python-opencv libopenblas-dev libhdf5-dev

Python 설치

$ sudo apt install python-dev python-pip python3-dev python3-pip

필수 라이브러리 설치

$ sudo -H pip3 install -U --user pip six numpy wheel setuptools mock future>=0.17.1
$ sudo -H pip3 install -U --user keras_applications==1.0.6 --no-deps
$ sudo -H pip3 install -U --user keras_preprocessing==1.0.5 --no-deps

Tensorflow 소스 다운로드

$ wget https://github.com/tensorflow/tensorflow/archive/v2.2.0.tar.gz
$ tar -xvf  v2.2.0.tar.gz
$ cd tensorflow-2.2.0/

빌드 구성

Do you wish to build TensorFlow with XLA JIT support? --> n 으로 설정

$ ./configure 
You have bazel 2.0.0- (@non-git) installed.
Please specify the location of python. [Default is /usr/bin/python]: /usr/local/bin/python3
 
 
Found possible Python library paths:
  /usr/local/lib/python3.7/site-packages
Please input the desired Python library path to use.  Default is [/usr/local/lib/python3.7/site-packages]
 
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: 
No OpenCL SYCL support will be enabled for TensorFlow.
 
Do you wish to build TensorFlow with ROCm support? [y/N]: 
No ROCm support will be enabled for TensorFlow.
 
Do you wish to build TensorFlow with CUDA support? [y/N]: 
No CUDA support will be enabled for TensorFlow.
 
Do you wish to download a fresh release of clang? (Experimental) [y/N]: 
Clang will not be downloaded.
 
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: 
 
 
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: 
Not configuring the WORKSPACE for Android builds.
 
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
        --config=mkl            # Build with MKL support.
        --config=monolithic     # Config for mostly static monolithic build.
        --config=ngraph         # Build with Intel nGraph support.
        --config=numa           # Build with NUMA support.
        --config=dynamic_kernels        # (Experimental) Build kernels into separate shared objects.
        --config=v2             # Build TensorFlow 2.x instead of 1.x.
Preconfigured Bazel build configs to DISABLE default on features:
        --config=noaws          # Disable AWS S3 filesystem support.
        --config=nogcp          # Disable GCP support.
        --config=nohdfs         # Disable HDFS support.
        --config=nonccl         # Disable NVIDIA NCCL support.
Configuration finished

빌드

$ sudo bazel --host_jvm_args=-Xmx1624m build --config=noaws --config=v2 --local_cpu_resources=1 --verbose_failures //tensorflow/tools/pip_package:build_pip_package

파이썬 라이브러리 만들기

$ sudo bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
Mon May 11 15:57:13 UTC 2020 : === Preparing sources in dir: /tmp/tmp.y2XMersE47
~/tensorflow-2.2.0 ~/tensorflow-2.2.0
~/tensorflow-2.2.0
~/tensorflow-2.2.0/bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow ~/tensorflow-2.2.0
~/tensorflow-2.2.0
/tmp/tmp.y2XMersE47/tensorflow/include ~/tensorflow-2.2.0
~/tensorflow-2.2.0
Mon May 11 15:57:49 UTC 2020 : === Building wheel
warning: no files found matching 'README'
warning: no files found matching '*.pyd' under directory '*'
warning: no files found matching '*.pyi' under directory '*'
warning: no files found matching '*.pd' under directory '*'
warning: no files found matching '*.dylib' under directory '*'
warning: no files found matching '*.dll' under directory '*'
warning: no files found matching '*.lib' under directory '*'
warning: no files found matching '*.csv' under directory '*'
warning: no files found matching '*.h' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*.proto' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*' under directory 'tensorflow/include/third_party'
Mon May 11 15:59:22 UTC 2020 : === Output wheel file is in: /tmp/tensorflow_pkg

tensorflow 2.2.0 파이썬 페키지 설치

$ cd /tmp/tensorflow_pkg/
$ sudo pip3 install --upgrade tensorflow-2.2.0-cp37-cp37m-linux_aarch64.whl 
WARNING: The directory '/home/pi/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing ./tensorflow-2.2.0-cp37-cp37m-linux_aarch64.whl
Requirement already satisfied, skipping upgrade: numpy<2.0,>=1.16.0 in /home/pi/.local/lib/python3.7/site-packages (from tensorflow==2.2.0) (1.18.4)
Collecting tensorboard<2.3.0,>=2.2.0
  Downloading tensorboard-2.2.1-py3-none-any.whl (3.0 MB)
     |████████████████████████████████| 3.0 MB 4.5 MB/s 
Collecting h5py<2.11.0,>=2.10.0
  Downloading h5py-2.10.0.tar.gz (301 kB)
     |████████████████████████████████| 301 kB 5.4 MB/s 
Collecting astunparse==1.6.3
  Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.2.1-py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 4.2 MB/s 
Requirement already satisfied, skipping upgrade: wheel>=0.26; python_version >= "3" in /usr/local/lib/python3.7/site-packages (from tensorflow==2.2.0) (0.34.2)
Collecting wrapt>=1.11.1
  Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting absl-py>=0.7.0
  Downloading absl-py-0.9.0.tar.gz (104 kB)
     |████████████████████████████████| 104 kB 6.4 MB/s 
Requirement already satisfied, skipping upgrade: six>=1.12.0 in /home/pi/.local/lib/python3.7/site-packages (from tensorflow==2.2.0) (1.14.0)
Collecting tensorflow-estimator<2.3.0,>=2.2.0
  Downloading tensorflow_estimator-2.2.0-py2.py3-none-any.whl (454 kB)
     |████████████████████████████████| 454 kB 5.0 MB/s 
Collecting gast==0.3.3
  Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting grpcio>=1.8.6
  Downloading grpcio-1.28.1.tar.gz (19.5 MB)
     |████████████████████████████████| 19.5 MB 17.1 MB/s 
Collecting scipy==1.4.1; python_version >= "3"
  Downloading scipy-1.4.1.tar.gz (24.6 MB)
     |████████████████████████████████| 24.6 MB 14.0 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting google-pasta>=0.1.8
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 4.5 MB/s 
Collecting protobuf>=3.8.0
  Downloading protobuf-3.11.3-py2.py3-none-any.whl (434 kB)
     |████████████████████████████████| 434 kB 6.5 MB/s 
Collecting keras-preprocessing>=1.1.0
  Downloading Keras_Preprocessing-1.1.0-py2.py3-none-any.whl (41 kB)
     |████████████████████████████████| 41 kB 2.2 MB/s 
Collecting markdown>=2.6.8
  Downloading Markdown-3.2.2-py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 5.9 MB/s 
Collecting requests<3,>=2.21.0
  Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 3.9 MB/s 
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.14.2-py2.py3-none-any.whl (89 kB)
     |████████████████████████████████| 89 kB 5.5 MB/s 
Requirement already satisfied, skipping upgrade: setuptools>=41.0.0 in /usr/local/lib/python3.7/site-packages (from tensorboard<2.3.0,>=2.2.0->tensorflow==2.2.0) (46.1.3)
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 6.8 MB/s 
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.6.0.post3-py3-none-any.whl (777 kB)
     |████████████████████████████████| 777 kB 5.3 MB/s 
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting importlib-metadata; python_version < "3.8"
  Downloading importlib_metadata-1.6.0-py2.py3-none-any.whl (30 kB)
Collecting idna<3,>=2.5
  Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 4.9 MB/s 
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 6.2 MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
     |████████████████████████████████| 126 kB 6.6 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 4.4 MB/s 
Collecting rsa<4.1,>=3.1.4
  Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 6.3 MB/s 
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting zipp>=0.5
  Downloading zipp-3.1.0-py3-none-any.whl (4.9 kB)
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 5.3 MB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 6.2 MB/s 
Building wheels for collected packages: h5py, wrapt, absl-py, termcolor, grpcio, scipy
  Building wheel for h5py (setup.py) ... done
  Created wheel for h5py: filename=h5py-2.10.0-cp37-cp37m-linux_aarch64.whl size=4023366 sha256=0ca490b9297ddd162e411faf2de0b19d035dec714ac002c5518ff911649d7b00
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/58/e7/f7/d9385040f9b6919de4a5c05625c4e655999412f12c96d3c7c3
  Building wheel for wrapt (setup.py) ... done
  Created wheel for wrapt: filename=wrapt-1.12.1-cp37-cp37m-linux_aarch64.whl size=71539 sha256=c4e9c727e5a12d10a2f4e4507fec751d4c4f126b6448f5edcd8eb49ac09b3927
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/62/76/4c/aa25851149f3f6d9785f6c869387ad82b3fd37582fa8147ac6
  Building wheel for absl-py (setup.py) ... done
  Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121931 sha256=48bc76f542213bc268a2f25ce5139a3817f9c6c859cc5a8171d7d943a5379f87
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/cc/af/1a/498a24d0730ef484019e007bb9e8cef3ac00311a672c049a3e
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=e108924f90b631bff23c0252b560510a3dce6d76a436ffc34d3a52fcd071e5fd
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
  Building wheel for grpcio (setup.py) ... done
  Created wheel for grpcio: filename=grpcio-1.28.1-cp37-cp37m-linux_aarch64.whl size=21721618 sha256=1c35d05a146e98a5b0fd24d9a8b9583176cb0b993c6f019ae0a43262f94c2164
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/1a/57/84/d91cbd4882f6ae0adc3acba56cbf0c2c75e0263118614d1fcf
  Building wheel for scipy (PEP 517) ... done
  Created wheel for scipy: filename=scipy-1.4.1-cp37-cp37m-linux_aarch64.whl size=45319698 sha256=6b3332b029f955a76cf77f18e6c732adb593153ff2fc913dae122ab5243c6834
  Stored in directory: /tmp/pip-ephem-wheel-cache-9x9ib2b3/wheels/ff/bd/f9/ac5a9a019da5be2072e8a283f36d28b219762cebdd21ff3c68
Successfully built h5py wrapt absl-py termcolor grpcio scipy
Installing collected packages: zipp, importlib-metadata, markdown, idna, chardet, urllib3, certifi, requests, pyasn1, rsa, pyasn1-modules, cachetools, google-auth, werkzeug, tensorboard-plugin-wit, grpcio, absl-py, oauthlib, requests-oauthlib, google-auth-oauthlib, protobuf, tensorboard, h5py, astunparse, opt-einsum, wrapt, tensorflow-estimator, gast, termcolor, scipy, google-pasta, keras-preprocessing, tensorflow
  Attempting uninstall: keras-preprocessing
    Found existing installation: Keras-Preprocessing 1.0.5
    Uninstalling Keras-Preprocessing-1.0.5:
      Successfully uninstalled Keras-Preprocessing-1.0.5
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 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 idna-2.9 importlib-metadata-1.6.0 keras-preprocessing-1.1.0 markdown-3.2.2 oauthlib-3.1.0 opt-einsum-3.2.1 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.2.1 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wrapt-1.12.1 zipp-3.1.0

버전 확인

$ python3
Python 3.7.7 (default, May  8 2020, 17:06:24) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.2.0'

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

라이브러리 만들기

$ sudo bazel --host_jvm_args=-Xmx1624m build --config=noaws --config=v2 --local_cpu_resources=1 --verbose_failures //tensorflow/tools/lib_package:libtensorflow
 
 ... 생략 ...
 
INFO: Analyzed target //tensorflow/tools/lib_package:libtensorflow (4 packages loaded, 42 targets configured).
INFO: Found 1 target...
Target //tensorflow/tools/lib_package:libtensorflow up-to-date:
  bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz
INFO: Elapsed time: 77.540s, Critical Path: 73.82s
INFO: 8 processes: 8 local.
INFO: Build completed successfully, 20 total actions

라이브러리 설치

$ sudo tar -C /usr/local -xzf bazel-bin/tensorflow/tools/lib_package/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

댓글을 달아 주세요

NanoPi M4V2 : TensorFlow 2.1.0 (aarch64) 설치 (Python 3.7)

OS/NanoPi 2020. 4. 29. 01:11 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.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 NanoPi-M4v2 4.4.179 #1 SMP Tue Mar 17 16:51:26 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
6

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

TensorFlow 2.1.0 패키지 설치

TensorFlow 2.1.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0.aarch64/tensorflow-2.1.0-cp37-cp37m-linux_aarch64.whl

tensorflow 2.1.0 파이썬 패키지 설치

$ pip3 install tensorflow-2.1.0-cp37-cp37m-linux_aarch64.whl
 
Defaulting to user installation because normal site-packages is not writeable
Processing ./tensorflow-2.1.0-cp37-cp37m-linux_aarch64.whl
Collecting gast==0.2.2
  Downloading gast-0.2.2.tar.gz (10 kB)
Collecting six>=1.12.0
  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting protobuf>=3.8.0
  Downloading protobuf-3.11.3-py2.py3-none-any.whl (434 kB)
     |████████████████████████████████| 434 kB 57 kB/s 
Collecting scipy==1.4.1; python_version >= "3"
  Downloading scipy-1.4.1.tar.gz (24.6 MB)
     |████████████████████████████████| 24.6 MB 20.1 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting absl-py>=0.7.0
  Downloading absl-py-0.9.0.tar.gz (104 kB)
     |████████████████████████████████| 104 kB 10.3 MB/s 
Collecting numpy<2.0,>=1.16.0
  Downloading numpy-1.18.3.zip (5.4 MB)
     |████████████████████████████████| 5.4 MB 7.2 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting keras-applications>=1.0.8
  Downloading Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
     |████████████████████████████████| 50 kB 2.6 MB/s 
Collecting opt-einsum>=2.3.2
  Downloading opt_einsum-3.2.1-py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 803 kB/s 
Collecting tensorflow-estimator<2.2.0,>=2.1.0rc0
  Downloading tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
     |████████████████████████████████| 448 kB 6.3 MB/s 
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /usr/local/lib/python3.7/site-packages (from tensorflow==2.1.0) (0.34.2)
Collecting termcolor>=1.1.0
  Downloading termcolor-1.1.0.tar.gz (3.9 kB)
Collecting astor>=0.6.0
  Downloading astor-0.8.1-py2.py3-none-any.whl (27 kB)
Collecting google-pasta>=0.1.6
  Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 2.2 MB/s 
Collecting keras-preprocessing>=1.1.0
  Downloading Keras_Preprocessing-1.1.0-py2.py3-none-any.whl (41 kB)
     |████████████████████████████████| 41 kB 337 kB/s 
Collecting wrapt>=1.11.1
  Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting tensorboard<2.2.0,>=2.1.0
  Downloading tensorboard-2.1.1-py3-none-any.whl (3.8 MB)
     |████████████████████████████████| 3.8 MB 4.7 MB/s 
Collecting grpcio>=1.8.6
  Downloading grpcio-1.28.1.tar.gz (19.5 MB)
     |████████████████████████████████| 19.5 MB 28.0 MB/s 
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from protobuf>=3.8.0->tensorflow==2.1.0) (46.1.3)
Collecting h5py
  Downloading h5py-2.10.0.tar.gz (301 kB)
     |████████████████████████████████| 301 kB 7.5 MB/s 
Collecting requests<3,>=2.21.0
  Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.3 MB/s 
Collecting markdown>=2.6.8
  Downloading Markdown-3.2.1-py2.py3-none-any.whl (88 kB)
     |████████████████████████████████| 88 kB 2.8 MB/s 
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.14.1-py2.py3-none-any.whl (89 kB)
     |████████████████████████████████| 89 kB 1.8 MB/s 
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 6.7 MB/s 
Collecting idna<3,>=2.5
  Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 2.2 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 8.1 MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
     |████████████████████████████████| 126 kB 7.7 MB/s 
Collecting chardet<4,>=3.0.2
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 8.4 MB/s 
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting rsa<4.1,>=3.1.4
  Downloading rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 8.0 MB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 8.3 MB/s 
Collecting pyasn1>=0.1.3
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |████████████████████████████████| 77 kB 1.7 MB/s 
Building wheels for collected packages: gast, scipy, absl-py, numpy, termcolor, wrapt, grpcio, h5py
  Building wheel for gast (setup.py) ... done
  Created wheel for gast: filename=gast-0.2.2-py3-none-any.whl size=7539 sha256=f88306dd981e1f5d97a0d07cf4bac95167efcb409449c2bd79661a38de7f845c
  Stored in directory: /home/pi/.cache/pip/wheels/21/7f/02/420f32a803f7d0967b48dd823da3f558c5166991bfd204eef3
  Building wheel for scipy (PEP 517) ... done
  Created wheel for scipy: filename=scipy-1.4.1-cp37-cp37m-linux_aarch64.whl size=45320154 sha256=385a8852f2654cf478c5fdcefd1d46d11d2b480ffa17e31ce11396613d754892
  Stored in directory: /home/pi/.cache/pip/wheels/ff/bd/f9/ac5a9a019da5be2072e8a283f36d28b219762cebdd21ff3c68
  Building wheel for absl-py (setup.py) ... done
  Created wheel for absl-py: filename=absl_py-0.9.0-py3-none-any.whl size=121931 sha256=cdeba8a0a6292ed3e8b8db2056628bc6663392e426a91ba579a0b3dad43ee838
  Stored in directory: /home/pi/.cache/pip/wheels/cc/af/1a/498a24d0730ef484019e007bb9e8cef3ac00311a672c049a3e
  Building wheel for numpy (PEP 517) ... done
  Created wheel for numpy: filename=numpy-1.18.3-cp37-cp37m-linux_aarch64.whl size=10755189 sha256=d5ccd2d36a2daee6068c7243402b759aee05622a954fd0b1dbe0fbc327e7bafd
  Stored in directory: /home/pi/.cache/pip/wheels/48/d4/c6/72be820f031a875f5bac74fbf85d9467bdd973c15071b99c0c
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=857af5a939264b1619349cb045a54003c6fc59cf07dc4ed28fcc2ddba9586962
  Stored in directory: /home/pi/.cache/pip/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2
  Building wheel for wrapt (setup.py) ... done
  Created wheel for wrapt: filename=wrapt-1.12.1-cp37-cp37m-linux_aarch64.whl size=71546 sha256=4e12db67d1c3d2466e39911ecf55bf8470d1b7f0389c84e25c90f35d6b8329a8
  Stored in directory: /home/pi/.cache/pip/wheels/62/76/4c/aa25851149f3f6d9785f6c869387ad82b3fd37582fa8147ac6
  Building wheel for grpcio (setup.py) ... done
  Created wheel for grpcio: filename=grpcio-1.28.1-cp37-cp37m-linux_aarch64.whl size=21720860 sha256=d7862648f99b7cb2f97b04bb0a26e29324569b40deb1a1ce783dbe968259ec4b
  Stored in directory: /home/pi/.cache/pip/wheels/1a/57/84/d91cbd4882f6ae0adc3acba56cbf0c2c75e0263118614d1fcf
  Building wheel for h5py (setup.py) ... done
  Created wheel for h5py: filename=h5py-2.10.0-cp37-cp37m-linux_aarch64.whl size=4023293 sha256=721fba3bd94be77c8cff5517b445b6e5f913d10164c019002cc3de2041c04c1c
  Stored in directory: /home/pi/.cache/pip/wheels/58/e7/f7/d9385040f9b6919de4a5c05625c4e655999412f12c96d3c7c3
Successfully built gast scipy absl-py numpy termcolor wrapt grpcio h5py
Installing collected packages: gast, six, protobuf, scipy, absl-py, numpy, h5py, keras-applications, opt-einsum, tensorflow-estimator, termcolor, astor, google-pasta, keras-preprocessing, wrapt, grpcio, idna, certifi, urllib3, chardet, requests, markdown, oauthlib, requests-oauthlib, cachetools, pyasn1, rsa, pyasn1-modules, google-auth, google-auth-oauthlib, werkzeug, tensorboard, tensorflow
  WARNING: The scripts f2py, f2py3 and f2py3.7 are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script chardetect is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown_py is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script google-oauthlib-tool is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tensorboard is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts estimator_ckpt_converter, saved_model_cli, tensorboard, tf_upgrade_v2, tflite_convert, toco and toco_from_protos are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 gast-0.2.2 google-auth-1.14.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 h5py-2.10.0 idna-2.9 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.2.1 numpy-1.18.3 oauthlib-3.1.0 opt-einsum-3.2.1 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 six-1.14.0 tensorboard-2.1.1 tensorflow-2.1.0 tensorflow-estimator-2.1.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wrapt-1.12.1

버전 확인

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

댓글을 달아 주세요

NanoPi M4V2 : TensorFlow 2.1.0 (aarch64) - C, C++ 라이브러리 설치

OS/NanoPi 2020. 4. 29. 01:04 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.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 NanoPi-M4v2 4.4.179 #1 SMP Tue Mar 17 16:51:26 CST 2020 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
6

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

TensorFlow 라이브러리 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0.aarch64/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

댓글을 달아 주세요

NanoPi M4V2 : Python 3.7 수동 설치

OS/NanoPi 2020. 4. 28. 23:07 Posted by 파란크리스마스

출처

Python 3.7 설치

기존에 설치되어 있는 Python3.6 제거(옵션)

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

Python을 설치하기 전에 Python을 빌드하는 데 필요한 필수 패키지를 설치

$ sudo apt update
$ sudo apt install -y --no-install-recommends libbluetooth-dev tk-dev uuid-dev wget ca-certificates gnupg2 dirmngr python gcc build-essential wget zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

Python 소스 다운로드

$ PYTHON_VERSION=3.7.7
$ wget "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"

Python 빌드

$ tar -xvf Python-3.7.7.tar.xz 
$ cd Python-3.7.7/
$ sudo ./configure --enable-loadable-sqlite-extensions \
  --enable-optimizations \
  --enable-option-checking=fatal \
  --enable-shared \
  --with-system-expat \
  --with-system-ffi \
  --without-ensurepip
$ sudo make -j 4 PROFILE_TASK='-m test.regrtest --pgo \
  test_array test_base64 test_binascii test_binhex test_binop test_bytes test_c_locale_coercion \
  test_class test_cmath test_codecs test_compile test_complex test_csv test_decimal test_dict \
  test_float test_fstring test_hashlib test_io test_iter test_json test_long test_math test_memoryview \
  test_pickle test_re test_set test_slice test_struct test_threading test_time test_traceback test_unicode'
 
 ... 생략 ...
 
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm                  _sqlite3                                 
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
 
 
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd                
time                                                           
 
running build_scripts
copying and adjusting /home/pi/Python-3.7.7/Tools/scripts/pydoc3 -> build/scripts-3.7
copying and adjusting /home/pi/Python-3.7.7/Tools/scripts/idle3 -> build/scripts-3.7
copying and adjusting /home/pi/Python-3.7.7/Tools/scripts/2to3 -> build/scripts-3.7
copying and adjusting /home/pi/Python-3.7.7/Tools/scripts/pyvenv -> build/scripts-3.7
changing mode of build/scripts-3.7/pydoc3 from 644 to 755
changing mode of build/scripts-3.7/idle3 from 644 to 755
changing mode of build/scripts-3.7/2to3 from 644 to 755
changing mode of build/scripts-3.7/pyvenv from 644 to 755
renaming build/scripts-3.7/pydoc3 to build/scripts-3.7/pydoc3.7
renaming build/scripts-3.7/idle3 to build/scripts-3.7/idle3.7
renaming build/scripts-3.7/2to3 to build/scripts-3.7/2to3-3.7
renaming build/scripts-3.7/pyvenv to build/scripts-3.7/pyvenv-3.7
make[1]: Leaving directory '/home/pi/Python-3.7.7'

Python 3.7 설치

$ sudo make install
$ sudo ldconfig
$ sudo find /usr/local -depth \
  \( \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
  -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \) -exec rm -rf '{}' +
$ echo 'export PATH=$PATH:/usr/local/sbin' >> ~/.bashrc
$ source  ~/.bashrc

pip 설치

$ cd ~  
$ wget -O get-pip.py "https://github.com/pypa/get-pip/raw/d59197a3c169cef378a22428a3fa99d33e080a5d/get-pip.py"
$ sudo python3 get-pip.py --disable-pip-version-check --no-cache-dir "pip==20.0.2"

설치 확인

$ python3 --version
Python 3.7.7
$ pip3 --version
pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

댓글을 달아 주세요

NanoPi M4V2

OS/NanoPi 2020. 4. 22. 23:53 Posted by 파란크리스마스

출처

NanoPi M4V2

eMMC에 Linux 설치

출처 : Flash Image to eMMC

  • rk3399-sd-friendlydesktop-bionic-4.4-arm64-YYYYMMDD.img : eMMC사용 없이 SD 메모리에 OS 설치
  • rk3399-eflasher-friendlydesktop-bionic-4.4-arm64-YYYYMMDD.img : NanoPi-M4V2의 전원을 켜면 SD 메모리에서 부팅되고 EFlasher 유틸리티가 자동으로 실행

eMMC 용량 확인

pi@NanoPi-M4v2:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           385M  1.1M  384M   1% /run
overlay          52G  3.0G   49G   6% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           385M   16K  385M   1% /run/user/1000
/dev/mmcblk1p8   52G  3.0G   49G   6% /media/pi/userdata

Npi-config

출처 : Npi-config - FriendlyARM WiKi

npi-config 커맨드는 password, language, timezone, Hostname, SSH 활성화 / 비활성화, 자동 로그인, 하드웨어 (시리얼 / I2C / SPI / PWM / I2S) 활성화 / 비활성화 등과 같은 시스템 구성을 설정

pi@NanoPi-M4v2:~$ sudo npi-config

네트워크 정보

pi@NanoPi-M4v2:~$ sudo apt install lshw
pi@NanoPi-M4v2:~$ sudo lshw -C network
  *-network:0               
       description: Wireless interface
       physical id: 7
       logical name: wlan1
       serial: d6:12:43:95:43:fc
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=wl driverversion=0 multicast=yes wireless=IEEE 802.11
  *-network:1
       description: Wireless interface
       physical id: 8
       logical name: wlan0
       serial: d4:12:43:95:43:fc
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=wl driverversion=0 ip=192.168.0.42 multicast=yes wireless=IEEE 802.11
  *-network:2
       description: Ethernet interface
       physical id: 9
       logical name: eth0
       serial: 4a:e9:88:5c:e0:ce
       size: 1Gbit/s
       capacity: 1Gbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=st_gmac driverversion=March_2013 duplex=full ip=192.168.0.2 link=yes multicast=yes port=MII speed=1Gbit/s

hostapd

서비스 상태 확인

pi@NanoPi-M4v2:~$ sudo systemctl status hostapd.service
 
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
   Loaded: loaded (/lib/systemd/system/hostapd.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-12-27 04:50:08 UTC; 1min 6s ago
  Process: 3795 ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=1/FAILURE)
 
Dec 27 04:50:08 NanoPi-M4v2 systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator...
Dec 27 04:50:08 NanoPi-M4v2 hostapd[3795]: Configuration file: /etc/hostapd/hostapd.conf
Dec 27 04:50:08 NanoPi-M4v2 hostapd[3795]: Could not open configuration file '/etc/hostapd/hostapd.conf' for reading.
Dec 27 04:50:08 NanoPi-M4v2 hostapd[3795]: Failed to set up interface with /etc/hostapd/hostapd.conf
Dec 27 04:50:08 NanoPi-M4v2 hostapd[3795]: Failed to initialize interface
Dec 27 04:50:08 NanoPi-M4v2 systemd[1]: hostapd.service: Control process exited, code=exited status=1
Dec 27 04:50:08 NanoPi-M4v2 systemd[1]: hostapd.service: Failed with result 'exit-code'.
Dec 27 04:50:08 NanoPi-M4v2 systemd[1]: Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.

hostapd.conf 파일 생성

hostapd 서비스 활성화를 위해서 hostapd.conf 파일 생성합니다.

pi@NanoPi-M4v2:~$ sudo vi /etc/hostapd/hostapd.conf

interface=wlan1
driver=nl80211
ssid=nanopi
hw_mode=g
channel=11
wpa=2
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
macaddr_acl=0

서비스 재실행

pi@NanoPi-M4v2:~$ sudo systemctl restart hostapd.service

원격 데스크톱 설치 (실패)

desktop environment 설치

pi@NanoPi-M4v2:~$ sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Xrdp 설치

pi@NanoPi-M4v2:~$ sudo apt install xrdp xorgxrdp

xrdp 서비스 상태 확인

pi@NanoPi-M4v2:~$ sudo systemctl status xrdp
● xrdp.service - xrdp daemon
   Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-12-27 05:30:29 UTC; 15s ago
     Docs: man:xrdp(8)
           man:xrdp.ini(5)
 Main PID: 8874 (xrdp)
    Tasks: 1 (limit: 4603)
   CGroup: /system.slice/xrdp.service
           └─8874 /usr/sbin/xrdp
 
Dec 27 05:30:28 NanoPi-M4v2 systemd[1]: Starting xrdp daemon...
Dec 27 05:30:28 NanoPi-M4v2 xrdp[8873]: (8873)(547698823184)[DEBUG] Testing if xrdp can listen on 0.0.0.0 port 3389.
Dec 27 05:30:28 NanoPi-M4v2 xrdp[8873]: (8873)(547698823184)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389)
Dec 27 05:30:28 NanoPi-M4v2 systemd[1]: xrdp.service: Can't open PID file /var/run/xrdp/xrdp.pid (yet?) after start: No such file or directory
Dec 27 05:30:29 NanoPi-M4v2 systemd[1]: Started xrdp daemon.
Dec 27 05:30:30 NanoPi-M4v2 xrdp[8874]: (8874)(547698823184)[INFO ] starting xrdp with pid 8874
Dec 27 05:30:30 NanoPi-M4v2 xrdp[8874]: (8874)(547698823184)[INFO ] listening to port 3389 on 0.0.0.0

~/.xsession 생성 및 확인

pi@NanoPi-M4v2:~$ ls /usr/bin/*session
/usr/bin/dbus-run-session  /usr/bin/gnome-session  /usr/bin/gnome-session-custom-session  /usr/bin/lxsession  /usr/bin/openbox-session  /usr/bin/xfce4-session
pi@NanoPi-M4v2:~$ echo "xfce4-session" > ~/.xsession
pi@NanoPi-M4v2:~$ cat ~/.xsession
xfce4-session

댓글을 달아 주세요

NanoPi NEO2 Black(H5) : TensorFlow 2.1.0 (aarch64) 설치 (Python 3.7)

OS/NanoPi 2020. 4. 22. 23:52 Posted by 파란크리스마스

출처

리눅스 정보 확인

CPU 정보 확인

$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
 ... 생략 ...
 
Hardware        : Allwinnersun50iw2Family
Revision        : 0000
Serial          : 0000000000000000

instruction set architecture (ISA)

$ uname -i
aarch64

커널에 대한 정보

$ uname -a
Linux NanoPi-NEO2-Black 4.14.111 #1 SMP Thu Dec 19 19:12:27 CST 2019 aarch64 aarch64 aarch64 GNU/Linux

OS버전에 대한 정보

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

논리 코어 수 확인

$ grep -c processor /proc/cpuinfo
4

관련 라이브러리 설치, 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
$ pip3 install numpy
$ sudo pip3 install h5py

swap 사이즈 설정

현재 swap 사이즈 확인

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           992M         32M        616M        368K        343M        874M
Swap:          511M         21M        490M
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/mnt/512MB.swap                         file            524284  22060   -2
$ sudo swapoff /mnt/512MB.swap
$ sudo dd if=/dev/zero of=/mnt/512MB.swap bs=1M count=2048 oflag=append conv=notrunc
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 102.775 s, 20.9 MB/s
$ sudo mkswap /mnt/512MB.swap
mkswap: /mnt/512MB.swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 2.5 GiB (2684350464 bytes)
no label, UUID=f9189d6f-b98a-439e-8cbf-cce176ac2f0a
$ sudo swapon /mnt/512MB.swap
$ free -h
              total        used        free      shared  buff/cache   available
Mem:           992M         46M         91M        5.9M        853M        845M
Swap:          2.5G          0B        2.5G
$ sudo swapon -s
Filename                                Type            Size    Used    Priority
/mnt/512MB.swap                         file            2621436 0       -2

TensorFlow 2.1.0 패키지 설치

TensorFlow 2.1.0 패키지 다운로드

$ wget http://1.229.109.140:3562/tensorflow/tensorflow-2.1.0.aarch64/tensorflow-2.1.0-cp37-cp37m-linux_aarch64.whl

tensorflow 2.1.0 파이썬 페키지 설치

$ pip3 install tensorflow-2.1.0-cp37-cp37m-linux_aarch64.whl
 
 ... 생략 ...
 
Successfully built absl-py wrapt grpcio termcolor scipy gast
Installing collected packages: absl-py, tensorflow-estimator, google-pasta, wrapt, grpcio, chardet, urllib3, certifi, idna, requests, protobuf, werkzeug, pyasn1, pyasn1-modules, rsa, cachetools, google-auth, oauthlib, requests-oauthlib, google-auth-oauthlib, markdown, tensorboard, termcolor, astor, scipy, gast, opt-einsum, tensorflow
  WARNING: The script chardetect is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script google-oauthlib-tool is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown_py is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script tensorboard is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts estimator_ckpt_converter, saved_model_cli, tensorboard, tf_upgrade_v2, tflite_convert, toco and toco_from_protos are installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed absl-py-0.9.0 astor-0.8.1 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 gast-0.2.2 google-auth-1.14.1 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.28.1 idna-2.9 markdown-3.2.1 oauthlib-3.1.0 opt-einsum-3.2.1 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.9 werkzeug-1.0.1 wrapt-1.12.1

버전 확인

$ python3
Python 3.7.7 (default, Apr 14 2020, 04:35:51) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.1.0'

댓글을 달아 주세요