USB Camera turns on and then crashes kernel and turns off, ml-l4t container issue

Hi, I’m having a strange issue using the Logitech C270 Webcam in the L4T-ML container.
When I type:

!ls -ltrh /dev/video*

I am getting the output

crw-rw---- 1 root video 81, 0 Apr 12 06:44 /dev/video0

I tried running this camera using OpenCV but it just turns on for a second then shuts off and resets the whole kernel.
The code I used:

import numpy as np
import cv2
cap = cv2.VideoCapture("/dev/video0")
while True:
ret, frame =
if cv2.waitKey(1) & 0xFF == ord(‘q’):

What could be the issue?

Please follow the steps to launch USB camera:
Jetson Nano FAQ
Q: I have a USB camera. How can I launch it on Jetson Nano?

If you can launch it in gstreamer command, please try this sample:
V4l2src using OpenCV Gstreamer is not working in Jetson Xavier NX - #3 by DaneLLL
Yo would need to apply format,width,height,framerate per your source.