I am trying to build an environment to run yolov5 on jetson agx xavier using docker. However, I get an error message, but when I look into it, all I can find is something that has nothing to do with jetson.
Here are the commands I typed in.
Commands typed in jetson
sudo docker pull nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3
sudo docker run -it --rm --runtime nvidia --network host nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3
Commands typed in docker
cd
git clone https://github.com/ultralytics/yolov5.git
cd yolov5/
pip3 install -r requirements.txt
python3 detect.py
Error Message
Traceback (most recent call last):
File "detect.py", line 45, in <module>
from models.common import DetectMultiBackend
File "/root/yolov5/models/common.py", line 18, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.8/dist-packages/cv2/gapi/__init__.py", line 301, in <module>
cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)
Also, since the error is about opencv and the pytorch environment is preconfigured, I commented out the some line in requirements.txt. However, I got an error message.
opencv-python>=4.1.1
torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended)
torchvision>=0.8.1
After creating a new docker environment, I ran detect.py
Error Message
File "detect.py", line 45, in <module>
from models.common import DetectMultiBackend
File "/root/yolov5/models/common.py", line 18, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.8/dist-packages/cv2/gapi/__init__.py", line 301, in <module>
cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)
I have investigated the above error message and have only found a fix that seems to be python related, not jetson related. Please advise.
Environment
The following are the results of typing the three commands.
uname -r
5.10.104-tegra
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_May__4_00:02:26_PDT_2022
Cuda compilation tools, release 11.4, V11.4.239
Build cuda_11.4.r11.4/compiler.31294910_0
cat /etc/nv_tegra_release
R35 (release), REVISION: 1.0, GCID: 31346300, BOARD: t186ref, EABI: aarch64, DATE: Thu Aug 25 18:41:45 UTC 2022