ultralytics 8.3.15 new TPU device-selection ability (#16576)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> Co-authored-by: Skillnoob <78843978+Skillnoob@users.noreply.github.com> Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
ccda7ff973
commit
22ebd44f62
4 changed files with 42 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.3.14"
|
||||
__version__ = "8.3.15"
|
||||
|
||||
import os
|
||||
|
||||
|
|
|
|||
|
|
@ -336,11 +336,15 @@ class AutoBackend(nn.Module):
|
|||
|
||||
Interpreter, load_delegate = tf.lite.Interpreter, tf.lite.experimental.load_delegate
|
||||
if edgetpu: # TF Edge TPU https://coral.ai/software/#edgetpu-runtime
|
||||
LOGGER.info(f"Loading {w} for TensorFlow Lite Edge TPU inference...")
|
||||
device = device[3:] if str(device).startswith("tpu") else ":0"
|
||||
LOGGER.info(f"Loading {w} on device {device[1:]} for TensorFlow Lite Edge TPU inference...")
|
||||
delegate = {"Linux": "libedgetpu.so.1", "Darwin": "libedgetpu.1.dylib", "Windows": "edgetpu.dll"}[
|
||||
platform.system()
|
||||
]
|
||||
interpreter = Interpreter(model_path=w, experimental_delegates=[load_delegate(delegate)])
|
||||
interpreter = Interpreter(
|
||||
model_path=w,
|
||||
experimental_delegates=[load_delegate(delegate, options={"device": device})],
|
||||
)
|
||||
else: # TFLite
|
||||
LOGGER.info(f"Loading {w} for TensorFlow Lite inference...")
|
||||
interpreter = Interpreter(model_path=w) # load TFLite model
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ def select_device(device="", batch=0, newline=False, verbose=True):
|
|||
Note:
|
||||
Sets the 'CUDA_VISIBLE_DEVICES' environment variable for specifying which GPUs to use.
|
||||
"""
|
||||
if isinstance(device, torch.device):
|
||||
if isinstance(device, torch.device) or str(device).startswith("tpu"):
|
||||
return device
|
||||
|
||||
s = f"Ultralytics {__version__} 🚀 Python-{PYTHON_VERSION} torch-{torch.__version__} "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue