Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./yolov9-tensorrt.exe ./model.engine ./1096.jpg Error Code 1: Cuda Runtime (an illegal memory access was encountered) #13

Open
molyswu opened this issue Apr 30, 2024 · 22 comments

Comments

@molyswu
Copy link

molyswu commented Apr 30, 2024

Hi,
./yolov9-tensorrt.exe ./model.engine ./1096.jpg error as follower:
[04/30/2024-10:14:29] [E] [TRT] 1: [weightConverters.cu::nvinfer1::rt::cuda::padCaskConvWeight::166] Error Code 1: Cuda Runtime (an illegal memory access was encountered)
CUDA error 700 at F:\TensorRT-YOLOv9\src\yolov9.cpp:97Assertion failed: 0, file F:\TensorRT-YOLOv9\src\yolov9.cpp, line 97

1096.jpg :409*962

@spacewalk01
Copy link
Owner

Hi, width=409 and height=962 image right? I will test it. Thank you for informing

@spacewalk01
Copy link
Owner

spacewalk01 commented Apr 30, 2024

I have tested it with 427x640 image and it worked:
image

@spacewalk01
Copy link
Owner

Will you send me your onnx model?

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

The weights. zip file contains onnx and jpg images of the target copper surface

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

onnx

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

156M File size too big: 25 MB

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

Do you have a cloud drive that allows you to upload ONNX files?

@spacewalk01
Copy link
Owner

Is it a costumized model? what is the number of classes of your model?

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

Locate the incorrect statement:
CUDA_CHECK(cudaMemcpyAsync(cpu_output_buffer, gpu_buffers[1], num_detections * detection_attribute_size * sizeof(float), cudaMemcpyDeviceToHost, cuda_stream));
CUDA_CHECK(cudaStreamSynchronize(cuda_stream));

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

It is costumized mode

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

2 classes

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

3F2C1C636248

@spacewalk01
Copy link
Owner

spacewalk01 commented Apr 30, 2024

detection_attribute_size * num_detections == 84 x 8400 for default 80 classes. So in your case, when the number of classes is 2, it should be 6 x 8400. Will you print out result? You can also analyze onnx file using https://netron.app application. It shows something like this:

image

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

I can't find this line in your code:“detection_attribute_size * num_detections == 84 x 8400”,I don't know where to modify it

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

CONF_THRESH = 0.3
IOU_THRESHOLD = 0.2
NUM_DETECTIONS = 8400
LEN_ONE_RESULT = 84

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

python

@spacewalk01
Copy link
Owner

You trained your model with 2 classes but your onnx file has 80 classes. I think that is the problem. You need to set the number of classes of your model into 2 in reparameterize.py.

@spacewalk01
Copy link
Owner

@spacewalk01
Copy link
Owner

In line 8, fix it as follows: model = Model(cfg, ch=3, nc=2, anchors=3)

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

python yolov9_trt.py --engine yolov9-c.engine --data images --outdir output error:
Traceback (most recent call last):
File "C:\ProgramData\anaconda3\envs\yolov9\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "F:\TensorRT-YOLOv9\python\yolov9_trt.py", line 394, in run
batch_image_raw, use_time = self.yolov9_wrapper.infer(self.yolov9_wrapper.get_raw_image(self.image_path_batch))
File "\TensorRT-YOLOv9\python\yolov9_trt.py", line 170, in infer
result_boxes, result_scores, result_classid = self.post_process(
File "F:\TensorRT-YOLOv9\python\yolov9_trt.py", line 293, in post_process
pred = np.reshape(output, (-1, NUM_DETECTIONS)).T
File "C:\ProgramData\anaconda3\envs\yolov9\lib\site-packages\numpy\core\fromnumeric.py", line 285, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "C:\ProgramData\anaconda3\envs\yolov9\lib\site-packages\numpy\core\fromnumeric.py", line 59, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 105966 into shape (8400)

@molyswu
Copy link
Author

molyswu commented Apr 30, 2024

I modified the program and there is the same issue:In line 8, fix it as follows: model = Model(cfg, ch=3, nc=2, anchors=3)

@molyswu
Copy link
Author

molyswu commented May 4, 2024

File "C:\ProgramData\anaconda3\envs\yolov9\lib\site-packages\numpy\core\fromnumeric.py", line 285, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "C:\ProgramData\anaconda3\envs\yolov9\lib\site-packages\numpy\core\fromnumeric.py", line 59, in _wrapfunc
return bound(*args, **kwds)
ValueError: cannot reshape array of size 141288 into shape (8400)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants