Deepstream + systemctl and no X11 = daemon cannot start

Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) Jetson Xavier AGX
• DeepStream Version 6.0.1
• JetPack Version (valid for Jetson only) 4.6
• TensorRT Version 8.2.1

I am trying to run a simple script through systemctl daemons, but the daemon is always Inactive, it starts but exits.

My script is essentially the https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/blob/master/apps/deepstream-test1-rtsp-out/deepstream_test1_rtsp_out.py, with short insignificant modifications (
test1_ds_tiled.py.txt (18.7 KB).

When I run the script from terminal, it works fine:
python3 test1_ds_tiled.py -i rtsp://admin:hbyt12345@10.21.45.19:554

But when I call it by using systemctl, it doesn’t starts.
systemctl --user start deepstreampipeline.service

My systemd file is this:

ubuntu@ubuntu:~/EdgeServer$ more /home/ubuntu/.config/systemd/user/deepstreampipeline.service 
[Unit]
Description=Serviço de detecções DeepStream no edge do ecosistema Livia

[Service]
Type=forking
ExecStart=python3 /home/ubuntu/EdgeServer/test1_ds_tiled.py -i rtsp://admin:hbyt12345@10.21.45.19:554
ExecStopPost=fkill -f test1_ds_tiled.py
Restart=on-failure

[Install]
WantedBy=default.target

I have seen many posts talking about the X11 problem, but there is no display. I have also tried to debug by doing sudo python3 test1_ds_tiled.py -i rtsp://admin:hbyt12345@10.21.45.19:554, since I know that systemd doesn’t run with exactly the same environment variables from user, but it didn’t help. I am missing something, but I doesn’t understand what is going on.

Does any one have a tip?

This problem doesn’t seem to be related to deepstream.

You can use the following command to view the systemd log to analyze the cause of the error.

It is possible that you need to start your service after some system services are started.

journalctl -u deepstreampipeline

I am quite sure its about deepstream, my systemd script works with any other Python scripts, except this one with deepstream. Now my systemd script is this, so that it get’s independent from reloading it, since it will always call an .sh file:

[Unit]
Description=Serviço de detecções DeepStream no edge do ecosistema Livia
#After=graphical-session.target
#BindsTo=graphical-session.target
#PartOf=graphical-session.target
#Requisite=graphical-session.target
#ConditionEnvironment=DISPLAY
#ConditionEnvironment=XAUTHORITY

[Service]
Type=forking
ExecStart=/home/ubuntu/EdgeServer/startdp.sh
ExecStopPost=/home/ubuntu/EdgeServer/stopdp.sh
Restart=on-failure

[Install]
WantedBy=default.target
#WantedBy=graphical-session.target

And all my startdp.sh does is python3 DeepstreamPipeline.py -i rtsp://admin:hbyt12345@10.21.45.19:554 &

Is there any violation of deepstream/gstreamer trying to use X, even though its is just a console application?

This does not mean that it has anything to do with deepstream. It may just be that the dependent system services are not started by systemd.

So what you need to do now is to check the systemd log. Have you used the command above to check the log?

I use deepstream_test1_rtsp_in_rtsp_out.py as an example.

Below is my systemd configuration file. Save it to /lib/systemd/system/deepstream.service

[Unit]
Description=Deepstream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
WorkingDirectory=/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/apps/deepstream-rtsp-in-rtsp-out/
Environment="PYTHONPATH=/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/apps"
ExecStart=python3 deepstream_test1_rtsp_in_rtsp_out.py -i rtsp://"my.rtsp.camera.ip"/media/video1
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

Add deepstrem.service to startup list

sudo systemctl enable deepstream.service 

enable NetworkManager-wait-online.service, please note that this will slow down startup, but it is necessary

sudo systemctl enable NetworkManager-wait-online.service

As I said above, this is a systemd issue, not deepstream.

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