Docker container from l4t-base cannot connect to a host usb camera

I build my own docker image from l4t-base in my ubuntu 18.04 host device

FROM nvcr.io/nvidia/l4t-base:r32.6.1

And run my container like:

export DISPLAY=:0
xhost +
docker run --net vistrack --ip 172.18.0.3 -it --name vistrack --runtime nvidia --device /dev/video0:/dev/video0 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix -v /home/root/:/vistrack xaviernx:v0.3

where xaviernx:v0.3 is my image build above. But, when I connect to this camera in my codes by opencv VideoCapture, that failed.

And I searched many method, none of them helps. One of them, I use v4l2-ctl -d /dev/video0 --list-formats-ext to check something usefule (I think …):), but I get following:

root@94932d4548dc:/vistrack# v4l2-ctl -d /dev/video0 --list-formats-ext
VIDIOC_QUERYCAP: failed: Function not implemented
/dev/video0: not a v4l2 node

I’m lost now, please help me.

Hi @lihuawei11, are you able to successfully use the /dev/video0 device outside of container?

If it’s a MIPI CSI camera, can you try adding -v /tmp/argus_socket:/tmp/argus_socket ?

Also, you may want to temporarily try --net host to see if that’s related.

Thanks for your quick reply.

are you able to successfully use the /dev/video0 device outside of container?

When on my host device (a ubuntu 18.04 amd64 laptop), I can see some useful information from command line:

$ v4l2-ctl --list-devices
Integrated_Webcam_HD: Integrate (usb-0000:00:14.0-5):
	/dev/video0
	/dev/video1

So, I can think it as working, right?

If it’s a MIPI CSI camera, can you try adding -v /tmp/argus_socket:/tmp/argus_socket
Also, you may want to temporarily try --net host to see if that’s related.

I don’t know if my camera is a CSI camera, how to verify it?
I have tried both above options simultaneously, but with no luck.

Beside, I should made it clear that I run my container with help of qemu, on a host laptop with ubuntu 18.04 amd-64bit installed while my docker container is a arm64 which is built from l4t-base as mentioned in my original question.

If it’s a USB camera, then it’s not MIPI CSI. So you can ignore the -v /tmp/argus_socket:/tmp/argus_socket thing I said before.

Are you able to run this command from your Jetson outside of container, and get the correct output?

Do you mean that the container is not actually running on Jetson hardware? I would not expect this to work running under emulation as l4t-base gets it’s drivers/CUDA/ect mounted into the container at runtime (when --runtime nvidia is used)

Do you mean that the container is not actually running on Jetson hardware? I would not expect this to work running under emulation as l4t-base gets it’s drivers/CUDA/ect mounted into the container at runtime (when --runtime nvidia is used)

Yes, that what I mean. So as I can understand, the root reason is qemu emulator which breaks bindings between host cuda releated path into container, right? Seems that the only way to fix it is to run all this on a Jetson hardware?

Yes, and although it’s unclear how that impacts V4L2 functionality under qemu emulation, those containers should be run on actual Jetson hardware instead.

Ok, I will try it on a true Jetson hardware. Thank you, @dusty_nv

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