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

When I run detect.py, I got a prediction of nan. #1749

Closed
Ramsden1 opened this issue Dec 21, 2020 · 3 comments
Closed

When I run detect.py, I got a prediction of nan. #1749

Ramsden1 opened this issue Dec 21, 2020 · 3 comments
Labels
question Further information is requested

Comments

@Ramsden1
Copy link

❔Question

I run the detect.py by

python detect.py --classes 2 --weights best.py --device 0

The code has no error, but the output image of this code has no bounding box annotated.
Then I tried to print this pred,

pred = model(img, augment=opt.augment)[0]

I find that the output tensor has a lot of nan values and some float numbers. But when I change device to CPU, this problem appeared.
So now I can only run it by CPU, can anyone tell me where is the wrong?

Thank you.

@Ramsden1 Ramsden1 added the question Further information is requested label Dec 21, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2020

Hello @Ramsden1, 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 screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@wudashuo
Copy link
Contributor

wudashuo commented Dec 21, 2020

Yes, I also found this problem. You can find more details in #1625.
Are you using Windows + Pytorch1.7? If yes:
A bad solution is set cudnn.benchmark = True, this will bring another problem, the results are pretty disastrous, according @glenn-jocher said.
My solution is install pytorch1.6.0+CU101 by pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html, and there's no need to downgrade your CUDA if you are using CUDA10.2 or CUDA11.x, it works fine with my env(CUDA11.1, Python3.8, Pytorch1.6.0+CU101)

@Ramsden1
Copy link
Author

Yes, I also found this problem. You can find more details in #1625.
Are you using Windows + Pytorch1.7? If yes:
A bad solution is set cudnn.benchmark = True, this will bring another problem, the results are pretty disastrous, according @glenn-jocher said.
My solution is install pytorch1.6.0+CU101 by pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html, and there's no need to downgrade your CUDA if you are using CUDA10.2 or CUDA11.x, it works fine with my env(CUDA11.1, Python3.8, Pytorch1.6.0+CU101)

Yes, My env is Windows + pytorch1.7 + cuda11.
I change the version of pytorch as you said, and it works for me.
Thank you!

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

No branches or pull requests

2 participants