Pin numpy 1.23.5 for JetPack 4 on NVIDIA Jetson Nano (#18783)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Lakshantha Dissanayake 2025-01-20 16:09:32 -08:00 committed by GitHub
parent a2430d0478
commit fb3e5adfd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -104,7 +104,6 @@ export = [
"tensorstore>=0.1.63; platform_machine == 'aarch64' and python_version >= '3.9'", # for TF Raspberry Pi exports "tensorstore>=0.1.63; platform_machine == 'aarch64' and python_version >= '3.9'", # for TF Raspberry Pi exports
"keras", # not installed automatically by tensorflow>=2.16 "keras", # not installed automatically by tensorflow>=2.16
"flatbuffers>=23.5.26,<100; platform_machine == 'aarch64'", # update old 'flatbuffers' included inside tensorflow package "flatbuffers>=23.5.26,<100; platform_machine == 'aarch64'", # update old 'flatbuffers' included inside tensorflow package
"numpy==1.23.5; platform_machine == 'aarch64'", # fix error: `np.bool` was a deprecated alias for the builtin `bool` when using TensorRT models on NVIDIA Jetson
"h5py!=3.11.0; platform_machine == 'aarch64'", # fix h5py build issues due to missing aarch64 wheels in 3.11 release "h5py!=3.11.0; platform_machine == 'aarch64'", # fix h5py build issues due to missing aarch64 wheels in 3.11 release
] ]
solutions = [ solutions = [

View file

@ -13,7 +13,7 @@ import torch
import torch.nn as nn import torch.nn as nn
from PIL import Image from PIL import Image
from ultralytics.utils import ARM64, IS_JETSON, IS_RASPBERRYPI, LINUX, LOGGER, ROOT, yaml_load from ultralytics.utils import ARM64, IS_JETSON, IS_RASPBERRYPI, LINUX, LOGGER, PYTHON_VERSION, ROOT, yaml_load
from ultralytics.utils.checks import check_requirements, check_suffix, check_version, check_yaml from ultralytics.utils.checks import check_requirements, check_suffix, check_version, check_yaml
from ultralytics.utils.downloads import attempt_download_asset, is_url from ultralytics.utils.downloads import attempt_download_asset, is_url
@ -262,6 +262,11 @@ class AutoBackend(nn.Module):
# TensorRT # TensorRT
elif engine: elif engine:
LOGGER.info(f"Loading {w} for TensorRT inference...") LOGGER.info(f"Loading {w} for TensorRT inference...")
if IS_JETSON and PYTHON_VERSION <= "3.8.0":
# fix error: `np.bool` was a deprecated alias for the builtin `bool` for JetPack 4 with Python <= 3.8.0
check_requirements("numpy==1.23.5")
try: try:
import tensorrt as trt # noqa https://developer.nvidia.com/nvidia-tensorrt-download import tensorrt as trt # noqa https://developer.nvidia.com/nvidia-tensorrt-download
except ImportError: except ImportError: