Not Able to Access CSI Camera in Jetson Nano DLI Course Container

First, I would like to thank you Jetson Nano DLI course teem, and Nvidia for such a valuable course.

I am trying to run CSI camera inside the course container, but I am not able to run the CSI camera inside the container.
Jetson Nano used version B01 (the one comes with two CSI camera slots)
Camera used : CSI camera (Raspberry Pi camera V2.1)
The camera is connected to the first slot.

Docker run command:

sudo docker run --runtime nvidia -it --rm --network host     --volume ~/nvdli-data:/nvdli-nano/data     --device /dev/video0

checking camera command works fine

!ls -ltrh /dev/video*
crw-rw---- 1 root video 81, 0 Oct 19 19:00 /dev/video0

Initializing the camera does not work

from jetcam.csi_camera import CSICamera

camera = CSICamera(width=224, height=224)

It is giving me this error:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/ in __init__(self, *args, **kwargs)
     23             if not re:
---> 24                 raise RuntimeError('Could not read image from camera.')
     25         except:

RuntimeError: Could not read image from camera.

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
<ipython-input-2-dae08cdf7ca7> in <module>
      1 from jetcam.csi_camera import CSICamera
----> 3 camera = CSICamera(width=224, height=224)

/usr/local/lib/python3.6/dist-packages/jetcam-0.0.0-py3.6.egg/jetcam/ in __init__(self, *args, **kwargs)
     25         except:
     26             raise RuntimeError(
---> 27                 'Could not initialize camera.  Please see error trace.')
     29         atexit.register(self.cap.release)

RuntimeError: Could not initialize camera.  Please see error trace.

Even though the camera works fine on the jetson outside the container. I cloned the Jetcam repo and run the notebook outside the container. it worked fine.

Could you please help me with this issue!?
Also, I hope you open a special section for DLI course issues so it becomes easier to search for all issues in one place.

Hi @anasmk, please add the --volume /tmp/argus_socket:/tmp/argus_socket option to your docker run command when launching the container:

sudo docker run --runtime nvidia -it --rm --network host     --volume ~/nvdli-data:/nvdli-nano/data     --volume /tmp/argus_socket:/tmp/argus_socket    --device /dev/video0

Then CSI camera should work from inside the container - sorry about that, we have updated the DLI course documentation to reflect that. For more info, please see this post:

1 Like

Thanks a lot @dusty_nv it works fine now.


I had the same issue and adding /tmp/argus_socket to the docker volumes worked for me initially. I am now having an issue where, when I halt the notebook kernel and attempt to open anything else that reads from the camera, I get the same “RuntimeError: Could not initialize camera.” error.

Steps to reproduce:
docker image dli-nano-ai:v2.0.0-r32.4.3
Run a notebook cell that accesses the camera with jetcam.csi_camera CSICamera
Shut down the kernel
Open it again (or any other nb with similar camera access method)
Try to run
Receive error

I’m able to solve it with a complete reboot of the nano. Stopping and restarting the container does not fix the issue. It’s almost like the camera does not close properly when the notebook kernel stops.

Any help would be appreciated!


Hi @jeo5015, after you stop the container, can you run this command from your host device:

$  sudo systemctl restart nvargus-daemon

Then start the container and try the camera again. Also, I believe there should be a cell near the end of the notebook that properly shuts down the camera.


Thanks! That works to avoid rebooting the device but I still have to kill the container and restart nvargus-daemon after every time I access the camera. Could you point me to a snippet of code to shut down the camera? I looked in all of the DLI notebooks and they only mention to shutdown the kernels. Thanks again for your help!

@dusty_nv never mind, I figured it out myself.

camera.cap.release() will do it. It is supposed to be triggered at exit according to this [1] but for some reason it isn’t working automatically for me.


Ah sorry, you appear to be correct - you could try adding a cell to the end of the notebook and running this to see if it improves the behavior on your system:


If that alone doesn’t help, you also might want to add del camera after that line and see if that works.

1 Like

Ah ok, thank you - I figured that might help. I will talk with the DLI folks to see about adding that into the notebook.

1 Like

I had the same problem; I solved it this way:
Under the cell which contains:
camera.unobserve(update_image, names=‘value’)
I inserted a new cell which contains:
camera.running = False

and this solves the problem. The release command releases the camera; the running=False is necessary to prevent an error.