deepstream_python_app环境配置

deepstream_python_app环境配置

周四 12月 05 2024
448 字 · 3 分钟
jetson python 未分配标签

deepstream_python_app 环境配置

本文介绍如何在 Jetsonx86 平台 上配置 DeepStream Python 应用的开发环境,包括依赖安装、源码编译以及使用 NVIDIA 提供的预构建绑定。


1. 安装 gi 依赖

BASH
# 安装必要依赖
sudo apt install -y   libgirepository1.0-dev   gcc   libcairo2-dev   pkg-config   python3-dev   gir1.2-gtk-3.0  python-gi-dev

# 安装 Pycairo
pip3 install pycairo

# 安装 PyGObject(注意版本号写法是==)
pip3 install PyGObject==3.50.0

⚠️ 如果你使用 conda/venv,请确认 pip3 对应的 Python 环境正确。


2. 从源码安装 gst-python

某些情况下需要从源码安装 gst-python,以保证与 DeepStream 的兼容性。

BASH
# 设置环境变量(编译 gstreamer python binding 需要)
export GST_LIBS="-lgstreamer-1.0 -lgobject-2.0 -lglib-2.0"
export GST_CFLAGS="-pthread -I/usr/include/gstreamer-1.0   -I/usr/include/glib-2.0   -I/usr/lib/x86_64-linux-gnu/glib-2.0/include"

# 拉取 gst-python 源码
git clone https://github.com/GStreamer/gst-python.git
cd gst-python

# 切换到兼容的提交(5343aeb 对应 DeepStream 官方推荐版本)
git checkout 5343aeb

# 编译 & 安装
./autogen.sh PYTHON=$(which python)
./configure PYTHON=$(which python)
make -j$(nproc)
sudo make install

3. 安装 CUDA Python(可选)

如果你的环境依赖 CUDA Python,可以通过 conda 安装:

BASH
conda install -c nvidia cuda-python

4. 使用预构建 Python 绑定(推荐)

NVIDIA 已提供 x86 与 Jetson 的预构建 DeepStreamSDK Python 绑定,无需手动编译,直接下载即可:

💡 建议优先使用预构建版本,源码编译仅在需要定制或开发特殊功能时使用。


总结

配置流程推荐优先级:

  1. 直接使用 NVIDIA 提供的预构建 Python 绑定(推荐)
  2. 若有兼容性问题,再考虑 源码编译 gst-python
  3. 依赖安装过程中注意 Python 版本与环境管理(建议使用 condavenv

这样可以快速搭建 DeepStream Python App 开发环境,减少不必要的编译问题。


Thanks for reading!

deepstream_python_app环境配置

周四 12月 05 2024
448 字 · 3 分钟
jetson python 未分配标签

© sunwen | CC BY-NC-SA 4.0