.. _run_multi_pipelines: Run Multiple (Concurrent) Pipelines ################################### The Palette SDK supports running multiple (upto 4) pipelines concurrently on a single MLSoC device. This option, in which tasks are interleaved (managed at the same time), offers efficient resource management across pipelines enabling high-throughput workloads. **Steps** .. tabs:: .. tab:: Standalone 1. You must have at least two or more uniquely named working GStreamer pipelines. 2. In the SDK, enable the multi-pipeline feature by updating the application.json file for each pipeline as shown below. * Configure the ``multi-pipeline`` parameter for the plugin ``simaaiprocessmla`` to be ``true``. That is, ``multi-pipeline = true``. For example, .. code:: console "gst": "rtspsrc location= ! rtph264depay wait-for-keyframe=true ! h264parse ! 'video/x-h264, parsed=true, stream-format=(string)byte-stream, alignment=(string)au, width=(int)[1,4096], height=(int)[1,4096]' ! simaaidecoder sima-allocator-type=2 name='decoder' ! tee name=source ! 'video/x-raw' ! simaaiprocesscvu name=simaai_preprocess num-buffers=5 ! simaaiprocessmla multi-pipeline=true name=simaai_process_mla num-buffers=5 ! simaaiboxdecode name='simaai_boxdecode' ! 'application/vnd.simaai.tensor' ! overlay. source. ! 'video/x-raw' ! simaai-overlay2 name=overlay render-info='input::decoder,bbox::simaai_boxdecode' labels-file='/data/simaai/applications/YoloV7/share/overlay/labels.txt' ! simaaiencoder enc-bitrate=4000 name=encoder ! h264parse ! rtph264pay ! udpsink host= port=" 3. Run the command ``mpk create`` to generate an updated mpk for the pipeline. 4. On the host side, update the ``PORT`` for each of the pipeline output to view the streams one by one running concurrently. For example, .. code:: console GST_DEBUG=0 gst-launch-1.0 udpsrc port= ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! 'video/x-h264,stream-format=byte-stream,alignment=au' ! avdec_h264 ! fpsdisplaysink sync=0 5. Use the command ``mpk deploy`` to run the pipeline on the SoC device in the appropriate sequence configured in the application.json file. 6. Repeat steps 2, 3, and 4, above, for each pipeline you will be running. .. tab:: PCIe 1. Make sure you have a host machine with a SiMa.ai PCIe HHHL card appropriately installed in its slot. Additionally, you must have at least two or more uniquely named working GStreamer pipelines. 2. In the SDK, enable the multi-pipeline feature by updating the application.json file for each pipeline as shown below. * Configure the ``queue`` parameter in the plugins, simaaipciesrc and simaaipciesink, for the order in which the pipeline will run. Use one queue for each pipeline. * Configure the ``multi-pipeline`` parameter for the plugin ``simaaiprocessmla`` to be ``true``. That is, ``multi-pipeline = true``. For example, .. code:: console "gst": "simaaipciesrc queue=3 ! tee name='allegro_tee' ! queue2 ! simaaiprocesscvu name=simaai_preprocess num-buffers=5 ! simaaiprocessmla multi-pipeline=true name=simaai_process_mla num-buffers=5 ! simaaiboxdecode name='simaai_boxdecode' ! 'application/vnd.simaai.tensor' ! simaai-overlay2 name=overlay render-info='input::simaaipciesrc,bbox::simaai_boxdecode' labels-file='/data/simaai/applications/YoloV7_PCIe/share/overlay/labels.txt' ! simaaipciesink queue=3 allegro_tee. ! queue2 ! overlay." 3. Run the command ``mpk create`` to generate an updated mpk for the pipeline. 4. On the host side, update the ``queue`` parameter of the plugin ``pciehost`` for each gst-pipeline. Make sure to use the same queue number as used in the corresponding JSON file of the pipeline. For example, .. code:: console gst-launch-1.0 rtspsrc location= ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! video/x-raw,format=NV12 ! pciehost queue=3 queuedepth=8 showfps=1 ! videoparse format=nv12 width=1280 height=720 ! autovideoconvert ! autovideosink 5. Use the command ``mpk deploy`` to run the pipeline on the SoC device in the appropriate sequence configured in the application.json file. 6. Repeat steps 2, 3, and 4, above, for each pipeline you will be running.