-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
what can I do for RuntimeError: Trying to create tensor with negative dimension -1592267047: [-1592267047] #1688
Comments
@Jackyinuo that's very strange. You may have an environment problem, I would try to reproduce your error in a verified working environment like Google Colab or our Docker image, and if the error appears there then please raise a full bug report here. I'll post you our default reply below. Hello, thank you for your interest in our work! This issue seems to lack the minimum requirements for a proper response, or is insufficiently detailed for us to help you. Please note that most technical problems are due to:
$ git clone https://github.com/ultralytics/yolov5 yolov5_new # clone latest
$ cd yolov5_new
$ python detect.py # verify detection
# CODE TO REPRODUCE YOUR ISSUE HERE
If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you! RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are passing. These tests evaluate proper operation of basic YOLOv5 functionality, including training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu. |
I think this is a bug of nms, refer to pytorch/vision#1705 here. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
btw, I have similar problem with custom dataset with YOLOv8 |
@tihhanovski it seems like you're encountering an issue that might be related to the interaction between PyTorch's NMS implementation and the MPS backend on Apple's M1 GPU. The error you're experiencing with YOLOv5 and a similar issue with YOLOv8 suggest that this could be a broader compatibility problem with MPS. Given the reference to a PyTorch/Vision issue, it's possible that the problem lies within the underlying library rather than YOLOv5 or YOLOv8 directly. However, ensuring that you're using the latest versions of PyTorch and torchvision that support the MPS backend could potentially resolve this issue. Apple's M1 GPUs have specific requirements, and compatibility is continually improving. For now, as a workaround, training without the GPU on the M1 (as you've done successfully) is a valid approach, albeit slower. You might also consider running your training on a different machine with a more widely supported GPU architecture (e.g., NVIDIA's CUDA) if that's an option for you. We appreciate your patience and understanding as these compatibility issues are worked out. The rapid development of machine learning frameworks and hardware often leads to these kinds of challenges, but they are usually resolved with time as updates are released. Keep an eye on updates from PyTorch and torchvision that might address this issue more directly. If you haven't already, please ensure your environment is up to date with the latest versions of all relevant libraries. If the problem persists, consider raising an issue on the PyTorch GitHub to bring more attention to MPS backend compatibility problems. Your detailed feedback can help the developers prioritize and address these issues more effectively. Thank you for your contribution to the community by highlighting this issue. Your efforts help improve the tool for everyone. 🙏 |
I had a similar issue while training on a single image. After I added more than one image, training on my M1 GPU worked. |
Thank you for sharing your experience! It's interesting to hear that adding more images resolved the issue on your M1 GPU. This suggests that the problem might be related to how the MPS backend handles certain operations with very small datasets. For anyone encountering similar issues, here are a few additional tips that might help:
Here's a small code snippet to ensure you're using the latest versions of PyTorch and torchvision: pip install --upgrade torch torchvision We appreciate your patience and contributions to improving the YOLOv5 experience for everyone. If you encounter further issues or have more insights to share, please feel free to continue the discussion here. Your feedback is invaluable to the community! 😊 Thank you again, and happy training! 🚀 |
❔Question
Starting training for 300 epochs...
Analyzing anchors... anchors/target = 4.45, Best Possible Recall (BPR) = 0.9949
all 5e+03 3.63e+04 0.0145 0.00296 0.00248 0.000805
Traceback (most recent call last):
File "train.py", line 503, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 336, in train
results, maps, times = test.test(opt.data,
File "/disk1/huihui/yolov5/test.py", line 120, in test
output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres, labels=lb)
File "/disk1/huihui/yolov5/utils/general.py", line 332, in non_max_suppression
i = torchvision.ops.nms(boxes, scores, iou_thres) # NMS
File "/home/phzhou/anaconda3/envs/pt1/lib/python3.8/site-packages/torchvision/ops/boxes.py", line 42, in nms
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
RuntimeError: Trying to create tensor with negative dimension -1592267047: [-1592267047]
Additional context
The text was updated successfully, but these errors were encountered: