I was wondering how I could use my app in container, so I made the image with this Dockerfile :
# Use an image compatible with Jetson Orin Nano and L4T 36.3.0
FROM nvcr.io/nvidia/l4t-jetpack:r36.3.0
# Set the working directory
WORKDIR /app
# Update and upgrade the system packages
RUN apt-get -y update && apt-get -y upgrade && apt-get install -y libopenmpi-dev libopenblas-dev
# Install necessary packages
# RUN apt-get install -y libcanberra-gtk-module libgbm1 libatk-bridge2.0-0 libgconf-2-4
# RUN apt-get install -y libgtk-3-dev libgtk-3-0 libgirepository1.0-dev
RUN apt-get install -y gobject-introspection libcairo2-dev
# Install pip3
RUN apt-get install -y python3-pip
# Copy your application code into the container
COPY ./workspace/concrete_project /app
# Install meson
RUN pip3 install meson==1.4.0 ninja
# Install Python dependencies
COPY ./workspace/concrete_project/requirements.txt /app
RUN pip3 install -r /app/requirements.txt
RUN pip3 uninstall -y opencv-python
# Define the command to run your app
CMD ["python3", "main.py"]
then I made container by this command :
docker run --privileged -v /dev/video0:/dev/video0 --device=/dev/video0:/dev/video0 -v /lib/modules:/lib/modules --runtime nvidia -it --volume /tmp/argus_socket:/tmp/argus_socket -v /mnt/usb_storage:/mnt/usb_storage -v /tmp/.X11-unix/:/tmp/.X11-unix/ -e DISPLAY=$DISPLAY --name app concrete_observer:1.0.0-production
then I got this error:
(main.py:1): dbind-WARNING **: 12:06:59.031: Couldn't connect to accessibility bus: Failed to connect to socket /run/user/1000/at-spi/bus_0: No such file or directory
0:00:00.185666955 38 0xaaaac9467960 WARN vadisplay gstvadisplay.c:287:_va_warning:<vadisplaydrm0> VA error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
0:00:00.185780527 38 0xaaaac9467960 WARN vadisplay gstvadisplay.c:347:gst_va_display_initialize:<vadisplaydrm0> vaInitialize: unknown libva error
0:00:00.445325700 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x120000: 'AVR (Audio Visual Research)' is not mapped
0:00:00.445400038 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x180000: 'CAF (Apple Core Audio File)' is not mapped
0:00:00.445427431 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x100000: 'HTK (HMM Tool Kit)' is not mapped
0:00:00.445449768 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0xc0000: 'MAT4 (GNU Octave 2.0 / Matlab 4.2)' is not mapped
0:00:00.445466120 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0xd0000: 'MAT5 (GNU Octave 2.1 / Matlab 5.0)' is not mapped
0:00:00.445481385 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x210000: 'MPC (Akai MPC 2k)' is not mapped
0:00:00.445502410 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0xe0000: 'PVF (Portable Voice Format)' is not mapped
0:00:00.445528778 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x160000: 'SD2 (Sound Designer II)' is not mapped
0:00:00.445553419 38 0xaaaac9467960 WARN default gstsfelement.c:97:gst_sf_create_audio_template_caps: format 0x190000: 'WVE (Psion Series 3)' is not mapped
0:00:01.099296563 38 0xaaaac9467960 WARN ladspa gstladspa.c:508:plugin_init:<plugin144> no LADSPA plugins found, check LADSPA_PATH
0:00:01.176796918 38 0xaaaac9467960 WARN nvenc gstnvenc.c:878:gst_nvenc_load_library: Could not open library libnvidia-encode.so.1, libnvidia-encode.so.1: cannot open shared object file: No such file or directory
0:00:01.176895962 38 0xaaaac9467960 WARN nvcodec plugin.c:80:plugin_init: Failed to load nvenc library
0:00:01.177586737 38 0xaaaac9467960 WARN default gstcuvidloader.c:89:gst_cuvid_load_library: Could not open library libnvcuvid.so.1, libnvcuvid.so.1: cannot open shared object file: No such file or directory
0:00:01.177625170 38 0xaaaac9467960 WARN nvcodec plugin.c:85:plugin_init: Failed to load nvdec library
(gst-plugin-scanner:38): GStreamer-WARNING **: 12:07:15.731: adding type GstEvent multiple times
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 29.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
0:00:05.323064547 1 0xaaaaee3636a0 WARN basesink gstbasesink.c:1249:gst_base_sink_query_latency:<appsink0> warning: Pipeline construction is invalid, please add queues.
0:00:05.323199175 1 0xaaaaee3636a0 WARN basesink gstbasesink.c:1249:gst_base_sink_query_latency:<appsink0> warning: Not enough buffering available for the processing deadline of 0:00:00.020000000, add enough queues to buffer 0:00:00.020000000 additional data. Shortening processing latency to 0:00:00.000000000.
[ WARN:0@14.986] global cap_gstreamer.cpp:1728 open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
(main.py:1): Gtk-CRITICAL **: 12:07:17.414: gtk_widget_new: assertion 'g_type_is_a (type, GTK_TYPE_WIDGET)' failed
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success
Traceback (most recent call last):
File "/app/main.py", line 569, in <module>
detector("ZERO","C")
File "/app/main.py", line 107, in detector
cv2.namedWindow(window_title, cv2.WINDOW_NORMAL)
cv2.error: OpenCV(4.8.0) /home/ubuntu/opencv_build/opencv/modules/highgui/src/window_gtk.cpp:169: error: (-215:Assertion failed) image_widget && "GTK widget creation is failed. Ensure that there is no GTK2/GTK3 libraries conflict" in function 'cvImageWidgetNew'
this is my first part of main.py :
#!/usr/bin/python3
import warnings
warnings.filterwarnings('ignore')
import sys, os
os.environ["LD_PRELOAD"] = "/usr/lib/aarch64-linux-gnu/libgomp.so.1"
os.system("sudo systemctl restart nvargus-daemon")
os.environ["DISPLAY"] = ":0"
os.environ["OPENCV_LOG_LEVEL"] = "ON"
os.environ["GST_DEBUG"] = "2"
os.environ["XDG_RUNTIME_DIR"] = "/run/user/1000"
# os.environ['OPENCV_VIDEOIO_PRIORITY_MSMF'] = '0' # Disable MSMF backend
# os.environ['OPENCV_VIDEOCAPTURE_API'] = 'CAP_V4L2' # Use V4L2 backend
import gi
# gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
import logging
logging.basicConfig(filename='app.log', level=logging.INFO, format='%(levelname)s:%(message)s')
import cv2
import pandas as pd
import numbers
import numpy as np
import cv2
import requests
import json
import base64
from PIL import Image
import datetime
import os
from ultralytics import YOLO
from utils.tools import *
model_mixer = YOLO("models/mixer/best.pt")
model_plate = YOLO("models/plate/best.pt")
model_classification = YOLO("models/classification/best.pt")
would you please help me to figure out, Thank you.