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

yolov5 Tensortt errors ? #13057

Open
1 task done
Janeqs-cx opened this issue May 31, 2024 · 11 comments
Open
1 task done

yolov5 Tensortt errors ? #13057

Janeqs-cx opened this issue May 31, 2024 · 11 comments
Labels
question Further information is requested Stale Stale and schedule for closing soon

Comments

@Janeqs-cx
Copy link

Search before asking

Question

I was trying to run tensort with my trained best.engine version. I checked best.engine file and it's working fine with tensort but when tried to run with script by yolov5 it's give these errors :

PS C:\Users\Janek\Desktop\Val-sz> & c:/Users/Janek/Desktop/Val-sz/cheats-env/Scripts/python.exe c:/Users/Janek/Desktop/Val-sz/scripts/dxcam_main.py
YOLOv5 2022-11-22 Python-3.10.5 torch-1.12.1+cu116 CUDA:0 (NVIDIA GeForce GTX 1060 6GB, 6144MiB)

Loading C:\Users\Janek\Desktop\Val-sz\scripts\best.engine for TensorRT inference...
[05/31/2024-21:01:11] [TRT] [I] [MemUsageChange] Init CUDA: CPU +297, GPU +0, now: CPU 11292, GPU 1015 (MiB)
[05/31/2024-21:01:11] [TRT] [I] Loaded engine size: 10 MiB
[05/31/2024-21:01:11] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB)
[05/31/2024-21:01:11] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB)
C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\tensorrt_init_.py:331: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar.
bool: np.bool,
Traceback (most recent call last):
File "C:\Users\Janek\Desktop\Val-sz\yolov5\hubconf.py", line 49, in create
model = DetectMultiBackend(path, device=device, fuse=autoshape) # detection model
File "C:\Users\Janek\Desktop\Val-sz\yolov5\models\common.py", line 406, in init
dtype = trt.nptype(model.get_binding_dtype(i))
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\tensorrt_init
.py", line 331, in nptype
bool: np.bool,
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\numpy_init_.py", line 338, in getattr
raise AttributeError(former_attrs[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically
wanted the numpy scalar type, use np.bool_ here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Janek\Desktop\Val-sz\yolov5\hubconf.py", line 60, in _create
model = attempt_load(path, device=device, fuse=False) # arbitrary model
File "C:\Users\Janek\Desktop\Val-sz\yolov5\models\experimental.py", line 79, in attempt_load
ckpt = torch.load(attempt_download(w), map_location='cpu') # load
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\serialization.py", line 713, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\serialization.py", line 920, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: unpickling stack underflow

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\Users\Janek\Desktop\Val-sz\scripts\dxcam_main.py", line 104, in
model = torch.hub.load(r'C:\Users\Janek\Desktop\Val-sz\yolov5' , 'custom', path= r'C:\Users\Janek\Desktop\Val-sz\scripts\best.engine',source='local').cpu()
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\hub.py", line 540, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\hub.py", line 569, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\Janek\Desktop\Val-sz\yolov5\hubconf.py", line 83, in custom
return _create(path, autoshape=autoshape, verbose=_verbose, device=device)
File "C:\Users\Janek\Desktop\Val-sz\yolov5\hubconf.py", line 78, in _create
raise Exception(s) from e
Exception: unpickling stack underflow. Cache may be out of date, try force_reload=True or see #36 for help.

Can someone explain and help me fix it?

Additional

No response

@Janeqs-cx Janeqs-cx added the question Further information is requested label May 31, 2024
Copy link
Contributor

github-actions bot commented May 31, 2024

👋 Hello @Janeqs-cx, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

@Janeqs-cx
Copy link
Author

already did this 💀

@glenn-jocher
Copy link
Member

It seems like you've already tried some troubleshooting steps. Could you please specify which steps you've taken so far? This will help us provide more targeted assistance. Thank you!

@Janeqs-cx
Copy link
Author

I reinstalled whole Tensort Pytorch And cuda cudnn i tried also making a new model but it also failed and now i really dont know why it's not working i also tried yolov5 older versions like v6.2

@glenn-jocher
Copy link
Member

Thank you for detailing the steps you've taken. It sounds like you've already tried a comprehensive set of troubleshooting actions. Let's try a couple more things:

  1. Check NumPy Version: The error related to np.bool suggests there might be a compatibility issue with the NumPy version. Ensure you are using a version compatible with your TensorRT and PyTorch setup.

  2. Revisit TensorRT Engine: Since you mentioned creating a new model didn't help, double-check the TensorRT engine creation process. Ensure that the .engine file is correctly generated and compatible with the version of TensorRT you are using.

  3. Environment Verification: Sometimes, environment path issues could cause unexpected behavior. Verify that your Python environment is correctly set up and that there are no conflicting packages.

If these steps don't resolve the issue, could you provide the exact command or script you are using to run the inference? This might help pinpoint where things are going wrong.

@Janeqs-cx
Copy link
Author

Reinstalled numpy + Checked TensortRT Engine to check i corrupted and also reinstalled whole python venv

@Janeqs-cx
Copy link
Author

Hi @glenn-jocher i just changed some version of dependecies and now throwwing these errors :

YOLOv5 v7.0-318-gc0380fd8 Python-3.9.13 torch-1.12.1+cu116 CUDA:0 (NVIDIA GeForce GTX 1060 6GB, 6144MiB)

Loading C:\Users\Janek\Desktop\Val-sz\best.engine for TensorRT inference...
[06/04/2024-14:46:21] [TRT] [I] [MemUsageChange] Init CUDA: CPU +286, GPU +0, now: CPU 11276, GPU 1008 (MiB)
[06/04/2024-14:46:21] [TRT] [I] Loaded engine size: 34 MiB
[06/04/2024-14:46:21] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB)
[06/04/2024-14:46:21] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB)
Adding AutoShape...
(544, 307, 816, 460)
Traceback (most recent call last):
File "c:\Users\Janek\Desktop\Val-sz\scripts\main.py", line 150, in
df= model(screenshot, size=640).pandas().xyxy[0]
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "C:\Users\Janek\Desktop\Val-sz\yolov5\models\common.py", line 872, in forward
y = self.model(x, augment=augment) # forward
File "C:\Users\Janek\Desktop\Val-sz\cheats-env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\Janek\Desktop\Val-sz\yolov5\models\common.py", line 688, 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, 384, 640]) not equal to max model size (1, 3, 736, 736)

@glenn-jocher
Copy link
Member

Hi @Janeqs-cx,

It looks like the input image size does not match the expected size by the model. The model is expecting an input size of (1, 3, 736, 736), but it received an input size of (1, 3, 384, 640).

Please ensure that the input images are resized or padded to match the model's expected input dimensions of 736x736 before passing them to the model. This adjustment should resolve the assertion error you're encountering.

Let us know if you need further assistance!

Copy link
Contributor

github-actions bot commented Jul 5, 2024

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Jul 5, 2024
@Avaneesh-S
Copy link

Hey @Janeqs-cx, regarding your original error. I have also faced the similar issue. installing numpy==1.23 before exporting to tensorrt format resolved the issue for me (I have tested it on colab)

@github-actions github-actions bot removed the Stale Stale and schedule for closing soon label Jul 10, 2024
Copy link
Contributor

github-actions bot commented Aug 9, 2024

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale Stale and schedule for closing soon label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale and schedule for closing soon
Projects
None yet
Development

No branches or pull requests

3 participants