So we got our Mac mini M1, and gave it a quick try running DepthAI on it. Got our prebuilt wheels (for Intel CPUs - x86_64) working very well using the Rosetta emulator.

First, the native Apple Silicon support for Homebrew is still being actively worked on (with several issues still existing), so I didn't attempted installing it / building from sources. See https://github.com/Homebrew/brew/issues/7857

The steps followed:

  1. Install Rosetta (note it may be already installed, for example attempting to install other apps (current TeamViewer) may prompt to install Rosetta first):
    softwareupdate --install-rosetta

  2. To run commands with x86_64 emulation, it is possible to prefix them with arch -x86_64

    But there's an easier way, to open the terminal app directly using Rosetta. For example, I copied Terminal to Desktop, renamed it to Terminal-x86_64 , and tick the checkbox Open using Rosetta:

Then after opening the terminal, it can be checked under what architecture it runs using uname -m

  • with Rosetta it prints: x86_64
  • native: arm64

After that, it's just the standard procedure to install Brew (it installed python 3.8.2 by default), clone depthai repo, running ./install_requirements.py , and finally ./depthai_demo.py.

Cheers,
The Luxonis Team

2 months later

I was able to follow the instructions here for Mac with no issues on my M1 Macbook Air, however I used iterm2, and not terminal. I also did not run it in rosetta mode.

I am, however, having issues with connectivity on both a USBA-> C cable that came with the camera with an additional USBA->C adapter, and a short USBC/Thunderbolt cable (which I would assume would work)

Running with --force_usb2 works for now.

    11 days later
    a year later

    With a new Oak-D-Lite on my Mac Mini M1 Monterey, using a 2nd Rosetta enabled Terminal that shows "uname -m" is x86_64, I was unable to run "python3 -m pip install depthai", apparently due to conflict with the "default" installation in /opt/homebrew. Collecting depthai
    Using cached depthai-2.14.0.0.tar.gz (325 kB)
    Installing build dependencies ... done
    Getting requirements to build wheel ... done
    Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: depthai
    Building wheel for depthai (pyproject.toml) ... error
    ERROR: Command errored out with exit status 1:
    command: /opt/homebrew/opt/python@3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/vendor/pep517/in_process/in_process.py build_wheel /var/folders/_j/1spktm_s02xgtcbwv77rwfn80000gn/T/tmplmufspx7 ....and lots more errors !

    • erik replied to this.

      Hello RobotRoss , what do you mean by 2nd Rosetta enabled terminal? We should have prebuilt wheels for that (x86_64), so I am not sure why it's trying to build new wheels for that. Which python version are you using?
      Thanks, Erik

      Erik, Tnx for response. My (Homebrew) installed python3 from arm64 terminal.app (uname -m arm6) is:
      which python3
      /opt/homebrew/bin/python3
      Ross@Kepler-2 ~ % python3 --version
      Python 3.9.9
      From x86_64 terminal-rosetta2.app
      which python
      /usr/bin/python
      Ross@Kepler-2 ~ % python3 --version
      Python 3.9.9

      I have a 1st native “terminal.app”, uname -m arm64. Homebrew is installed in /opt/homebrew & there is text in the PATH environment to this folder. This is the default, per this response to 'brew config" from the Native arm64 and Rosetta x86_64 terminal.
      From arm64 terminal.app
      Ross@Kepler-2 ~ % brew doctor
      Your system is ready to brew.
      Ross@Kepler-2 ~ % brew config
      HOMEBREW_VERSION: 3.3.9
      ORIGIN: https://github.com/Homebrew/brew
      HEAD: 96137bc19e68398ebbb7033379df288cd8b9a3f9
      Last commit: 4 weeks ago
      Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
      Core tap HEAD: 551bdc22ddc5695e9db3e7a59c30b4dba83fc904
      Core tap last commit: 23 hours ago
      Core tap branch: master
      HOMEBREW_PREFIX: /opt/homebrew
      HOMEBREW_CASK_OPTS: []
      HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
      HOMEBREW_MAKE_JOBS: 8
      Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
      CPU: octa-core 64-bit arm_firestorm_icestorm
      Clang: 13.0.0 build 1300
      Git: 2.32.0 => /Library/Developer/CommandLineTools/usr/bin/git
      Curl: 7.77.0 => /usr/bin/curl
      macOS: 12.1-arm64
      CLT: 13.2.0.0.1.1638488800
      Xcode: 13.2.1
      Rosetta 2: false

      From x86_64 terminal-rosetta2.app
      Ross@Kepler-2 ~ % brew config
      HOMEBREW_VERSION: 3.3.10
      ORIGIN: https://github.com/Homebrew/brew
      HEAD: 385892f3d27dcab0f5a1cb47c3927d9d65ed007c
      Last commit: 33 hours ago
      Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
      Core tap HEAD: aa2f643fd4215653c61d968ca54ff5c56b6f3da6
      Core tap last commit: 20 hours ago
      Core tap branch: master
      HOMEBREW_PREFIX: /opt/homebrew
      HOMEBREW_REPOSITORY: /opt/homebrew
      HOMEBREW_CELLAR: /opt/homebrew/Cellar
      HOMEBREW_CASK_OPTS: []
      HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
      HOMEBREW_MAKE_JOBS: 8
      Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
      CPU: octa-core 64-bit westmere
      Clang: 13.0.0 build 1300
      Git: 2.34.1 => /opt/homebrew/bin/git
      Curl: 7.77.0 => /usr/bin/curl
      macOS: 12.1-x86_64
      CLT: 13.2.0.0.1.1638488800
      Xcode: 13.2.1
      Rosetta 2: true
      Ross@Kepler-2 ~ % uname -m
      x86_64

      The 2nd terminal-rosetta.app was configured enabled for Rosetta2, as described by your Brandon Dec 20 note “69-depthai-apple-m1-based-macs”. uname -m x86_64. There is a 2nd homebrew installed in the pre-M1 folder /use/local/homebrew This text is not in the PATH. I ran the python3 -m install_requirements.py from this Rosetta2 enabled terminal, with the earlier posted result. The system seems to want to run the arm64 version of Homebrew Python to build your depth wheels, even while using the x86_64 terminal, probably because of the PATH text , with the resulting errors. Is there a way to force the system to stay with the x86_64 terminal Homebrew for running python3 ?

      So since the Mac M1 has been out for over a year now and presumably Homebrew has matured, can you release a native arm64 depthai wheel? I’d rather not potentially break my current Homebrew jury rigging the x86_64 Rosetta2 terminal. I note there are other Data Scientist packages in arm64 Homebrew , such as numpy, scipy.
      Regards
      RobotRoss

      7 days later

      To all users of M1 Mac that would like to use DepthAI, I recommend you to build a VM with Ubuntu ARM. My OAK-D works like a charm on it!

      Yes, I can confirm the same success with a Ubuntu 20.04 VM on my Mac M1 and that the scripts run fast. As described for a Linux installation, must enable the udev rule. I will look forward, though for release of a native MAC arm64 Homebrew wheel installation. I’ve also installed the depthai on a Jetson Nano B01 Ubuntu 18.04 and Raspberry Pi 4/4G Raspi OS Buster 32 bit arm7.( though the compile takes 35 mins)

      • erik replied to this.

        Hello RobotRoss , looking at piwheels, we should have 2.13.2 pre-built wheels for arm6/arm7 (python 3.7/3.9), as on the img below.

        Thanks, Erik

        7 days later

        Hi everyone!!
        Yesterday I received my flaming new OAK-D Lite, and after 30 minutes my experience is not that D-Litefull ;-). And I haven't even plugged it in 😅 . I've followed Brandon instructions and copied a Terminal app on the desktop, selected Open using Rosetta, checked that the uname -m was X84_64, and still get the following error (exactly the same I had before re-creating the "Rosetta Terminal"):

        Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
        To rerun under ARM use:
        arch -arm64 brew install ...
        To install under x86_64, install Homebrew into /usr/local.

        I have checked that there is a Homebrew folder in /usr/local, but I guess the code is using the native Homebrew installation. Any ideas or suggestions


        EDIT:
        I have fixed this with:
        export PATH=/usr/local/Homebrew/bin:$PATH
        in case it helps someone.

        If the Terminal is enabled for x86_64 ("Use with Rosetta" box checked" and there is NO previous Homebrew installed in the native arm64 Mac, this may work. The problem I had was that I had apreviously installed Homebrew which goes into /opt/homebrew space and sets "HOMEBREW_PREFIX: /opt/homebrew " and matching "PATH" locations. This apparently confuses the depthai installation scripts which installs another homebrew stack in "/usr/local/homebrew" space but does not completely configure the default paths . Execute "% brew config" to see your default path settings. While I have NOT yet followed these instructions, check out the #macos for posts by whab which uses a virtual environment: https://discord.com/channels/790680891252932659/924798973519216651/934391777811636294 .

        a month later

        This is not the answer.. compile the wheel for the M1 is the solution:

        whab — 01/22/2022
        For those struggling with running DepthAI natively on their M1 computers, here are step-by-step instructions to build, install and test a M1 native version of DepthAI in less than 30 minutes (tested on a new MacBookPro M1 Pro running macOS Monterey 12.1 with a OAK-D-Lite):

        # Install native M1 version of brew
        /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
        echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
        eval "$(/opt/homebrew/bin/brew shellenv)"
        
        # Install conda to create virtual environments for Python
        brew install --cask miniconda
        conda init zsh
        Close and re-open a Terminal window
        
        # Install DepthAI by building a M1 wheel (inside ~/DepthAI/)
        conda create --name DepthAIEnv39 python=3.9
        conda activate DepthAIEnv39
        python3 -m pip install -U pip
        brew update
        brew install cmake libusb
        cd ~; mkdir DepthAI; cd DepthAI
        git clone --recursive  https://github.com/luxonis/depthai-python.git
        cd depthai-python
        mkdir build && cd build
        cmake ..
        cmake --build . --parallel
        cd ..
        python3 -m pip wheel . -w wheelhouse
        pip install wheelhouse/depthai-*
        
        # Test DepthAI with a OAK plugged to your new M1 Mac
        cd examples
        nano install_requirements.py
            Remove code of block (3 lines) starting with: if thisPlatform == "arm64" and platform.system() == "Darwin":
            Remove code of block (48 lines) starting with: if not args.skip_depthai:
        python3 install_requirements.py
        python3 ColorCamera/rgb_preview.py

        Enjoy!

        7 days later

        Hi! Thanks for the code! I'm, new to my M1 mac and macOS and I'm having some problems when I run this part
        cmake ..
        I get this error
        CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
        CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

        I've tried these solutions from stackoverflow , but they haven't helped

        sudo xcode-select --reset
        from [1]https://stackoverflow.com/questions/41380900/cmake-error-no-cmake-c-compiler-could-be-found-using-xcode-and-glfw

        export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
        xcode-select -p
        and selecting the path that I get from there
        sudo xcode-select -s /Library/Developer/CommandLineTools
        from [2]https://stackoverflow.com/questions/65276102/compilation-errors-with-m1-macbook-pro-and-cmake

        a month later

        Thanks for writing the install steps. I ran into the following error while running the cmake ..
        The depthai-core/CMakeLists.txt and depthai-core/shared directory didn't get created.
        Can you suggest a solution? Thank you.

        CMake Error at depthai-core/shared/depthai-shared.cmake:38 (string):
        string sub-command SUBSTRING requires four arguments.
        Call Stack (most recent call first):
        depthai-core/CMakeLists.txt:150 (include)

        CMake Error at depthai-core/shared/depthai-shared.cmake:39 (if):
        if given arguments:

        "STREQUAL" "-"

        Unknown arguments specified
        Call Stack (most recent call first):
        depthai-core/CMakeLists.txt:150 (include)

        Here are the contents of the error log:

        Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
        Compiler: /Library/Developer/CommandLineTools/usr/bin/cc
        Build flags:
        Id flags:

        The output was:
        1
        ld: library not found for -lSystem
        clang: error: linker command failed with exit code 1 (use -v to see invocation)

        Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
        Compiler: /Library/Developer/CommandLineTools/usr/bin/c++
        Build flags:
        Id flags:

        The output was:
        1
        ld: library not found for -lc++
        clang: error: linker command failed with exit code 1 (use -v to see invocation)

        still no further progress in new M1 chips?I mean native.-_-.

        • erik replied to this.

          Hello weiYao ,
          M1 runners aren't yet supported by Github, that's why we haven't yet added support for native M1, more info here. As soon as that comes out we will also add support for M1 on depthai.
          Thank you for understanding, Erik

          2 months later

          I am trying to migrate from a working DepthAI/OAK-D on an older (X86-based) MacBook to a new (M1 Max-based) MacBook. Using the standard (and naive, in retrospect) migration approach left me with nothing working, due to several issues, including Python locations and versions, non-functional Homebrew, etc. I think I've got all issues resolved, except for the lack of M1 native DepthAI. Based on this discussion thread and the DepthAI documentation, I seem to have 3 options I can: (1) run the X86 DepthAI using Rosetta; (2) build the M1 native wheels; (3) wait for Luxonis to produce the M1 native wheels.

          My needs are currently not urgent; I'm not wild about Rosetta dependencies; from the thread it seems that with my level of system skills I'd never succeed at building M1 native wheels. That leaves waiting for Luxonis to produce the M1 native wheels. Is there an estimate of when that might happen? Thanks!

          Brandon This sounds exciting! That said, I don't fully understand. The GitHub link appears to suggest that M1-specific (not universal) wheels will get produced; that I think works for me. I'm unsure what you statement "This is not going to be automatically built" means. Does it refer to some Github restriction?

          Assuming the wheels do become available somehow, can you estimate when the relevant documentation will get updated? Thanks.

          • erik replied to this.

            Yes it means that M1 will just install w/out having any other work. Will be equivalent to x86 Mac, or x86 Linux and/or all the standard builds we have now.

            So this should be fully out this week when we do another release with this system.