구글 코랄 TPU USB를 한번 사용해 봄

일단은 설치된 python의 버전을 확인해야 하는데 버전에 맞지 않는 런타임을 설치할 경우

아래와 같이 not a supported wheel on this platform 이라는 에러가 발생한다.

$ pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp38-cp38-linux_x86_64.whl
tflite_runtime-2.1.0.post1-cp38-cp38-linux_x86_64.whl is not a supported wheel on this platform.
$ python3 --version
Python 3.6.9

[링크 : https://coral.ai/docs/accelerator/get-started/]

 

dmesg로 확인해보니.. 다음과 같이 나온다.

[  957.819504] usb 2-1.2: new high-speed USB device number 4 using ehci-pci
[  957.928960] usb 2-1.2: New USB device found, idVendor=1a6e, idProduct=089a, bcdDevice= 1.00
[  957.928968] usb 2-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0

 

lsusb로는 아래와 같이

Bus 002 Device 004: ID 04f2:b242 Chicony Electronics Co., Ltd 
Bus 002 Device 009: ID 1a6e:089a Global Unichip Corp
Bus 002 Device 008: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 04b4:6560 Cypress Semiconductor Corp. CY7C65640 USB-2.0 "TetraHub"
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

lshw로 확인해보면 아래와 같이 UNCLAIMED 라고 뜬다.

Global Unichip corp를 검색해보니 asic 설계 서비스 회사, Fabless 회사라고 나오네.

              *-usb
                   description: USB hub
                   product: Integrated Rate Matching Hub
                   vendor: Intel Corp.
                   physical id: 1
                   bus info: usb@2:1
                   version: 0.00
                   capabilities: usb-2.00
                   configuration: driver=hub slots=8 speed=480Mbit/s
                 *-usb:0 UNCLAIMED
                      description: Generic USB device
                      vendor: Global Unichip Corp.
                      physical id: 2
                      bus info: usb@2:1.2
                      version: 1.00
                      capabilities: usb-2.10
                      configuration: maxpower=498mA speed=480Mbit/s

 

아래는 할 것 다하고 USB 가속기를 설치하지 않았을 경우 발생하는 에러

장치를 발견하지 못했다고 뜨지 않고 Failed to load delegate from libedgetpu.so.1 이라고 뜬다.

$ python3 classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg
Traceback (most recent call last):
  File "/home/minimonk/.local/lib/python3.6/site-packages/tflite_runtime/interpreter.py", line 161, in load_delegate
    delegate = Delegate(library, options)
  File "/home/minimonk/.local/lib/python3.6/site-packages/tflite_runtime/interpreter.py", line 120, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "classify_image.py", line 122, in <module>
    main()
  File "classify_image.py", line 99, in main
    interpreter = make_interpreter(args.model)
  File "classify_image.py", line 73, in make_interpreter
    {'device': device[0]} if device else {})
  File "/home/minimonk/.local/lib/python3.6/site-packages/tflite_runtime/interpreter.py", line 164, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1

 

아무튼 USB 꼽고 하니 먼가 결과는 나오는데

맞나? 싶을 정도로 단순하게 문자열로 나온다.

그리고 USB2.0으로 해서 그런가 초기 속도가 상당히 느리게 나온다.

(홈페이지에서는 10ms 미만이었던 것 같은데)

$ python3 classify_image.py --model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_labels.txt --input images/parrot.jpg
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
103.2ms
10.7ms
10.6ms
10.4ms
10.3ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.77734

 

혹시나 해서 찾아본 라이브러리 경로.

$ sudo find / -name libedgetpu.so*
/usr/lib/x86_64-linux-gnu/libedgetpu.so.1
/usr/lib/x86_64-linux-gnu/libedgetpu.so.1.0

 

 

+

회사에서 알게된 장비인데 중고로 구매할까 구매대행으로 할까하고 찾아보니

12만원 넘어서 그냥 한번 써보는걸로 만족하려는 중

 

 

+ 2020.10.21

웹캠으로 받아서 TPU로 90가지 객체가 인식 가능한지 한번 해봐? ㅋㅋㅋ

[링크 : https://ultrakid.tistory.com/6]

    [링크 : https://github.com/google-coral/edgetpu/blob/master/examples/object_detection.py]

'프로그램 사용 > google coral' 카테고리의 다른 글

edgetpu_c.h 파일 내용 분석  (0) 2022.02.07
tensorflow brace-enclosed initializer list  (4) 2022.02.07
google coral, tpu yolo  (0) 2022.01.27
coral tpu delegate example  (0) 2022.01.25
google coral  (0) 2020.10.06
Posted by 구차니