google-coral / pycoral

Python API for ML inferencing and transfer-learning on Coral devices
https://coral.ai
Apache License 2.0
347 stars 145 forks source link

Docker container cannot access EdgeTPU #88

Closed johnsonafool closed 1 year ago

johnsonafool commented 2 years ago

Description

Hello, I am now doing project related to use EdgeTPU usb to making the inference of car flow and velocity, since I would like to test some code locally on my laptop (M1 sys mac), I feel like it's a good try with docker, however, when I set up the env like the tutorial on offical doc, the comtainer inside cannot access my TPU device, so I wonder it is the problem exisist on my laptop, since I also try the procedure of start a docker container on Ubntu and it just work fine.

Click to expand! ### Issue Type Support ### Operating System Mac OS ### Coral Device Dev Board, USB Accelerator, Enviro Board, Coral Camera ### Other Devices _No response_ ### Programming Language Python 3.8 ### Relevant Log Output _No response_
hjonnala commented 2 years ago

Please try the follow steps:

mkdir usb
cd usb
touch Dockerfile

Place the below content on Dockerfile

FROM debian:sid-slim
WORKDIR /home
ENV HOME /home
RUN cd ~
RUN apt-get -y update
RUN apt-get -y dist-upgrade
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y git nano python3.9 python3.9-venv python3-pip wget usbutils curl unzip sudo python3.9-dev pkg-config udev

RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" \
| tee /etc/apt/sources.list.d/coral-edgetpu.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get update

RUN sudo apt-get install libedgetpu1-std

RUN mkdir coral
RUN git clone https://github.com/google-coral/pycoral.git coral/pycoral

RUN bash coral/pycoral/examples/install_requirements.sh classify_image.py

RUN python3.9 -m pip install --extra-index-url https://google-coral.github.io/py-repo/ pycoral~=2.0

RUN python3.9 -m pip install pyftdi pyserial mendel-development-tool

# docker build -t "coral-usb" .
# docker run -it --device=/dev/bus/usb:/dev/bus/usb coral-usb 
# cd coral/pycoral
# python3.9 examples/classify_image.py   --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite    --labels test_data/inat_bird_labels.txt   --input test_data/parrot.jpg
docker build -t "coral-usb" .
docker run -it --device=/dev/bus/usb:/dev/bus/usb coral-usb 
cd coral/pycoral
python3.9 examples/classify_image.py   --model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite    --labels test_data/inat_bird_labels.txt   --input test_data/parrot.jpg

Here are the logs for reference: https://github.com/hjonnala/snippets/blob/main/USB/docker_logs.txt

google-coral-bot[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No