Standardize license headers in Python files (#13490)
* Refactor code for speed and clarity * Auto-format by https://ultralytics.com/actions --------- Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
52 files changed
+67
-64
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# Ultralytics YOLOv5 🚀, AGPL-3.0 license
|
||||
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||
"""PyTorch utils."""
|
||||
|
||||
import math
|
||||
@@ -121,9 +121,9 @@ def select_device(device="", batch_size=0, newline=True):
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1" # force torch.cuda.is_available() = False
|
||||
elif device: # non-cpu device requested
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = device # set environment variable - must be before assert is_available()
|
||||
assert torch.cuda.is_available() and torch.cuda.device_count() >= len(
|
||||
device.replace(",", "")
|
||||
), f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)"
|
||||
assert torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(",", "")), (
|
||||
f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)"
|
||||
)
|
||||
|
||||
if not cpu and not mps and torch.cuda.is_available(): # prefer GPU if available
|
||||
devices = device.split(",") if device else "0" # range(torch.cuda.device_count()) # i.e. 0,1,6,7
|
||||
|
||||
Reference in new issue
Block a user