kumuji / trt_yolo_ros

yolov3 ros node using tensorrt acceleration
12 stars 4 forks source link

Installation step #4

Open Jason-Lee0 opened 4 years ago

Jason-Lee0 commented 4 years ago

Sorry ,could you tell me how to compile your code? I want to use your code ,but I don't know how to run the code successfully.

Thanks

Best wishes.

kumuji commented 4 years ago

Sure, it should be pretty simple.

  1. You should install two dependencies: opencv and tensorrt. tensorrt installation is system-dependent, which machine do you use?
  2. Then you need to install ros and all of its dependencies.
  3. Copy the source code of this repo to ros workspace and build the node using catkib build command. What step are you in?
Jason-Lee0 commented 4 years ago

Sorry I found your cmakelist didn't mention about setting launch file. I have build,but it didn't have launch file at install folder.

Could you take a look? Thanks~~

kumuji commented 4 years ago

You will not have launch files in the installation folder. It will remain in sources. Can you try: roslaunch trt_yolo_ros demo.launch

Write me on telegram, I can try guiding you personally.

Shame-fight commented 4 years ago

Hi,I have catkib build this project correctly,but when I run roslaunch trt_yolo_ros demo.launch,the following problems occurred: [INFO] [1600738370.583793]: [trt_yolo_ros] starting the node Building new trt engine file Building ONNX graph for yolov3 Building ONNX graph Layer of type yolo not supported, skipping ONNX node generation. Layer of type yolo not supported, skipping ONNX node generation. Layer of type yolo not supported, skipping ONNX node generation. graph yolov3-416 ( %000_net[FLOAT, 64x3x416x416] ) initializers ( %001_convolutional_bn_scale[FLOAT, 32] %001_convolutional_bn_bias[FLOAT, 32] Loading ONNX file from path /home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/weights/yolov3-416.onnx... Beginning ONNX file parsing Completed parsing of ONNX file Building an engine this may take a while... [TensorRT] ERROR: Network must have at least one output [TensorRT] ERROR: Network validation failed. Completed creating engine, saving it. Traceback (most recent call last): File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo_ros/scripts/node.py", line 11, in <module> network = YOLORos() File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo_ros/src/trt_yolo_ros/trt_yolo_ros.py", line 27, in __init__ show_image=self.publish_image, File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/src/trt_yolo/detector.py", line 60, in __init__ self.engine = self.get_engine(weights_path, config_path, yolo_type) File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/src/trt_yolo/detector.py", line 109, in get_engine self.build_trt_from_onnx(weights_path, configs_path, yolo_type) File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/src/trt_yolo/detector.py", line 140, in build_trt_from_onnx f.write(engine.serialize()) AttributeError: 'NoneType' object has no attribute 'serialize' [trt_yolo_ros-2] process has died [pid 11026, exit code 1, cmd /home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo_ros/scripts/node.py __name:=trt_yolo_ros __log:=/home/knt/.ros/log/8415d566-fc73-11ea-828a-983f9f190824/trt_yolo_ros-2.log]. log file: /home/knt/.ros/log/8415d566-fc73-11ea-828a-983f9f190824/trt_yolo_ros-2*.log [trt_yolo_ros-2] restarting process process[trt_yolo_ros-2]: started with pid [11287] WARNING: TensorRT Python 2 support is deprecated, and will be dropped in a future version! [INFO] [1600738447.908609]: [trt_yolo_ros] starting the node Reading engine from file /home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/weights/yolov3-416.trt [TensorRT] ERROR: INVALID_ARGUMENT: Cannot deserialize with an empty memory buffer. [TensorRT] ERROR: INVALID_CONFIG: Deserialize the cuda engine failed. Traceback (most recent call last): File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo_ros/scripts/node.py", line 11, in <module> network = YOLORos() File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo_ros/src/trt_yolo_ros/trt_yolo_ros.py", line 27, in __init__ show_image=self.publish_image, File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/src/trt_yolo/detector.py", line 61, in __init__ self.inputs, self.outputs, self.bindings, self.stream = self._allocate_buffers() File "/home/knt/catkin_ws/src/trt_yolo_ros/trt_yolo/src/trt_yolo/detector.py", line 172, in _allocate_buffers for binding in self.engine: TypeError: 'NoneType' object is not iterable

I am using python2.7,onnx1.4.1,tensorrt7(from jetpack4.4),how can I solve this problem,thank you a lot. @kumuji

kumuji commented 4 years ago

In requirements.txt I specified onnx==1.5.0. Can you try it with that version?

Shame-fight commented 4 years ago

In requirements.txt I specified onnx==1.5.0. Can you try it with that version?

I have tried onnx=1.5.0, but I still get an error. What is the version of jetpack that your jetson nano uses? I will try to install the same environment as yours. @kumuji

kumuji commented 4 years ago

I think I was using jetpack 4.2 for long time, but recently reinstalled 4.4. Haven't installed ros there yet, most of the debugging was on normal pc. There I have this environment:

python==2.7.17
cuda==10.0

onnx==1.5.0
tensorrt==6.0.1.5
pycuda==2019.1.1

Let me install ros on my jetson nano, I will come back in few hours.

Shame-fight commented 4 years ago

I think I was using jetpack 4.2 for long time, but recently reinstalled 4.4. Haven't installed ros there yet, most of the debugging was on normal pc. There I have this environment:

python==2.7.17
cuda==10.0

onnx==1.5.0
tensorrt==6.0.1.5
pycuda==2019.1.1

Let me install ros on my jetson nano, I will come back in few hours.

Thank you for your efforts on this and look forward to receiving your reply.

kumuji commented 4 years ago

Sorry, takes longer then I expected.

Shame-fight commented 4 years ago

Sorry, takes longer then I expected.

It doesn't matter, as far as I know, tensorrt in jetpack4.4 supports python3 by default, I don't know if this is one of the reasons. Thank you for your work on this, and look forward to your completion.

lchop commented 3 years ago

Any updates on this issue ? I have exactly the same issue on my Xavier, so I guess the package is not usable right now, or is there a trick ? Thanks for your work !

kumuji commented 3 years ago

Sorry, so far no updates :( Too busy right now. I will be able to come back for this task in the end of next week. The thing is, this problem doesn't relate to the ros wrapper itself, but to the code of nvidia to generate onnx graph. If you have time, check if you can run nvidia exmaple with yolo on tensorrt.

kumuji commented 3 years ago

So, I was able to reproduce the error on jetson.

AttributeError: 'NoneType' object has no attribute 'serialize'

It seems like the problem happens during conversion from onnx to trt, and this error only appears on trt_version > 7. So, should work perfectly on jetpack == 4.2 if you need it now. I will check also file onnx_to_tensorrt from other repo, seems like the author might have a solution to the problem. But I am not quite sure about that... Will keep you updated.