• Hardware Platform (Jetson / GPU) Jetson Orin Nano • DeepStream Version 6.2 • Issue Type( questions, new requirements, bugs) Question
Hi, I’m interested in understanding whether it is possible to dynamically change the gst-nvinferserver’s “interval” property value after the pipeline is running.
Things I’ve tried:
Set the property value in a callback function which has the gst-nvinferserver element in context. This does not give an error while setting the property value however this change of value is not reflected either.
Example:
def callback():
pgie.set_property("interval", 10)
def main():
global pgie
pgie = Gst.ElementFactory.make("nvinferserver", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
pgie.set_property('config-file-path', 'config.txt')
Resetting a new config file in the callback function does not help either.
Example:
def callback():
pgie.set_property("config-file-path", 'new-config.txt')
def main():
global pgie
pgie = Gst.ElementFactory.make("nvinferserver", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
pgie.set_property('config-file-path', 'config.txt')
I’ve gone through a few topics related to this but haven’t been able to locate an answer that works.
You can try to use the gst_nvevent_infer_interval_update in the opt\nvidia\deepstream\deepstream\sources\libs\gstnvdscustomhelper\gst-nvdscustomevent.c to update the interval.
Hi yuweiw, thanks for the response. Can you please provide a working example for how to use/invoke the “gst_nvevent_infer_interval_update” function? I don’t see any python bindings for this function so I’m not sure how to invoke it
def callback():
pgie.set_property("interval", 10)
def main():
global pgie
pgie = Gst.ElementFactory.make("nvinferserver", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
pgie.set_property('config-file-path', 'config.txt')
I’ve noticed that if I do a pgie.get_property(‘interval’) the next time it enters the callback function - it shows me the updated interval value on the console but it does not affect the number of inference requests being sent to the Triton Server. Is the interval sent as part of the server initialization when the pipeline starts running? I don’t think that should be the case though. Any thoughts on this?
Following up on the previous point, I’ve also tried restarting the pipeline to see if this is able to change the interval value
def callback():
pipeline.set_state(Gst.State.NULL)
pgie.set_property("interval", 10)
time.sleep(5)
pipeline.set_state(Gst.State.PLAYING)
def main():
global pgie
pgie = Gst.ElementFactory.make("nvinferserver", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
pgie.set_property('config-file-path', 'config.txt')
However this does not restart the pipeline correctly… It processes two frames and then freezes. What’s the right way to restart the pipeline? I’ve tried this with a file source and a usb-source. It freezes for both (on restart).
I also tried making the interval property a dynamically controllable property as mentioned here (Dynamic Controllable Parameters) and also set a GST_PARAM_CONTROLLABLE flag when the interval property is created in gst_nvinfer_server_class_init() at /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvinferserver/gstnvinferserver.cpp
However, this hasn’t been able to help. Are there any cpp/python examples using dynamic controllable parameters? Would this be the right approach?
Through your method, it is possible to dynamically set variables normally to the plugin, but the internal variables of nviferserver updated through events. So you can set the variables dynamically, but it doesn’t actually work. You can refer to our source code opt\nvidia\deepstream\deepstream\sources\gst-plugins\gst-nvinferserver about how this variable work within the plugin.
Noted. I’ve made a few changes to use gst_nvevent_infer_interval_update from opt\nvidia\deepstream\deepstream\sources\libs\gstnvdscustomhelper\gst-nvdscustomevent.c
Following this link I created a function that is callable from Python and within the binding function it creates a custom event followed by which it tries to send the event to the sink element of nvinferserver. However, I’m getting a segmentation fault while trying to send the event.
In my python code, I invoke the bindings function like
def callback():
interval = 10
pyds.gst_element_send_nvevent_interval_update(sys.getsizeof(pgie), '0', interval)
def main():
global pgie
pgie = Gst.ElementFactory.make("nvinferserver", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
pgie.set_property('config-file-path', 'config.txt')
I’ve made a few other changes, but the overall compilation works fine and I’m able to reach the binding function. However it results in a seg fault when trying to send the event (I’m guessing due to improper casting). Any thoughts on this?
If the casting works fine then I’m hoping to reach gst_nvinfer_server_sink_event() in opt\nvidia\deepstream\deepstream\sources\gst-plugins\gst-nvinferserver\gstnvinferserver.cpp. Am I correct in assuming this?
BTW I have to also pass stream_id to gst_nvevent_infer_interval_update. How can I get this value in the python workflow?