在 qemu VM 中使用 Google Coral mPCIe TPU

问题描述

我正在尝试使用 Google Coral mPCIe EdgeTPU,它在主机系统和 qemu 虚拟机中运行良好,但我无法让任何示例正常工作。

主机系统:Ubuntu 20.04

访客系统:Fedora 33 with Python 3.8

经过反复试验,我已经安装了必要的驱动程序和工具 (edgetpu),设置了从主机到来宾系统的 PCI 直通,并且 Edge TPU 设备按预期列在来宾系统中(/dev/apex_0 存在且 Coral Edge TPU 列在 lspci 调用中)。

但是当我尝试启动其中一个示例时,我收到以下错误消息:

RuntimeError: Error in device opening (/dev/apex_0)!

和 dmesg 列出以下错误

RAM did not enable within timeout (12000 ms)
Error in device open cb: -110

任何帮助将不胜感激。

编辑:

我尝试从头开始设置 VM,现在我从控制台收到不同的消息,但 dmesg 错误保持不变。用户已在相应的顶点组中。

带有相应函数调用的新错误消息:

python3 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
Traceback (most recent call last):
  File "/home/fti/tf-tpu/lib64/python3.8/site-packages/tflite_runtime/interpreter.py",line 152,in load_delegate
    delegate = Delegate(library,options)
  File "/home/fti/tf-tpu/lib64/python3.8/site-packages/tflite_runtime/interpreter.py",line 111,in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "examples/classify_image.py",line 84,in <module>
    main()
  File "examples/classify_image.py",line 61,in main
    interpreter = make_interpreter(*args.model.split('@'))
  File "/home/fti/tf-tpu/lib64/python3.8/site-packages/pycoral/utils/edgetpu.py",line 66,in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/home/fti/tf-tpu/lib64/python3.8/site-packages/pycoral/utils/edgetpu.py",line 42,in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB,options or {})
  File "/home/fti/tf-tpu/lib64/python3.8/site-packages/tflite_runtime/interpreter.py",line 154,in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

其他信息:

ls -la /dev/apex_0 
crw-rw----. 1 root apex 120,0 25. Jan 11:33 /dev/apex_0
lspci -nnk
06:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]
    Subsystem: Global Unichip Corp. Coral Edge TPU [1ac1:089a]
    Kernel driver in use: apex
    Kernel modules: apex

编辑: 我已经尝试将 Coral USB Accelerator 与我的 Fedora VM 一起使用,并且没有任何问题。所以我的猜测是到 VM 的 PCI 直通不能 100% 正确工作。为了设置 PCI 直通,我按照 here 中描述的指南对设备 ID 进行了调整。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)