Skip to content

Commit

Permalink
Fix device counting method to account for double-digit device IDs (ul…
Browse files Browse the repository at this point in the history
…tralytics#8502)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
2 people authored and hmurari committed Apr 17, 2024
1 parent 816e4fb commit 8253e3b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ultralytics/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def select_device(device="", batch=0, newline=False, verbose=True):
device = "0"
visible = os.environ.get("CUDA_VISIBLE_DEVICES", None)
os.environ["CUDA_VISIBLE_DEVICES"] = device # set environment variable - must be before assert is_available()
if not (torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(",", ""))):
if not (torch.cuda.is_available() and torch.cuda.device_count() >= len(device.split(","))):
LOGGER.info(s)
install = (
"See https://pytorch.org/get-started/locally/ for up-to-date torch install instructions if no "
Expand Down

0 comments on commit 8253e3b

Please sign in to comment.