0006 MPTPU(M.2 E):修订间差异
无编辑摘要 |
|||
第143行: | 第143行: | ||
<code>sudo reboot</code> | <code>sudo reboot</code> | ||
4.5 验证模块检测以及驱动安装 | === 4.5 验证模块检测以及驱动安装 === | ||
系统启动后验证模块检测以及驱动安装 | 系统启动后验证模块检测以及驱动安装 | ||
第161行: | 第160行: | ||
16 | 16 | ||
=== 4. | === 4.6 代码运行环境配置 === |
2024年7月18日 (四) 10:13的版本
关键词
树莓派5、PCIE、TPU、DTPU、驱动安装、操作演示、AI、google、Coral
一、简介
MPW7/TPU是一款专为树莓派5设计的TPU扩展板,通过PCIE 1x Gen2驱动来自Coral的TPU模组。树莓派系统下使用TPU模块需要安装驱动以及操作环境配置,本文操作演示基于MPW7/TPU扩展板,对于双TPU的驱动安装也适用。
注意:此操作演示需要确保能连通外网(需自备方法),否则许多文件无法下载。
二、硬件资源
关于双TPU的官方描述(本文档所演示的单TPU也可参考此描述):
PRODUCT DETAILS
The Coral M.2 Accelerator with Dual Edge TPU is an M.2 module that brings two Edge TPU coprocessors to existing systems and products with an available M.2 E-key slot.
Features
Performs high-speed ML inferencing: Each Edge TPU coprocessor is capable of performing 4 trillion operations per second (4 TOPS), using 2 watts of power. For example, it can execute state-of-the-art mobile vision models such as MobileNet v2 at almost 400 FPS, in a power-efficient manner. With the two Edge TPUs in this module, you can double the inferences per second (8 TOPS) in several ways, such as by running two models in parallel or pipelining one model across both Edge TPUs.
Works with Debian Linux and Windows: Integrates with Debian-based Linux or Windows 10 systems with a compatible card module slot.
Supports TensorFlow Lite: No need to build models from the ground up. TensorFlow Lite models can be compiled to run on the Edge TPU.
Supports AutoML Vision Edge: Easily build and deploy fast, high-accuracy custom image classification models to your device with AutoML Vision Edge.
Description
The Coral M.2 Accelerator with Dual Edge TPU is an M.2 module (E-key) that includes two Edge TPU ML accelerators, each with their own PCIe Gen2 x1 interface.
The Edge TPU is a small ASIC designed by Google that accelerates TensorFlow Lite models in a power efficient manner: each one is capable of performing 4 trillion operations per second (4 TOPS), using 2 watts of power—that's 2 TOPS per watt. For example, one Edge TPU can execute state-of-the-art mobile vision models such as MobileNet v2 at almost 400 frames per second. This on-device ML processing reduces latency, increases data privacy, and removes the need for a constant internet connection.
With the two Edge TPUs in this module, you can double the inferences per second (8 TOPS) in several ways, such as by running two models in parallel or pipelining one model across both Edge TPUs.
三、系统烧写
3.1 本文档使用的镜像为2024-07-04-raspios-bookworm-arm64-full.img.xz(树莓派OS,Raspberry Pi OS with desktop and recommended software)。
树莓派OS下载地址:
https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit
3.2 系统烧写在SD(TF)卡上,点击直达烧写方法说明。
四、驱动安装与配置
4.1 配置config.txt
系统启动后打开树莓派终端输入命令:
sudo nano /boot/firmware/config.txt
在文件最下方添加以下代码:
dtparam=pciex1
kernel=kernel8.img
dtoverlay=pineboards-hat-ai
01
02
代码添加成功后,保存并重启系统:
sudo reboot
4.2 确认软件环境
系统重启后打开打开树莓派终端输入命令:
uname -r
确保内核版本大于4.18后输入:
lsmod | grep apex
确保没有输出则可以开始安装TPU驱动。
03
4.3 安装必要软件
确保网络能连通外网(需自备方法)后,添加Google TPU软件库:
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
04
05
添加完成后更新软件列表
sudo apt-get update
06
更新完成后安装必要的软件
sudo apt-get install cmake libedgetpu1-std devscripts debhelper dkms dh-dkms
07
08
4.4 安装Gasket Driver
依次输入以下命令安装Gasket Driver
git clone https://github.com/google/gasket-driver.git
cd gasket-driver
sudo debuild -us -uc -tc -b
cd ..
sudo dpkg -i gasket-dkms_1.0-18_all.deb
09
10
11
安装完成后输入命令确保驱动以及软件安装成功
sudo apt-get install gasket-dkms libedgetpu1-std
12
接下来添加udev rule去获得设备操作权限
sudo sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules"
添加用户到apex
sudo groupadd apex
sudo adduser $USER apex
13
设置完成后重启系统
sudo reboot
4.5 验证模块检测以及驱动安装
系统启动后验证模块检测以及驱动安装
lspci -nn | grep 089a
ls /dev/apex_0
14
这里板载单TPU,因此可以看到一个TPU模块。
输入sudo lspci -v
可以看到驱动加载
15
16