English 中文(简体)
Problem to run script in .engine format but works fine in .py format
原标题:

So I do not know how to code very well and im stuck at a problem with loading model onto GPU using TensorRT. this is a object detection model and im just trying to make it run faster. The script works fine when using Cuda in Pytorch format but when i use engine format after exporting pytorch to engine for tensorRT these errors occur.

Thanks to anyone that has some tips in advance

[04/05/2023-19:41:54] [TRT] [I] [MemUsageChange] Init CUDA: CPU +499, GPU +0, now: CPU 11536, GPU 1240 (MiB) [04/05/2023-19:41:54] [TRT] [I] Loaded engine size: 5 MiB [04/05/2023-19:41:55] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +1186, GPU +408, now: CPU 12783, GPU 1654 (MiB) [04/05/2023-19:41:55] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) [04/05/2023-19:41:55] [TRT] [I] [MemUsageChange] Init cuDNN: CPU +0, GPU +8, now: CPU 12776, GPU 1654 (MiB) [04/05/2023-19:41:55] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) Adding AutoShape... (1376, 576, 2064, 864) Traceback (most recent call last): File "c:UsersHALLÅÅDocumentsCHEATSscriptsmain copy.py", line 150, in df= model(screenshot, size=640).pandas().xyxy[0] File "C:UsersHALLÅÅDocumentsCHEATScheats-envlibsite-packages orch nmodulesmodule.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "C:UsersHALLÅÅDocumentsCHEATScheats-envlibsite-packages orchutils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "C:UsersHALLÅÅDocumentsCHEATSyolov5modelscommon.py", line 704, in forward y = self.model(x, augment=augment) # forward File "C:UsersHALLÅÅDocumentsCHEATScheats-envlibsite-packages orch nmodulesmodule.py", line 1501, in _call_impl return forward_call(*args, **kwargs) File "C:UsersHALLÅÅDocumentsCHEATSyolov5modelscommon.py", line 536, in forward assert im.shape == s, f"input size {im.shape} { > if self.dynamic else not equal to } max model size {s}" AssertionError: input size torch.Size([1, 3, 288, 640]) not equal to max model size (1, 3, 640, 640)

问题回答

AssertionError: input size torch.Size([1, 3, 288, 640]) not equal to max model size (1, 3, 640, 640) input size is 288,640 engine格式的权重,要求输入的图片size是640,640

解决办法:(2选一即可)

1.你可以修改你的图片的input size,改成640,640

2.重新将pt转为engine,加一个条件限制 imgsz=288,640





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签