Error in initializing nvenc context

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
A5000 laptop GPU, on Ubuntu 20.04

• DeepStream Version
6.3
• TensorRT Version

nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-12.0/now 1.0-1 amd64 [installed,local]
tensorrt-dev/unknown,unknown,now 8.6.1.6-1+cuda12.0 amd64 [installed,upgradable to: 10.9.0.34-1+cuda12.8]
tensorrt-libs/unknown,unknown,now 8.6.1.6-1+cuda12.0 amd64 [installed,upgradable to: 10.9.0.34-1+cuda12.8]
tensorrt/unknown,unknown,now 8.6.1.6-1+cuda12.0 amd64 [installed,upgradable to: 10.9.0.34-1+cuda12.8]

• NVIDIA GPU Driver Version (valid for GPU only)

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.124.06             Driver Version: 570.124.06     CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA RTX A5000 Laptop GPU    On  |   00000000:01:00.0  On |                  N/A |
| N/A   60C    P8             16W /   90W |     314MiB /  16384MiB |     13%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
+-----------------------------------------------------------------------------------------+

although I originally had the 470.xx driver when I started getting this error and uninstalled/reinstalled/upgraded the driver in process of troubleshooting this issue

• Issue Type( questions, new requirements, bugs)
This seems very similar to this issue: ERROR from nvv4l2h264enc. Could not get/set settings from/on resource. Device is in streaming mode

I have started getting a lot of these errors when starting pipelines:

Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed

• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

For instance here’s the output of one of the deepstream apps:

deepstream-app -c /opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/source4_1080p_dec_infer-resnet_tracker_sgie_tiled_display_int8.txt 
libEGL warning: MESA-LOADER: failed to retrieve device information

libEGL warning: DRI2: failed to authenticate
0:00:04.390909617 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_2> NvDsInferContext[UID 6]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1988> [UID = 6]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:610 [Implicit Engine Info]: layers num: 2
0   INPUT  kFLOAT input_1         3x224x224       
1   OUTPUT kFLOAT predictions/Softmax 20x1x1          

0:00:04.568478987 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_2> NvDsInferContext[UID 6]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2091> [UID = 6]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine
0:00:04.573337678 10049 0x563c60111690 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<secondary_gie_2> [UID 6]: Load new model:/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/config_infer_secondary_carmake.txt sucessfully
0:00:08.246213303 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_1> NvDsInferContext[UID 5]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1988> [UID = 5]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:610 [Implicit Engine Info]: layers num: 2
0   INPUT  kFLOAT input_1         3x224x224       
1   OUTPUT kFLOAT predictions/Softmax 12x1x1          

0:00:08.428340892 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_1> NvDsInferContext[UID 5]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2091> [UID = 5]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine
0:00:08.430388255 10049 0x563c60111690 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<secondary_gie_1> [UID 5]: Load new model:/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/config_infer_secondary_carcolor.txt sucessfully
0:00:12.101397882 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 4]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1988> [UID = 4]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:610 [Implicit Engine Info]: layers num: 2
0   INPUT  kFLOAT input_1         3x224x224       
1   OUTPUT kFLOAT predictions/Softmax 6x1x1           

0:00:12.285438853 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<secondary_gie_0> NvDsInferContext[UID 4]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2091> [UID = 4]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine
0:00:12.286287925 10049 0x563c60111690 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<secondary_gie_0> [UID 4]: Load new model:/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/config_infer_secondary_vehicletypes.txt sucessfully
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
[NvMultiObjectTracker] Loading TRT Engine for tracker ReID...
[NvMultiObjectTracker] Loading Complete!
ERROR: [TRT]: 3: [runtime.cpp::~Runtime::346] Error Code 3: API Usage Error (Parameter check failed at: runtime/rt/runtime.cpp::~Runtime::346, condition: mEngineCounter.use_count() == 1. Destroying a runtime before destroying deserialized engines created by the runtime leads to undefined behavior.
)
[NvMultiObjectTracker] Initialized
0:00:16.070228557 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1988> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Primary_Detector/resnet10.caffemodel_b4_gpu0_int8.engine
INFO: ../nvdsinfer/nvdsinfer_model_builder.cpp:610 [Implicit Engine Info]: layers num: 3
0   INPUT  kFLOAT input_1         3x368x640       
1   OUTPUT kFLOAT conv2d_bbox     16x23x40        
2   OUTPUT kFLOAT conv2d_cov/Sigmoid 4x23x40         

0:00:16.251219966 10049 0x563c60111690 INFO                 nvinfer gstnvinfer.cpp:682:gst_nvinfer_logger:<primary_gie> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2091> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/../../models/Primary_Detector/resnet10.caffemodel_b4_gpu0_int8.engine
0:00:16.253038472 10049 0x563c60111690 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<primary_gie> [UID 1]: Load new model:/opt/nvidia/deepstream/deepstream-6.3/samples/configs/deepstream-app/config_infer_primary.txt sucessfully

Runtime commands:
	h: Print this help
	q: Quit

	p: Pause
	r: Resume

NOTE: To expand a source in the 2D tiled display and view object details, left-click on the source.
      To go back to the tiled display, right-click anywhere on the window.


**PERF:  FPS 0 (Avg)	FPS 1 (Avg)	FPS 2 (Avg)	FPS 3 (Avg)	
**PERF:  0.00 (0.00)	0.00 (0.00)	0.00 (0.00)	0.00 (0.00)	
** INFO: <bus_callback:239>: Pipeline ready

Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
ENC_CTX(0x7fab8400d210) Error in initializing nvenc context 
ERROR from sink_sub_bin_encoder2: Could not get/set settings from/on resource.
Debug info: gstv4l2object.c(3536): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline/GstBin:processing_bin_0/GstBin:sink_bin/GstBin:sink_sub_bin2/nvv4l2h264enc:sink_sub_bin_encoder2:
Device is in streaming mode
Quitting
nvstreammux: Successfully handled EOS for source_id=0
nvstreammux: Successfully handled EOS for source_id=1
nvstreammux: Successfully handled EOS for source_id=2
nvstreammux: Successfully handled EOS for source_id=3
[NvMultiObjectTracker] De-initialized
App run failed

could you share the output of “gst-inspect-1.0 |grep nvv4l2h264enc” and “ldd /usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideo4linux2.so” ?

$ gst-inspect-1.0 |grep nvv4l2h264enc
nvvideo4linux2:  nvv4l2h264enc: V4L2 H.264 Encoder

$ ldd /usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideo4linux2.so
	linux-vdso.so.1 (0x00007ffe1610e000)
	libnvbufsurface.so => ///opt/nvidia/deepstream/deepstream-6.3/lib/libnvbufsurface.so (0x00007facaeb97000)
	libnvbufsurftransform.so => ///opt/nvidia/deepstream/deepstream-6.3/lib/libnvbufsurftransform.so (0x00007facaced7000)
	libgstnvcustomhelper.so => ///opt/nvidia/deepstream/deepstream-6.3/lib/libgstnvcustomhelper.so (0x00007facaced2000)
	libgstallocators-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstallocators-1.0.so.0 (0x00007facace94000)
	libgstnvdsseimeta.so => ///opt/nvidia/deepstream/deepstream-6.3/lib/libgstnvdsseimeta.so (0x00007facace8d000)
	libgstreamer-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0 (0x00007facacd46000)
	libgstbase-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0 (0x00007facaccc8000)
	libgstvideo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libgstvideo-1.0.so.0 (0x00007facacc17000)
	libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007facacaed000)
	libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007facaca8d000)
	libv4l2.so.0 => /usr/lib/x86_64-linux-gnu/libv4l2.so.0 (0x00007facac986000)
	libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6 (0x00007facac794000)
	libnvbuf_fdmap.so => ///opt/nvidia/deepstream/deepstream-6.3/lib/libnvbuf_fdmap.so (0x00007facac78e000)
	libcudart.so.12 => /usr/local/cuda-12.1/lib64/libcudart.so.12 (0x00007facac4e7000)
	libcuda.so.1 => /usr/lib/x86_64-linux-gnu/libcuda.so.1 (0x00007faca8022000)
	libpthread.so.0 => /usr/lib/x86_64-linux-gnu/libpthread.so.0 (0x00007faca7fff000)
	libnppc.so.12 => /usr/local/cuda-12.1/lib64/libnppc.so.12 (0x00007faca7c6e000)
	libnppig.so.12 => /usr/local/cuda-12.1/lib64/libnppig.so.12 (0x00007faca5472000)
	libnppidei.so.12 => /usr/local/cuda-12.1/lib64/libnppidei.so.12 (0x00007faca4834000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007faca4652000)
	libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007faca4637000)
	libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007faca4631000)
	libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x00007faca44e0000)
	libdl.so.2 => /usr/lib/x86_64-linux-gnu/libdl.so.2 (0x00007faca44da000)
	liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007faca4457000)
	libpcre.so.3 => /usr/lib/x86_64-linux-gnu/libpcre.so.3 (0x00007faca43e4000)
	libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007faca43d8000)
	libv4lconvert.so.0 => /usr/lib/x86_64-linux-gnu/libv4lconvert.so.0 (0x00007faca434f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007facaebf6000)
	librt.so.1 => /usr/lib/x86_64-linux-gnu/librt.so.1 (0x00007faca4345000)

I am running deepstream inside of a docker container with a non-sudo user, not in host networking mode.

  1. for simplicity, could you try these two commands?
    gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! fakesink
    gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! video/x-raw(memory:NVMM),format=I420 ! nvv4l2h264enc bitrate=1000000 ! filesink location=test.264
$ sudo gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed

(sudo doesn’t change things)

$ gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! video/x-raw\(memory:NVMM\),format=I420 ! nvv4l2h264enc bitrate=1000000 ! filesink location=test.264
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed

I tried installing the drivers via .run script downloaded directly from nvidia, and in that case, the drivers never loaded at all, Ubuntu just kept falling back to the open source drivers so the card wasn’t being recognized at all. I also tried the headless drivers without success.

I saw one other post about the NVIDIA_DRIVER_CAPABILITIES:

$ echo $NVIDIA_DRIVER_CAPABILITIES 
compute,utility
me@indominus_rex2:/workspaces/nvidia ()
$ export NVIDIA_DRIVER_CAPABILITIES=all
me@indominus_rex2:/workspaces/nvidia ()
$ gst-launch-1.0 filesrc location=/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! video/x-raw\(memory:NVMM\),format=I420 ! nvv4l2h264enc bitrate=1000000 ! filesink location=test.264
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed
Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed

Any other ideas would be appreciated.

I think I must be seeing two errors. I rebuilt my container where the last line or so had

ENV NVIDIA_DRIVER_CAPABILITIES=all

and re-ran and now I don’t get the

Error while setting IOCTL
Invalid control
S_EXT_CTRLS for CUDA_GPU_ID failed

errors, however I do still get the Error in initializing the nvenc context when running a pipeline that uses the encoder

It looks like a setup problem. You can refer to our dGPU model Platform and OS Compatibility. If you are using DeepStream 6.3, we recommend that you install the following drivers R525.125.06 on your host. Then you can directly use our docker nvcr.io/nvidia/deepstream:6.3-triton-multiarch to run your sample.

Is the recipe for nvcr.io/nvidia/deepstream:6.3-triton-multiarch available somewhere? running that image I don’t see the errors so I’m curious what the difference is between that image and the one I’m using. (currently I start with nvidia/cuda:12.1.1-cudnn8-devel-ubuntu20.04 and then install nv-tensorrt-local-repo-ubuntu2004-8.6.1-cuda-12.0_1.0-1_amd64.deb and deepstream_sdk_v6.3.0_x86_64.tbz2. As far as I can tell I’m following the instructions here: Quickstart Guide — DeepStream 6.3 Release documentation (or doing the equivalent thing). Main reason I’m doing that is the triton-multiarch image is kind of big and a pain to move around. Was trying to slim things down to only have what we need.

You can get the detailed information below. https://catalog.ngc.nvidia.com/orgs/nvidia/containers/deepstream/tags.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

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