Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Triton on MacOS with Apple silicon. #3443

Closed
fkouteib opened this issue Mar 23, 2024 · 2 comments
Closed

Build Triton on MacOS with Apple silicon. #3443

fkouteib opened this issue Mar 23, 2024 · 2 comments

Comments

@fkouteib
Copy link
Contributor

I attempted to build triton wheel for macOS on a MacBook with M2 Max chip and the build fails.

Local config: M2 Max, macOS 14.4, Python 3.12.2, with all the project-specific python library dependencies installed.

The error I ran into is

$HOME/.triton/llvm/llvm-4017f04e-macos-arm64/lib/libMLIRTransforms.a'
ld: library 'LLVMX86CodeGen' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I root caused the issue to the cmake config where 'CMAKE_SYSTEM_PROCESSOR' is used to decide whether to take dependency on x86 or aarch64 variants of LLVM library dependencies. Linux and MacOS use different strings for identifying their ARM processor/isa, "aarch64" and "arm64" respectively. So the macOS build currently fails that check, selects the x86 libraries then later fails to find them in the downloaded LLVM libraries bundle.

The fix is to expand the cmake check to account for both. I will submit a PR for it shortly.

With this change, I am able to successfully compile and install triton on my Mac. It passed the ninja and lit unit tests outlined in readme file. I tried to run some of the core unit tests and tutorials, and they asserted (as expected) on either PyTorch not compiled for CUDA, or number of active GPU drivers is not 1. As a sanity check, I spun up an ubuntu container instance on my Mac and successfully compiled for aarch64, installed, and passed the ninja/lit unit tests.

Lastly, I am aware that macOS isn't a supported platform and neither are Apple silicon GPUs at this time. So even getting a working build doesn't unlock all the supported capabilities of the language and compiler. But I wanted to have some native local triton support to the hardware-agnostic aspects as I experiment with and learn Triton.

fkouteib added a commit to fkouteib/triton that referenced this issue Mar 23, 2024
Linux and macOS use different processor/ISA string identifiers for their ARM64 variants. So the macOS build was falling thru in cmake config, then later trying to link against x86 libraries and failing to find them in the LLVM librarries bundle for macOS-ARM.
@fkouteib fkouteib changed the title Build fails on MacOS with Apple silicon. Build Triton on MacOS with Apple silicon. Mar 23, 2024
Jokeren pushed a commit that referenced this issue Mar 23, 2024
Linux and macOS use different processor/ISA string identifiers for their
ARM64 variants. So the macOS build was falling thru in cmake config,
then later trying to link against x86 libraries and failing to find them
in the LLVM libraries bundle for macOS-ARM.
karupayun pushed a commit to openxla/triton that referenced this issue Apr 3, 2024
…riton-lang#3444)

Linux and macOS use different processor/ISA string identifiers for their
ARM64 variants. So the macOS build was falling thru in cmake config,
then later trying to link against x86 libraries and failing to find them
in the LLVM libraries bundle for macOS-ARM.
@alimaslax
Copy link

alimaslax commented Apr 28, 2024

I can confirm. This fixed my ninja build

ninja: build stopped: subcommand failed.

  Traceback (most recent call last):
    File "/private/var/folders/jq/6fddylx16811mcdw6lsbg24w0000gp/T/pip-build-env-fbuwe8sm/overlay/lib/python3.9/site-packages/setuptools/command/editable_wheel.py", line 155, in run
      self._create_wheel_file(bdist_wheel)

After pulling in the latest main, I am able to build with ninja.

`Successfully built triton llnl-hatchet

Installing collected packages: Arpeggio, pydot, importlib-metadata, caliper-reader, textX, llnl-hatchet, triton
Successfully installed Arpeggio-2.0.2 caliper-reader-0.4.0 importlib-metadata-7.1.0 llnl-hatchet-2024.1.1 pydot-2.0.0 textX-4.0.1 triton-3.0.0
WARNING: You are using pip version 22.0.4; however, version 24.0 is available.
You should consider upgrading via the '/Users/mali/.pyenv/versions/3.9.16/bin/python3.9 -m pip install --upgrade pip' command.`

@BuildBackBuehler
Copy link

Maybe this doesn't need a triple check but getting these essential packages that have eluded the Mac Metal plat. always excites me! 🤓 🚀

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants