ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.39k stars 16.26k forks source link

YOLOv5 installed failed on Macbook M1 #2075

Closed whenyougone closed 3 years ago

whenyougone commented 3 years ago

hello all,

I tried installing Yolo5 on Macbook M1, always failed on installing python libraries.

My python version: python 3.8.2 (default, Dec 21 2020, 15:06:03) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin

[makele@madeMacBook-Air]yolov5 % sudo pip3 install -r requirements.txt ARNING: The directory '/Users/makele/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting Cython Downloading http://mirrors.aliyun.com/pypi/packages/ad/4b/9e53bcce3c959fd0db143626e573210bba07be810fe8d7296373948c4183/Cython-0.29.21-py2.py3-none-any.whl (974 kB) |████████████████████████████████| 974 kB 15.9 MB/s Collecting matplotlib>=3.2.2 Downloading http://mirrors.aliyun.com/pypi/packages/7b/b3/7c48f648bf83f39d4385e0169d1b68218b838e185047f7f613b1cfc57947/matplotlib-3.3.3.tar.gz (37.9 MB) |████████████████████████████████| 37.9 MB 22.0 MB/s ERROR: Command errored out with exit status 1: command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-ukrzi9b0/matplotlib_a48d3719e7794858b7ccf441c9706c79/setup.py'"'"'; file='"'"'/private/tmp/pip-install-ukrzi9b0/matplotlib_a48d3719e7794858b7ccf441c9706c79/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-idb8b9zq cwd: /private/tmp/pip-install-ukrzi9b0/matplotlib_a48d3719e7794858b7ccf441c9706c79/ Complete output (109 lines): Processing numpy/random/_bounded_integers.pxd.in Processing numpy/random/_philox.pyx Traceback (most recent call last): File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 59, in process_pyx from Cython.Compiler.Version import version as cython_version ModuleNotFoundError: No module named 'Cython'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 235, in <module>
    main()
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 231, in main
    find_process_files(root_dir)
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 222, in find_process_files
    process(root_dir, fromfile, tofile, function, hash_db)
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 188, in process
    processor_function(fromfile, tofile)
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/tools/cythonize.py", line 64, in process_pyx
    raise OSError('Cython needs to be installed in Python as a module')
OSError: Cython needs to be installed in Python as a module
Running from numpy source directory.
/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py:485: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
  run_build = parse_setuppy_commands()
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
    yield saved
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
    yield
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 513, in <module>
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 493, in setup_package
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 290, in generate_cython
    "cycler>=0.10",
RuntimeError: Running cythonize failed!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-install-ukrzi9b0/matplotlib_a48d3719e7794858b7ccf441c9706c79/setup.py", line 242, in <module>
    setup(  # Finally, pass this all along to distutils to do the heavy lifting.
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 144, in setup
    _install_setup_requires(attrs)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 716, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 780, in resolve
    dist = best[req.key] = env.best_match(
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1065, in best_match
    return self.obtain(req, installer)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1077, in obtain
    return installer(requirement)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 786, in fetch_build_egg
    return cmd.easy_install(req)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 679, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 705, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/command/easy_install.py", line 1144, in run_setup
    run_setup(setup_script, args)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 253, in run_setup
    raise
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
    yield
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 166, in save_modules
    saved_exc.resume()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 141, in resume
    six.reraise(type, exc, self._tb)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/_vendor/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 154, in save_modules
    yield saved
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 195, in setup_context
    yield
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 250, in run_setup
    _execfile(setup_script, ns)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 513, in <module>
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 493, in setup_package
  File "/tmp/easy_install-0aqxli8a/numpy-1.20.0rc2/setup.py", line 290, in generate_cython
    "cycler>=0.10",
RuntimeError: Running cythonize failed!

Edit setup.cfg to change the build options; suppress output with --quiet.

BUILDING MATPLOTLIB
  matplotlib: yes [3.3.3]
      python: yes [3.8.2 (default, Nov  4 2020, 21:23:28)  [Clang 12.0.0
                  (clang-1200.0.32.28)]]
    platform: yes [darwin]
 sample_data: yes [installing]
       tests: no  [skipping due to configuration]
      macosx: yes [installing]

Cythonizing sources
github-actions[bot] commented 3 years ago

👋 Hello @whenyougone, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@whenyougone YOLOv5 installs correctly on M1 Macbooks, we have it running currently on a 13" M1 Macbook Pro with no issues and no extra steps required for installation. I recommend you follow the above instructions.

whenyougone commented 3 years ago

@glenn-jocher thanks for info. I am using MacBook not MacBook Pro, the SoC HW platform should be similar. I will try again and follow your suggestion. BTW: Does YOLOv5 support MacBook M1 GPU acceleration like Intel platform with Nvidia GPU?

Thanks!

glenn-jocher commented 3 years ago

@whenyougone for PyTorch M1 exploitation/compatibility you might want to make your voice heard on the main thread here: https://github.com/pytorch/pytorch/issues/47702

zhiqwang commented 3 years ago

There are also some discussions here https://github.com/pytorch/pytorch/issues/48145#issuecomment-748336874

whenyougone commented 3 years ago

Thanks the hints @zhiqwang @glenn-jocher