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:
1 parent
27911dc824
commit
c215878f11
5 files changed
+11
-8
No files matched your search
+1
-1
@@ -331,7 +331,7 @@ class DetectMultiBackend(nn.Module):
|
||||
names = yaml.safe_load(f)['names']
|
||||
|
||||
if pt: # PyTorch
|
||||
model = attempt_load(weights if isinstance(weights, list) else w, map_location=device)
|
||||
model = attempt_load(weights if isinstance(weights, list) else w, device=device)
|
||||
stride = max(int(model.stride.max()), 32) # model stride
|
||||
names = model.module.names if hasattr(model, 'module') else model.names # get class names
|
||||
model.half() if fp16 else model.float()
|
||||
|
||||
Reference in new issue
Block a user