Is building gst-python from source necessary?

• Hardware Platform: Jetson AGX Orin
• DeepStream Version: 6.2
• JetPack Version: 5.1
• Issue Type: Question

Hello, I have a question about the building of python bindings for Deepstream. I have been following the readme here: deepstream_python_apps/bindings at v1.1.6 · NVIDIA-AI-IOT/deepstream_python_apps · GitHub. I am curious about the following step which installs gst-python (using the submodule, currently pointing to the tag 1.14.5):

cd 3rdparty/gst-python/
./autogen.sh
make
sudo make install

This step however depends on the where does python point. If pointing to python2.7, the gst-python libraries are going to be installed in:

/usr/local/lib/python2.7/dist-packages/gi/overrides/

Using python3 as the default python will install the files in

/usr/local/lib/python3.8/site-packages/gi/overrides

This is something I had stumbled upon since I am using python2 as the default interpreter but the following code (and Deepstream applications) worked ok for me (even though the bindings did not compile for python3 at all).

import gi

gi.require_version('Gst', '1.0') # This is fine
from gi.repository import Gst

This is fine, since the necessary packages are already installed with the following command (copied from the same guide).

apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git python-dev \
    python3 python3-pip python3.8-dev cmake g++ build-essential libglib2.0-dev \
    libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev

The question is:
Given that using gstreamer in Python is already enabled by installing gir1.2-gstreamer-1.0, gir1.2-gst-plugins-base-1.0 packages (already installed in the apt script above), is it not necessary to compile gst-python from source?
Is this correct, or am I missing something.

1 Like

please refer to the architecture of Python Bindingsdeepstream_python_apps, gst-python is necessary, we need to compile it because there is no at default.

Hello,

thank you for the reply. Could you please expand more on the following statement? I am not sure I understand correctly what it means.

gst-python is necessary, we need to compile it because there is no at default

To elaborate even more, in the meantime, I have used the docker image nvcr.io/nvidia/deepstream-l4t:6.2-base and compiled pyds from source. I have skipped the gst-python installation step from this tutorial. Afterwards, I have been successful in running deepstream apps in Python without any issue.

Moreover, I have then repeated this procedure but without skipping the gst-python compilation and run a quick test:

strace -e trace=openat python3 -c "import gi; gi.require_version('Gst','1.0'); from gi.repository import Gst"

With this, i have noticed that Python is not using the compiled version binary, but it prefers the one installed in the section 1.2 of the tutorial via apt-get (although not explicitely listed, there is a dependency on the package python3-gst-1.0).

openat(AT_FDCWD, "/usr/lib/python3/dist-packages/gi/overrides/_gi_gst.cpython-38-x86_64-linux-gnu.so", O_RDONLY|O_CLOEXEC) = 3

All of this has led me to the conclusion that the step 1.4 could be potentially skipped.

1 Like
  1. did you meet this compilaton error in nvcr.io/nvidia/deepstream-l4t:6.2-base container? bindanalyticsmeta.hpp:21:10: fatal error: nvds_analytics_meta.h: No such file or directory
  1. which deepstream apps can you run successfully?
  1. which binary are you referring to?

Hello,
allow me to expand on each of the three points:

  1. The base docker does not contain Deepstream headers (to save space I presume), but we can easily mount them from the host machine (or in Dockerfile, use the COPY command to add them. I am also mounting samples in order to use the packaged models to run sample applications, but for the compilation alone, it is not necessary.

This is how I started the docker container when I was testing the installation.

docker run -it -v  /lib/modules/5.10.104-tegra:/lib/modules/5.10.104-tegra  \
-v /opt/nvidia/deepstream/deepstream/sources/includes/:/opt/nvidia/deepstream/deepstream/sources/includes/ \
-v /opt/nvidia/deepstream/deepstream/samples/:/opt/nvidia/deepstream/deepstream/samples/\
 --net=host --runtime nvidia  -e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix   nvcr.io/nvidia/deepstream-l4t:6.2-base

I have installed the packages

bash user_additional_install.sh
apt update && apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git python-dev \
    python3 python3-pip python3.8-dev cmake g++ build-essential libglib2.0-dev \
    libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev libgstreamer-plugins-base1.0-dev

Please, take note that I have added the unlisted package libgstreamer-plugins-base1.0-dev to install the header video.h. The rest is taken from the tutorial mentioned in my first post.

I have cloned and installed pyds bindings

cd sources && \
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps && \
cd deepstream_python_apps/bindings && \
git checkout v1.1.6 && \
git submodule update --init && \
mkdir build && \
cd build && \
cmake .. -DPIP_PLATFORM=linux_aarch64 && \
make -j8

And installed the built bindings.

python3 -m pip install --upgrade pip && \
python3 -m pip install ./pyds-1.1.6-py3-none-linux_aarch64.whl

I have tested this just now on a Jetson Orin, Jetpack 5.1 without any problem whatsoever.

  1. I have been using mainly our proprietary applications written on top of Deepstream SDK, but for testing purposes, I like to use some of the sample applications. For example deepstream_test_2 is a very nice way to test out inference, tracking, and visualization.
./deepstream_test_2.py /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264

As we can see, everything seems to work just fine. Please note that i have mounted my X11 display into the container as instructed here: DeepStream-l4t | NVIDIA NGC .

  1. I am talking about the dynamic library _gi_gst.cpython-38-x86_64-linux-gnu.so

thanks for your sharing, using the same steps in the last comment, I can also run deepstream-test2 successfully without installing Gst-python. I will check.

After checking, installing python3-gst-1.0 and gst-python did the similar thing, they all will install /usr/lib/python3/dist-packages/gi/overrides/_gi_gst.cpython-38-aarch64-linux-gnu.so, here are the installing logs:
install-python3-gst-1.0.txt (3.7 KB)
install-gst-python.txt (8.2 KB)

Hello,

thank you for verifying. Can you please confirm that we can hence use the apt package to save time when installing Gst Python?

As a side note, I have noticed, that there are currently two Markdown documents concerned with the installation of Gst-python:

Both use a different procedure with different ENV vars and library version (one uses gst-python version 1.14.5 and the other 1.16.2). Pehaps this can be potentially confusing for other developers, wanting to compile the dependencies from source.

Sometime we will upgrade Gstreamer, Gst-python should be upgraded accordingly, so I suggest to compile Gst Python, and we have verified the specified versions are compatible.

thanks for your sharing, we will check.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.