问题 YOLO 在 Jetson Nano 上给出非法指令(核心转储)

问题 YOLO 在 Jetson Nano 上给出非法指令(核心转储)

我有一台 jetson nano,并且安装了运行 JetPack 4.6 的 Ubuntu 18.04。我正在尝试从其上的相机运行对象检测程序。

我有一个有点时髦的安装过程:

  • 我安装了python3(不是在虚拟环境中)
  • 然后安装了一些库,然后才意识到我需要 python 3.8 或更高版本才能使用 ultralytics 和 torch
  • 我安装了 python3.8 并创建了一个名为 python31 的别名,它将运行 python3.8
  • 我使用 opencv 来获取我的网络摄像头输入并且它有效
  • 我尝试安装 torch,但它不起作用,所以我转而在 python 3.8 中创建虚拟环境
  • 我在虚拟环境中安装了 torch 和 ultralytics,但由于某种原因,torch 也安装在环境之外,所以我决定也在环境之外安装 ultralytics。
  • 我使用 测试了虚拟机和外部是否都存在 ultralytics 和 torch。版本它有效,版本也匹配。 (火炬版本2.1.2,torchvision 0.16.2,ultralytics版本8.0.235,opencv-python 0.16.2)
  • 我尝试运行此代码并且导入顺利进行,但是,当我在 code-oss 上运行此代码时,出现非法指令(核心转储)错误
import cv2
import sys
from ultralytics import YOLO
print(cv2.__version__)
model = YOLO("yolo-Weights/yolov8n.pt")
classNames = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat",
              "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat",
              "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella",
              "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat",
              "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup",
              "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange", "broccoli",
              "carrot", "hot dog", "pizza", "donut", "cake", "chair", "sofa", "pottedplant", "bed",
              "diningtable", "toilet", "tvmonitor", "laptop", "mouse", "remote", "keyboard", "cell phone",
              "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors",
              "teddy bear", "hair drier", "toothbrush"
              ]
window_title = "USB camera"
camera_id = "/dev/video0"
video_capture = cv2.VideoCapture(camera_id, cv2.CAP_V4L2)
video_capture.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
video_capture.set(cv2.CAP_PROP_FPS, 30)
while True:
    ret, frame = video_capture.read()
    results = model(frame, stream=True)
    for r in results:
        boxes = r.boxes
        for box in boxes:
            x1, y1, x2, y2 = box.xyxy[0]
            x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
            cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 255), 3)
            con = math.ceil((box.conf[0]*100))/100
            print(con)
            classs = int(box.cls[0])
            org = [x1, y1]
            font = cv2.FONT_HERSEY_SIMPLEX
            fontScale = 1
            color = (255, 0, 0)
            thickness = 2
            cv2.putText(img, classNames[classs], org, font, fontScale, color, thickness)

    cv2.imshow('JetCam', frame)
    if cv2.waitKey(1) == ord('q'):
        break
video_capture.release()
cv2.destroyAllWindows()

终端输出:4.9.0

非法指令(核心转储)

我想知道如何诊断此错误以及修复它的方法。谢谢!

相关内容