YOLOv5 Apple Metal Performance Shader (MPS) support (#7878)

* Apple Metal Performance Shader (MPS) device support

Following https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/

Should work with Apple M1 devices with PyTorch nightly installed with command `--device mps`. Usage examples:
```bash
python train.py --device mps
python detect.py --device mps
python val.py --device mps
```

* Update device strategy to fix MPS issue
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-05-24 13:34:32 +02:00
1 parent 27911dc824
commit c215878f11
5 files changed
+11 -8

No files matched your search

+1 -1
View File
@@ -536,7 +536,7 @@ def run(
):
# PyTorch model
im = torch.zeros((batch_size, 3, *imgsz)) # BCHW image
model = attempt_load(weights, map_location=torch.device('cpu'), inplace=True, fuse=False)
model = attempt_load(weights, device=torch.device('cpu'), inplace=True, fuse=False)
_ = model(im) # inference
model.info()