Replies: 1 comment
-
@xjx12 hello, Thank you for bringing this issue to our attention. The error you're encountering, To help us diagnose and resolve this issue, could you please provide a minimum reproducible example of your code? This will allow us to better understand the context and replicate the issue on our end. You can find guidelines on how to create a reproducible example here: Minimum Reproducible Example. Additionally, please ensure that you are using the latest versions of all relevant packages, including PyTorch and Ultralytics YOLO. Sometimes, issues like these are resolved in newer releases. Here's a quick checklist to help you verify your setup:
If the issue persists after these steps, please share the reproducible example, and we'll be happy to assist you further. Thank you for your cooperation! 😊 |
Beta Was this translation helpful? Give feedback.
-
Apple m1 mps训练报错RuntimeError: Trying to create tensor with negative dimension -1: [2, -1, 5],而使用cpu则不会报错。
具体报错信息如下:
Traceback (most recent call last):
File "/opt/anaconda3/envs/yolo/bin/yolo", line 8, in
sys.exit(entrypoint())
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/cfg/init.py", line 591, in entrypoint
getattr(model, mode)(**overrides) # default args from model
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/engine/model.py", line 650, in train
self.trainer.train()
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/engine/trainer.py", line 204, in train
self._do_train(world_size)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/engine/trainer.py", line 381, in _do_train
self.loss, self.loss_items = self.model(batch)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/nn/tasks.py", line 101, in forward
return self.loss(x, *args, **kwargs)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/nn/tasks.py", line 283, in loss
return self.criterion(preds, batch)
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/utils/loss.py", line 215, in call
targets = self.preprocess(targets.to(self.device), batch_size, scale_tensor=imgsz[[1, 0, 1, 0]])
File "/opt/anaconda3/envs/yolo/lib/python3.9/site-packages/ultralytics/utils/loss.py", line 179, in preprocess
out = torch.zeros(batch_size, counts.max(), 5, device=self.device)
RuntimeError: Trying to create tensor with negative dimension -1: [4, -1, 5]
Beta Was this translation helpful? Give feedback.
All reactions