Skip to content

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jun 6, 2022

May resolve #8102

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced model loading for device compatibility in the YOLOv5 ensemble setup.

πŸ“Š Key Changes

  • Unified model loading process to first load weights on the CPU.
  • After loading, the checkpoint is moved to the specified device (e.g., GPU or CPU) and converted to floating point precision (FP32).

🎯 Purpose & Impact

  • πŸš€ Ensures greater compatibility across different computing devices by first using the CPU for loading weights.
  • πŸ” Aids in avoiding potential out-of-memory errors on GPUs during the model loading phase.
  • 🌐 Simplifies the model loading pipeline, making it more robust and maintainable for users working with different hardware configurations.

@glenn-jocher glenn-jocher self-assigned this Jun 6, 2022
@glenn-jocher glenn-jocher changed the title experimental.py Apple MPS fix experimental.py Apple MPS device fix Jun 6, 2022
@glenn-jocher
Copy link
Member Author

Updates seem load faster than mapping directly to GPU...

%timeit torch.load('yolov5x.pt', map_location='cpu')['model'].to(torch.device('cuda:0')).float()
%timeit torch.load('yolov5x.pt', map_location=torch.device('cuda:0'))['model'].float()

1 loop, best of 5: 208 ms per loop
1 loop, best of 5: 254 ms per loop

@glenn-jocher glenn-jocher merged commit 18674e2 into master Jun 6, 2022
@glenn-jocher glenn-jocher deleted the fix/mps branch June 6, 2022 21:58
tdhooghe pushed a commit to tdhooghe/yolov5 that referenced this pull request Jun 10, 2022
* experimental.py Apple MPS fix

May resolve ultralytics#8102

* Update experimental.py

* Update experimental.py
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* experimental.py Apple MPS fix

May resolve ultralytics#8102

* Update experimental.py

* Update experimental.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Torch MPS (gpu) acceleration not working M1 Mac.

1 participant