Why does MLIR need a lot of RAM to compile? Can I somehow get MLIR binaries on my laptop?

Title says it all - I am unable to compile MLIR on my laptop with 4GB RAM (it crashes during the final stages of linking by ninja), yet can do so on my 64GB RAM machine.

If I can’t build it - any ideas how I can circumvent this to have MLIR binaries on my laptop?

There are several ways to save memories during linking:

  1. Use gold or LLD as the linker. More specifically, adding the -DLLVM_USE_LINKER=gold/lld cmake argument.
  2. Use the -DLLVM_PARALLEL_LINK_JOBS=<N> to limit the number of threads during linking.
  3. Building LLVM/MLIR as shared libraries can also save some memories (and speed up the build). Please use -DBUILD_SHARED_LIBS=ON.
4 Likes

@mshockwave gave you all the good tips to do to reduce memory consumption!
I’ll add one extra important point: disable debug info. I always build with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON on a day-to-day basis.

2 Likes

Okay will try them - thank you all!