You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a project using a Jetson Nano where I am trying to perform inference using TensorRT (Yolov5 object detection) in a ROS (Melodic) node. I have encountered a Bus Error(Core dumped) / segmentation fault (core dumped), which seems to arise from a memory conflict between ROS and TensorRT. I am seeking advice or solutions from anyone who might have faced and resolved a similar issue.
I have provided the code to my inference node below. I would greatly appreciate any insights, suggestions, or solutions.
`
#!/usr/bin/env python3
import rospy
from sensor_msgs.msg import Image
from std_msgs.msg import String
import json
import cv2
import imutils
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
import tensorrt as trt
import pycuda.autoinit
import random
import ctypes
import pycuda.driver as cuda
import time
import multiprocessing as mp
import threading
def process_image(yolo):
bridge = CvBridge()
while not rospy.is_shutdown():
try:
data = rospy.wait_for_message("/camera/image_raw", Image, timeout=None)
cv_image = bridge.imgmsg_to_cv2(data, "bgr8")
cv_image = imutils.resize(cv_image, width=1504)
detections, _ = yolo.Inference(cv_image)
relevant_detections = [det for det in detections if det['class'] in ['pedestrian', 'people']]
if relevant_detections:
detection_pub.publish(json.dumps(relevant_detections))
except CvBridgeError as e:
print(e)
if name == 'main':
mp.set_start_method('spawn')
print("Init ROS Node")
#rospy.init_node('yolo_image_processor', anonymous=True)
print("ROS Node init done")
Hello everyone,
I am currently working on a project using a Jetson Nano where I am trying to perform inference using TensorRT (Yolov5 object detection) in a ROS (Melodic) node. I have encountered a Bus Error(Core dumped) / segmentation fault (core dumped), which seems to arise from a memory conflict between ROS and TensorRT. I am seeking advice or solutions from anyone who might have faced and resolved a similar issue.
I have provided the code to my inference node below. I would greatly appreciate any insights, suggestions, or solutions.
Environment Details:
Jetpack Version: 4.6.
ROS Version: ROS Melodic
TensorRT Version: 8.2.1.8
PyCUDA: 2019.1.2
Torch version: 1.10.0
CUDA: 10.2
`
#!/usr/bin/env python3
import rospy
from sensor_msgs.msg import Image
from std_msgs.msg import String
import json
import cv2
import imutils
from cv_bridge import CvBridge, CvBridgeError
import numpy as np
import tensorrt as trt
import pycuda.autoinit
import random
import ctypes
import pycuda.driver as cuda
import time
import multiprocessing as mp
import threading
EXPLICIT_BATCH = 1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
host_inputs = []
cuda_inputs = []
host_outputs = []
cuda_outputs = []
bindings = []
class YoloTRT():
def init(self, library, engine, conf, yolo_ver):
print("Initiating Engine")
self.CONF_THRESH = conf
self.IOU_THRESHOLD = 0.4
self.LEN_ALL_RESULT = 38001
self.LEN_ONE_RESULT = 38
self.yolo_version = yolo_ver
self.categories = ["pedestrian", "people", "bicycle", "car", "van", "truck", "tricycle", "awning-tricycle", "bus", "motor"]
def process_image(yolo):
bridge = CvBridge()
while not rospy.is_shutdown():
try:
data = rospy.wait_for_message("/camera/image_raw", Image, timeout=None)
cv_image = bridge.imgmsg_to_cv2(data, "bgr8")
cv_image = imutils.resize(cv_image, width=1504)
detections, _ = yolo.Inference(cv_image)
relevant_detections = [det for det in detections if det['class'] in ['pedestrian', 'people']]
if name == 'main':
mp.set_start_method('spawn')
print("Init ROS Node")
#rospy.init_node('yolo_image_processor', anonymous=True)
print("ROS Node init done")
`
The text was updated successfully, but these errors were encountered: