ultralytics / ultralytics

Ultralytics YOLO11 🚀
https://docs.ultralytics.com
GNU Affero General Public License v3.0
36.58k stars 7.05k forks source link

Numpy incompatibilities on MacOS with new version 8.3.70 #18979

Open vsivsi opened 1 week ago

vsivsi commented 1 week ago

Search before asking

Ultralytics YOLO Component

Install

Bug

This PR https://github.com/ultralytics/ultralytics/pull/18945 seems to have introduced an Numpy incompatibility within the Ultralytics package on MacOS: e.g.

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/bin/yolo", line 6, in <module>
    from ultralytics.cfg import entrypoint
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/__init__.py", line 11, in <module>
    from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/__init__.py", line 3, in <module>
    from .fastsam import FastSAM
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/fastsam/__init__.py", line 3, in <module>
    from .model import FastSAM
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/fastsam/model.py", line 5, in <module>
    from ultralytics.engine.model import Model
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/engine/model.py", line 8, in <module>
    import torch
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/__init__.py", line 1477, in <module>
    from .functional import *  # noqa: F403
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/functional.py", line 9, in <module>
    import torch.nn.functional as F
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),

Environment

yolo checks                                                                      

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/bin/yolo", line 6, in <module>
    from ultralytics.cfg import entrypoint
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/__init__.py", line 11, in <module>
    from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/__init__.py", line 3, in <module>
    from .fastsam import FastSAM
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/fastsam/__init__.py", line 3, in <module>
    from .model import FastSAM
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/models/fastsam/model.py", line 5, in <module>
    from ultralytics.engine.model import Model
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/ultralytics/engine/model.py", line 8, in <module>
    import torch
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/__init__.py", line 1477, in <module>
    from .functional import *  # noqa: F403
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/functional.py", line 9, in <module>
    import torch.nn.functional as F
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/Users/vsi/.cache/uv/archive-v0/YW2Jvm6FScpaJemyWrY7l/lib/python3.12/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
Ultralytics 8.3.70 🚀 Python-3.12.8 torch-2.2.2 CPU (Intel Core(TM) i7-1068NG7 2.30GHz)
Setup complete ✅ (8 CPUs, 32.0 GB RAM, 612.7/3727.1 GB disk)

OS                  macOS-15.3-x86_64-i386-64bit
Environment         Darwin
Python              3.12.8
Install             pip
RAM                 32.00 GB
Disk                612.7/3727.1 GB
CPU                 Intel Core(TM) i7-1068NG7 2.30GHz
CPU count           8
GPU                 None
GPU count           None
CUDA                None

numpy               ✅ 2.1.1<=2.1.1,>=1.23.0
matplotlib          ✅ 3.10.0>=3.3.0
opencv-python       ✅ 4.11.0.86>=4.6.0
pillow              ✅ 11.1.0>=7.1.2
pyyaml              ✅ 6.0.2>=5.3.1
requests            ✅ 2.32.3>=2.23.0
scipy               ✅ 1.15.1>=1.4.1
torch               ✅ 2.2.2>=1.8.0
torch               ✅ 2.2.2!=2.4.0,>=1.8.0; sys_platform == "win32"
torchvision         ✅ 0.17.2>=0.9.0
tqdm                ✅ 4.67.1>=4.64.0
psutil              ✅ 6.1.1
py-cpuinfo          ✅ 9.0.0
pandas              ✅ 2.2.3>=1.1.4
seaborn             ✅ 0.13.2>=0.11.0
ultralytics-thop    ✅ 2.0.14>=2.0.0

Minimal Reproducible Example

# Here's a full dump of a reproduction. Manually downgrading the automatically selected numpy version resolves issue.
% python3 -m venv myenv
% source myenv/bin/activate
(myenv) % pip install ultralytics
Collecting ultralytics
  Downloading ultralytics-8.3.70-py3-none-any.whl.metadata (35 kB)
Collecting numpy<=2.1.1,>=1.23.0 (from ultralytics)
  Downloading numpy-2.1.1-cp312-cp312-macosx_14_0_x86_64.whl.metadata (60 kB)
Collecting matplotlib>=3.3.0 (from ultralytics)
  Downloading matplotlib-3.10.0-cp312-cp312-macosx_10_13_x86_64.whl.metadata (11 kB)
Collecting opencv-python>=4.6.0 (from ultralytics)
  Downloading opencv_python-4.11.0.86-cp37-abi3-macosx_13_0_x86_64.whl.metadata (20 kB)
Collecting pillow>=7.1.2 (from ultralytics)
  Downloading pillow-11.1.0-cp312-cp312-macosx_10_13_x86_64.whl.metadata (9.1 kB)
Collecting pyyaml>=5.3.1 (from ultralytics)
  Downloading PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl.metadata (2.1 kB)
Collecting requests>=2.23.0 (from ultralytics)
  Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting scipy>=1.4.1 (from ultralytics)
  Downloading scipy-1.15.1-cp312-cp312-macosx_14_0_x86_64.whl.metadata (61 kB)
Collecting torch>=1.8.0 (from ultralytics)
  Downloading torch-2.2.2-cp312-none-macosx_10_9_x86_64.whl.metadata (25 kB)
Collecting torchvision>=0.9.0 (from ultralytics)
  Downloading torchvision-0.17.2-cp312-cp312-macosx_10_13_x86_64.whl.metadata (6.6 kB)
Collecting tqdm>=4.64.0 (from ultralytics)
  Downloading tqdm-4.67.1-py3-none-any.whl.metadata (57 kB)
Collecting psutil (from ultralytics)
  Downloading psutil-6.1.1-cp36-abi3-macosx_10_9_x86_64.whl.metadata (22 kB)
Collecting py-cpuinfo (from ultralytics)
  Downloading py_cpuinfo-9.0.0-py3-none-any.whl.metadata (794 bytes)
Collecting pandas>=1.1.4 (from ultralytics)
  Downloading pandas-2.2.3-cp312-cp312-macosx_10_9_x86_64.whl.metadata (89 kB)
Collecting seaborn>=0.11.0 (from ultralytics)
  Downloading seaborn-0.13.2-py3-none-any.whl.metadata (5.4 kB)
Collecting ultralytics-thop>=2.0.0 (from ultralytics)
  Downloading ultralytics_thop-2.0.14-py3-none-any.whl.metadata (9.4 kB)
Collecting contourpy>=1.0.1 (from matplotlib>=3.3.0->ultralytics)
  Downloading contourpy-1.3.1-cp312-cp312-macosx_10_13_x86_64.whl.metadata (5.4 kB)
Collecting cycler>=0.10 (from matplotlib>=3.3.0->ultralytics)
  Downloading cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)
Collecting fonttools>=4.22.0 (from matplotlib>=3.3.0->ultralytics)
  Downloading fonttools-4.55.8-cp312-cp312-macosx_10_13_x86_64.whl.metadata (101 kB)
Collecting kiwisolver>=1.3.1 (from matplotlib>=3.3.0->ultralytics)
  Downloading kiwisolver-1.4.8-cp312-cp312-macosx_10_13_x86_64.whl.metadata (6.2 kB)
Collecting packaging>=20.0 (from matplotlib>=3.3.0->ultralytics)
  Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
Collecting pyparsing>=2.3.1 (from matplotlib>=3.3.0->ultralytics)
  Downloading pyparsing-3.2.1-py3-none-any.whl.metadata (5.0 kB)
Collecting python-dateutil>=2.7 (from matplotlib>=3.3.0->ultralytics)
  Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz>=2020.1 (from pandas>=1.1.4->ultralytics)
  Downloading pytz-2025.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting tzdata>=2022.7 (from pandas>=1.1.4->ultralytics)
  Downloading tzdata-2025.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting charset-normalizer<4,>=2 (from requests>=2.23.0->ultralytics)
  Downloading charset_normalizer-3.4.1-cp312-cp312-macosx_10_13_universal2.whl.metadata (35 kB)
Collecting idna<4,>=2.5 (from requests>=2.23.0->ultralytics)
  Downloading idna-3.10-py3-none-any.whl.metadata (10 kB)
Collecting urllib3<3,>=1.21.1 (from requests>=2.23.0->ultralytics)
  Downloading urllib3-2.3.0-py3-none-any.whl.metadata (6.5 kB)
Collecting certifi>=2017.4.17 (from requests>=2.23.0->ultralytics)
  Downloading certifi-2025.1.31-py3-none-any.whl.metadata (2.5 kB)
Collecting filelock (from torch>=1.8.0->ultralytics)
  Downloading filelock-3.17.0-py3-none-any.whl.metadata (2.9 kB)
Collecting typing-extensions>=4.8.0 (from torch>=1.8.0->ultralytics)
  Downloading typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Collecting sympy (from torch>=1.8.0->ultralytics)
  Downloading sympy-1.13.3-py3-none-any.whl.metadata (12 kB)
Collecting networkx (from torch>=1.8.0->ultralytics)
  Downloading networkx-3.4.2-py3-none-any.whl.metadata (6.3 kB)
Collecting jinja2 (from torch>=1.8.0->ultralytics)
  Downloading jinja2-3.1.5-py3-none-any.whl.metadata (2.6 kB)
Collecting fsspec (from torch>=1.8.0->ultralytics)
  Downloading fsspec-2025.2.0-py3-none-any.whl.metadata (11 kB)
Collecting six>=1.5 (from python-dateutil>=2.7->matplotlib>=3.3.0->ultralytics)
  Downloading six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
Collecting MarkupSafe>=2.0 (from jinja2->torch>=1.8.0->ultralytics)
  Downloading MarkupSafe-3.0.2-cp312-cp312-macosx_10_13_universal2.whl.metadata (4.0 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy->torch>=1.8.0->ultralytics)
  Downloading mpmath-1.3.0-py3-none-any.whl.metadata (8.6 kB)
Downloading ultralytics-8.3.70-py3-none-any.whl (914 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 914.9/914.9 kB 10.1 MB/s eta 0:00:00
Downloading matplotlib-3.10.0-cp312-cp312-macosx_10_13_x86_64.whl (8.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.2/8.2 MB 13.8 MB/s eta 0:00:00
Downloading numpy-2.1.1-cp312-cp312-macosx_14_0_x86_64.whl (6.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.6/6.6 MB 11.9 MB/s eta 0:00:00
Downloading opencv_python-4.11.0.86-cp37-abi3-macosx_13_0_x86_64.whl (56.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.7/56.7 MB 28.2 MB/s eta 0:00:00
Downloading pandas-2.2.3-cp312-cp312-macosx_10_9_x86_64.whl (12.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.5/12.5 MB 21.1 MB/s eta 0:00:00
Downloading pillow-11.1.0-cp312-cp312-macosx_10_13_x86_64.whl (3.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 24.3 MB/s eta 0:00:00
Downloading PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl (183 kB)
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
Downloading scipy-1.15.1-cp312-cp312-macosx_14_0_x86_64.whl (28.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 28.0/28.0 MB 29.6 MB/s eta 0:00:00
Downloading seaborn-0.13.2-py3-none-any.whl (294 kB)
Downloading torch-2.2.2-cp312-none-macosx_10_9_x86_64.whl (150.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 150.8/150.8 MB 28.3 MB/s eta 0:00:00
Downloading torchvision-0.17.2-cp312-cp312-macosx_10_13_x86_64.whl (1.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 13.7 MB/s eta 0:00:00
Downloading tqdm-4.67.1-py3-none-any.whl (78 kB)
Downloading ultralytics_thop-2.0.14-py3-none-any.whl (26 kB)
Downloading psutil-6.1.1-cp36-abi3-macosx_10_9_x86_64.whl (247 kB)
Downloading py_cpuinfo-9.0.0-py3-none-any.whl (22 kB)
Downloading certifi-2025.1.31-py3-none-any.whl (166 kB)
Downloading charset_normalizer-3.4.1-cp312-cp312-macosx_10_13_universal2.whl (196 kB)
Downloading contourpy-1.3.1-cp312-cp312-macosx_10_13_x86_64.whl (271 kB)
Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB)
Downloading fonttools-4.55.8-cp312-cp312-macosx_10_13_x86_64.whl (2.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 16.6 MB/s eta 0:00:00
Downloading idna-3.10-py3-none-any.whl (70 kB)
Downloading kiwisolver-1.4.8-cp312-cp312-macosx_10_13_x86_64.whl (66 kB)
Downloading packaging-24.2-py3-none-any.whl (65 kB)
Downloading pyparsing-3.2.1-py3-none-any.whl (107 kB)
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Downloading pytz-2025.1-py2.py3-none-any.whl (507 kB)
Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Downloading tzdata-2025.1-py2.py3-none-any.whl (346 kB)
Downloading urllib3-2.3.0-py3-none-any.whl (128 kB)
Downloading filelock-3.17.0-py3-none-any.whl (16 kB)
Downloading fsspec-2025.2.0-py3-none-any.whl (184 kB)
Downloading jinja2-3.1.5-py3-none-any.whl (134 kB)
Downloading networkx-3.4.2-py3-none-any.whl (1.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 14.9 MB/s eta 0:00:00
Downloading sympy-1.13.3-py3-none-any.whl (6.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.2/6.2 MB 20.3 MB/s eta 0:00:00
Downloading MarkupSafe-3.0.2-cp312-cp312-macosx_10_13_universal2.whl (14 kB)
Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 kB 6.5 MB/s eta 0:00:00
Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pytz, py-cpuinfo, mpmath, urllib3, tzdata, typing-extensions, tqdm, sympy, six, pyyaml, pyparsing, psutil, pillow, packaging, numpy, networkx, MarkupSafe, kiwisolver, idna, fsspec, fonttools, filelock, cycler, charset-normalizer, certifi, scipy, requests, python-dateutil, opencv-python, jinja2, contourpy, torch, pandas, matplotlib, ultralytics-thop, torchvision, seaborn, ultralytics
Successfully installed MarkupSafe-3.0.2 certifi-2025.1.31 charset-normalizer-3.4.1 contourpy-1.3.1 cycler-0.12.1 filelock-3.17.0 fonttools-4.55.8 fsspec-2025.2.0 idna-3.10 jinja2-3.1.5 kiwisolver-1.4.8 matplotlib-3.10.0 mpmath-1.3.0 networkx-3.4.2 numpy-2.1.1 opencv-python-4.11.0.86 packaging-24.2 pandas-2.2.3 pillow-11.1.0 psutil-6.1.1 py-cpuinfo-9.0.0 pyparsing-3.2.1 python-dateutil-2.9.0.post0 pytz-2025.1 pyyaml-6.0.2 requests-2.32.3 scipy-1.15.1 seaborn-0.13.2 six-1.17.0 sympy-1.13.3 torch-2.2.2 torchvision-0.17.2 tqdm-4.67.1 typing-extensions-4.12.2 tzdata-2025.1 ultralytics-8.3.70 ultralytics-thop-2.0.14 urllib3-2.3.0

(myenv) % yolo

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.1 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/Users/vsi/yolotest/myenv/bin/yolo", line 5, in <module>
    from ultralytics.cfg import entrypoint
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/ultralytics/__init__.py", line 11, in <module>
    from ultralytics.models import NAS, RTDETR, SAM, YOLO, FastSAM, YOLOWorld
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/ultralytics/models/__init__.py", line 3, in <module>
    from .fastsam import FastSAM
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/ultralytics/models/fastsam/__init__.py", line 3, in <module>
    from .model import FastSAM
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/ultralytics/models/fastsam/model.py", line 5, in <module>
    from ultralytics.engine.model import Model
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/ultralytics/engine/model.py", line 8, in <module>
    import torch
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/__init__.py", line 1477, in <module>
    from .functional import *  # noqa: F403
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/functional.py", line 9, in <module>
    import torch.nn.functional as F
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/nn/__init__.py", line 1, in <module>
    from .modules import *  # noqa: F403
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/nn/modules/__init__.py", line 35, in <module>
    from .transformer import TransformerEncoder, TransformerDecoder, \
  File "/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/nn/modules/transformer.py", line 20, in <module>
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
/Users/vsi/yolotest/myenv/lib/python3.12/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /Users/runner/work/pytorch/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)
  device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),

    Arguments received: ['yolo']. Ultralytics 'yolo' commands use the following syntax:

        yolo TASK MODE ARGS

        Where   TASK (optional) is one of frozenset({'obb', 'classify', 'segment', 'detect', 'pose'})
                MODE (required) is one of frozenset({'val', 'benchmark', 'predict', 'export', 'train', 'track'})
                ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
                    See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'

    1. Train a detection model for 10 epochs with an initial learning_rate of 0.01
        yolo train data=coco8.yaml model=yolo11n.pt epochs=10 lr0=0.01

    2. Predict a YouTube video using a pretrained segmentation model at image size 320:
        yolo predict model=yolo11n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320

    3. Val a pretrained detection model at batch-size 1 and image size 640:
        yolo val model=yolo11n.pt data=coco8.yaml batch=1 imgsz=640

    4. Export a YOLO11n classification model to ONNX format at image size 224 by 128 (no TASK required)
        yolo export model=yolo11n-cls.pt format=onnx imgsz=224,128

    5. Ultralytics solutions usage
        yolo solutions count or in ['heatmap', 'queue', 'speed', 'workout', 'analytics', 'trackzone', 'inference'] source="path/to/video/file.mp4"

    6. Run special commands:
        yolo help
        yolo checks
        yolo version
        yolo settings
        yolo copy-cfg
        yolo cfg
        yolo solutions help

    Docs: https://docs.ultralytics.com
    Solutions: https://docs.ultralytics.com/solutions/
    Community: https://community.ultralytics.com
    GitHub: https://github.com/ultralytics/ultralytics

(myenv) % pip install 'numpy<2'
Collecting numpy<2
  Downloading numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl.metadata (61 kB)
Downloading numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl (20.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 20.3/20.3 MB 18.0 MB/s eta 0:00:00
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 2.1.1
    Uninstalling numpy-2.1.1:
      Successfully uninstalled numpy-2.1.1
Successfully installed numpy-1.26.4
(myenv) % yolo                 

    Arguments received: ['yolo']. Ultralytics 'yolo' commands use the following syntax:

        yolo TASK MODE ARGS

        Where   TASK (optional) is one of frozenset({'obb', 'segment', 'detect', 'pose', 'classify'})
                MODE (required) is one of frozenset({'track', 'train', 'predict', 'benchmark', 'val', 'export'})
                ARGS (optional) are any number of custom 'arg=value' pairs like 'imgsz=320' that override defaults.
                    See all ARGS at https://docs.ultralytics.com/usage/cfg or with 'yolo cfg'

    1. Train a detection model for 10 epochs with an initial learning_rate of 0.01
        yolo train data=coco8.yaml model=yolo11n.pt epochs=10 lr0=0.01

    2. Predict a YouTube video using a pretrained segmentation model at image size 320:
        yolo predict model=yolo11n-seg.pt source='https://youtu.be/LNwODJXcvt4' imgsz=320

    3. Val a pretrained detection model at batch-size 1 and image size 640:
        yolo val model=yolo11n.pt data=coco8.yaml batch=1 imgsz=640

    4. Export a YOLO11n classification model to ONNX format at image size 224 by 128 (no TASK required)
        yolo export model=yolo11n-cls.pt format=onnx imgsz=224,128

    5. Ultralytics solutions usage
        yolo solutions count or in ['heatmap', 'queue', 'speed', 'workout', 'analytics', 'trackzone', 'inference'] source="path/to/video/file.mp4"

    6. Run special commands:
        yolo help
        yolo checks
        yolo version
        yolo settings
        yolo copy-cfg
        yolo cfg
        yolo solutions help

    Docs: https://docs.ultralytics.com
    Solutions: https://docs.ultralytics.com/solutions/
    Community: https://community.ultralytics.com
    GitHub: https://github.com/ultralytics/ultralytics

(myenv) % deactivate

Additional

No response

Are you willing to submit a PR?

UltralyticsAssistant commented 1 week ago

👋 Hello @vsivsi, thank you for bringing this up and for your detailed report 🚀! We appreciate your thorough analysis and inclusion of a Minimal Reproducible Example (MRE) 🐛. This will help us investigate the potential NumPy compatibility issue on macOS more efficiently.

To assist further, we'd suggest checking the following while we look into this:

Upgrade

Ensure you are using the latest ultralytics package and related dependencies, as recent bug fixes or compatibility updates might already address the issue. You can upgrade with:

pip install -U ultralytics

Additionally, confirm that your environment meets the package requirements (Python>=3.8, PyTorch>=1.8).

Environment Options

YOLO can also be run in verified environments where all dependencies are preconfigured:

For heavy workloads, verified cloud environments such as AWS, Google Cloud, or Docker Images might be beneficial.

Quick Fix Option

As noted in your report, downgrading to a compatible version of NumPy (numpy<2) might temporarily mitigate the issue:

pip install "numpy<2"

This could serve as a workaround while our team investigates the compatibility with NumPy 2.x further.

Community Support

If you'd like to share this issue with the community or discuss similar experiences, consider engaging with others on:

Status Badge

Ultralytics CI

If this badge is green 💚, all Ultralytics CI tests including MacOS are passing. CI runs daily to ensure cross-platform compatibility with all supported modes and tasks.

An Ultralytics engineer will follow up on this issue soon! Let us know if you observe any additional behavior that might help us reproduce this more effectively. Thanks for helping us improve Ultralytics! 😊

Y-T-G commented 1 week ago

You can try upgrading PyTorch