ultralytics icon indicating copy to clipboard operation
ultralytics copied to clipboard

GPU warmup error

Open buckeye17 opened this issue 3 years ago • 3 comments

Search before asking

  • [X] I have searched the YOLOv8 issues and found no similar bug report.

YOLOv8 Component

I'm attempting to make a detection inference.

Bug

Traceback (most recent call last):
  File "/app/test.py", line 18, in detect_people_with_yolov8
    yolov8_result_obj = model(img_path, imgsz=img.shape, classes=desired_class_ind_ls, device=device)[0]  # predict on an image
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/yolo/engine/model.py", line 65, in __call__
    return self.predict(source, stream, verbose, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/yolo/engine/model.py", line 146, in predict
    return self.predictor(source=source, stream=stream, verbose=verbose)
  File "/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/yolo/engine/predictor.py", line 158, in __call__
    return list(self.stream_inference(source, model, verbose))  # merge list of Result into one
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/yolo/engine/predictor.py", line 179, in stream_inference
    self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.bs, 3, *self.imgsz))
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/nn/autobackend.py", line 354, in warmup
    self.forward(im)  # warmup
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/nn/autobackend.py", line 248, in forward
    b, ch, h, w = im.shape  # batch, channel, height, width
ValueError: too many values to unpack (expected 4)
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

Environment

Minimal Reproducible Example

# import third party packages
import cv2 as cv
import torch
from ultralytics import YOLO

img_path = "/path/to/img.jpg"

device = "0" if torch.cuda.is_available() else "cpu"

desired_class_ls = ["person"]
yolo_classes_ls = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis','snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
desired_class_ind_ls = [yolo_classes_ls.index(item) for item in desired_class_ls]

img = cv.imread(img_path)

model = YOLO('yolov8x.pt')  # load a pretrained model (recommended for training)
yolov8_result_obj = model(img_path, imgsz=img.shape, classes=desired_class_ind_ls, device=device)[0]  # predict on an image

Additional

No response

Are you willing to submit a PR?

  • [ ] Yes I'd like to help by submitting a PR!

buckeye17 avatar Feb 02 '23 06:02 buckeye17

@buckeye17 imgsz can be either an integer or a list of length 1 or 2, but it can not have length 3, which is what img.shape will produce.

glenn-jocher avatar Feb 04 '23 11:02 glenn-jocher

Screenshot 2023-02-04 at 15 58 16

glenn-jocher avatar Feb 04 '23 11:02 glenn-jocher

Added improved error reporting for this user error in https://github.com/ultralytics/ultralytics/pull/800/commits/11dad0aaf3604569d2a375ea4c4eff9eae2f0893

glenn-jocher avatar Feb 04 '23 12:02 glenn-jocher

👋 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:

  • Docs: https://docs.ultralytics.com
  • HUB: https://hub.ultralytics.com
  • Community: https://community.ultralytics.com

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[bot] avatar Mar 08 '23 00:03 github-actions[bot]