JetBot项目原生环境配置指南(非Docker方案)
前言
JetBot作为基于NVIDIA Jetson平台的开源智能小车项目,为AI教育和开发提供了绝佳的平台。本文将详细介绍如何在Jetson设备上配置原生运行环境(非Docker方案),适合希望直接与硬件交互、进行深度定制的开发者。
环境准备
1. 基础系统安装
首先需要确保设备已安装NVIDIA JetPack SDK,这是Jetson平台的完整开发套件,包含:
- Ubuntu操作系统
- CUDA加速库
- cuDNN深度学习库
- TensorRT推理优化器
建议使用最新版本的JetPack以获得最佳性能支持。
2. 关键依赖安装
PyTorch框架
PyTorch是JetBot项目的主要AI框架,需要安装适配Jetson平台的版本。由于ARM架构的特殊性,不能直接使用pip安装,必须使用NVIDIA官方提供的预编译包。
Node.js环境
Jupyter Lab依赖Node.js运行前端组件,推荐安装LTS版本:
curl -sL https://deb.nodesource.com/setup_10.x | bash -
sudo apt-get install -y nodejs libffi-dev
Jupyter Lab配置
1. 核心组件安装
sudo python3 -m pip install jupyter jupyterlab
jupyter labextension install @jupyter-widgets/jupyterlab-manager
2. 图像交互组件
为支持道路跟随等示例中的图像点击功能,需要额外安装:
sudo apt-get install -y libssl1.0-dev
git clone https://github.com/jaybdub/jupyter_clickable_image_widget
cd jupyter_clickable_image_widget
git checkout tags/v0.1
sudo pip3 install -e .
jupyter labextension install js
jupyter lab build
cd ..
3. 其他依赖项
sudo apt-get update && apt-get install -y process-manager unzip
sudo apt install -y python3-smbus && pip3 install pyzmq
性能优化组件
torch2trt安装(可选)
这个工具可以将PyTorch模型转换为TensorRT格式,显著提升推理速度:
git clone https://github.com/NVIDIA-AI-IOT/torch2trt
cd torch2trt
python3 setup.py install
cd ..
JetBot核心包安装
git clone https://github.com/NVIDIA-AI-IOT/jetbot
cd jetbot
sudo python3 setup.py install
如果计划修改JetBot源代码,建议使用开发模式安装:
sudo python3 setup.py develop
系统服务配置
1. Jupyter Lab密码设置
jupyter notebook password
2. 创建开机自启服务
创建jetbot_jupyter.service
文件:
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
User=jetson
ExecStart=/bin/sh -c "jupyter lab --ip=0.0.0.0 --no-browser --allow-root"
WorkingDirectory=/home/jetson
Restart=Always
[Install]
WantedBy=multi-user.target
部署服务:
sudo cp jetbot_jupyter.service /etc/systemd/system/
sudo systemctl enable jetbot_jupyter
3. IP显示服务
创建jetbot_display.service
文件:
[Unit]
Description=IP Display Service
[Service]
Type=simple
User=jetson
ExecStart=/bin/sh -c "python3 -m jetbot.apps.stats"
WorkingDirectory=/home/jetson
Restart=Always
[Install]
WantedBy=multi-user.target
部署服务:
sudo cp jetbot_display.service /etc/systemd/system/
sudo systemctl enable jetbot_display
验证与使用
完成上述配置后,重启设备即可:
- OLED屏将显示设备IP地址
- Jupyter Lab服务会自动启动
- 通过浏览器访问
https://<设备IP>:8888
即可开始编程
常见问题
- 密码设置不生效:检查
~/.jupyter/jupyter_notebook_config.json
文件是否生成 - 服务启动失败:使用
journalctl -u jetbot_jupyter -b
查看日志 - 显示服务异常:确认已正确连接OLED屏并安装I2C驱动
结语
原生环境配置虽然步骤较多,但提供了更直接的硬件访问能力和更高的定制自由度。适合需要进行深度开发的用户。配置完成后,您就可以开始探索JetBot的各种AI功能了,包括物体识别、自主导航等有趣的应用。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考