ultralytics 8.3.63 IMX500 sudo install fix (#18714)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
309f5cafc1
commit
f777b63c8b
4 changed files with 29 additions and 5 deletions
|
|
@ -109,4 +109,8 @@ keywords: Ultralytics, YOLO, utility functions, version checks, requirements, im
|
||||||
|
|
||||||
## ::: ultralytics.utils.checks.cuda_is_available
|
## ::: ultralytics.utils.checks.cuda_is_available
|
||||||
|
|
||||||
|
<br><br><hr><br>
|
||||||
|
|
||||||
|
## ::: ultralytics.utils.checks.is_sudo_available
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||||
|
|
||||||
__version__ = "8.3.62"
|
__version__ = "8.3.63"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,13 @@ from ultralytics.utils import (
|
||||||
get_default_args,
|
get_default_args,
|
||||||
yaml_save,
|
yaml_save,
|
||||||
)
|
)
|
||||||
from ultralytics.utils.checks import check_imgsz, check_is_path_safe, check_requirements, check_version
|
from ultralytics.utils.checks import (
|
||||||
|
check_imgsz,
|
||||||
|
check_is_path_safe,
|
||||||
|
check_requirements,
|
||||||
|
check_version,
|
||||||
|
is_sudo_available,
|
||||||
|
)
|
||||||
from ultralytics.utils.downloads import attempt_download_asset, get_github_assets, safe_download
|
from ultralytics.utils.downloads import attempt_download_asset, get_github_assets, safe_download
|
||||||
from ultralytics.utils.files import file_size, spaces_in_path
|
from ultralytics.utils.files import file_size, spaces_in_path
|
||||||
from ultralytics.utils.ops import Profile
|
from ultralytics.utils.ops import Profile
|
||||||
|
|
@ -1071,7 +1077,6 @@ class Exporter:
|
||||||
assert LINUX, f"export only supported on Linux. See {help_url}"
|
assert LINUX, f"export only supported on Linux. See {help_url}"
|
||||||
if subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True).returncode != 0:
|
if subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True).returncode != 0:
|
||||||
LOGGER.info(f"\n{prefix} export requires Edge TPU compiler. Attempting install from {help_url}")
|
LOGGER.info(f"\n{prefix} export requires Edge TPU compiler. Attempting install from {help_url}")
|
||||||
sudo = subprocess.run("sudo --version >/dev/null", shell=True).returncode == 0 # sudo installed on system
|
|
||||||
for c in (
|
for c in (
|
||||||
"curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -",
|
"curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -",
|
||||||
'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | '
|
'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | '
|
||||||
|
|
@ -1079,7 +1084,7 @@ class Exporter:
|
||||||
"sudo apt-get update",
|
"sudo apt-get update",
|
||||||
"sudo apt-get install edgetpu-compiler",
|
"sudo apt-get install edgetpu-compiler",
|
||||||
):
|
):
|
||||||
subprocess.run(c if sudo else c.replace("sudo ", ""), shell=True, check=True)
|
subprocess.run(c if is_sudo_available() else c.replace("sudo ", ""), shell=True, check=True)
|
||||||
ver = subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1]
|
ver = subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1]
|
||||||
|
|
||||||
LOGGER.info(f"\n{prefix} starting export with Edge TPU compiler {ver}...")
|
LOGGER.info(f"\n{prefix} starting export with Edge TPU compiler {ver}...")
|
||||||
|
|
@ -1160,7 +1165,10 @@ class Exporter:
|
||||||
if "openjdk 17" not in str(out.stdout):
|
if "openjdk 17" not in str(out.stdout):
|
||||||
raise FileNotFoundError
|
raise FileNotFoundError
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
subprocess.run(["sudo", "apt", "install", "-y", "openjdk-17-jdk", "openjdk-17-jre"], check=True)
|
c = ["apt", "install", "-y", "openjdk-17-jdk", "openjdk-17-jre"]
|
||||||
|
if is_sudo_available():
|
||||||
|
c.insert(0, "sudo")
|
||||||
|
subprocess.run(c, check=True)
|
||||||
|
|
||||||
def representative_dataset_gen(dataloader=self.get_int8_calibration_dataloader(prefix)):
|
def representative_dataset_gen(dataloader=self.get_int8_calibration_dataloader(prefix)):
|
||||||
for batch in dataloader:
|
for batch in dataloader:
|
||||||
|
|
|
||||||
|
|
@ -782,6 +782,18 @@ def cuda_is_available() -> bool:
|
||||||
return cuda_device_count() > 0
|
return cuda_device_count() > 0
|
||||||
|
|
||||||
|
|
||||||
|
def is_sudo_available() -> bool:
|
||||||
|
"""
|
||||||
|
Check if the sudo command is available in the environment.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the sudo command is available, False otherwise.
|
||||||
|
"""
|
||||||
|
if WINDOWS:
|
||||||
|
return False
|
||||||
|
return subprocess.run(["sudo", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
|
||||||
|
|
||||||
|
|
||||||
# Run checks and define constants
|
# Run checks and define constants
|
||||||
check_python("3.8", hard=False, verbose=True) # check python version
|
check_python("3.8", hard=False, verbose=True) # check python version
|
||||||
check_torchvision() # check torch-torchvision compatibility
|
check_torchvision() # check torch-torchvision compatibility
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue