tenstorrent / tt-mlir

Tenstorrent MLIR compiler
https://tenstorrent.github.io/tt-mlir/
Apache License 2.0
51 stars 7 forks source link

Multi-Stage Docker Image Build #481

Closed vmilosevic closed 6 days ago

vmilosevic commented 2 weeks ago

Multi-Stage Docker Image Build and Push to GHCR

Create a GitHub Actions workflow to build and push three Docker images to GitHub Container Registry (GHCR), each building upon the last. This will replace the current docker image build. Docker images are tagged with current commit SHA, and build can be skipped if the image already exists.

Base Image (tt-mlir-base-ubuntu-22.04)

Project Build Image (tt-mlir-ubuntu-22.04)

IRD Image (tt-mlir-ird-ubuntu-22.04)

odjuricicTT commented 2 weeks ago

@vmilosevic Is there an ETA for the IRD image? Some builds don't currently work on the standard ubuntu IRD image and using the base without ssh is quite complicated for development.

vmilosevic commented 1 week ago

There are two docker images:

ghcr.io/tenstorrent/tt-mlir/tt-mlir-ird-ubuntu-22-04:latest and ghcr.io/tenstorrent/tt-mlir/tt-mlir-base-ird-ubuntu-22-04:latest

base-ird contains only build dependencies and is a much lighter image. With it, you need to build the toolchain first. ird contains the prebuilt toolchain and is ready to build the project, but it is much larger and you will need to wait longer for the lab machine to download it.

You can make reservations using these images from the command line.

ird reserve --timeout 1-0 --team bgd --docker-image ghcr.io/tenstorrent/tt-mlir/tt-mlir-base-ird-ubuntu-22-04:latest --machine bgdepyc01

Or, if you are using the VS Code IRD extension, just add them to the Docker list. Set of commands I used to test the base image:

git clone git@github.com:tenstorrent/tt-mlir.git
cd tt-mlir/
export TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain
sudo mkdir -p $TTMLIR_TOOLCHAIN_DIR && sudo chown -R $USER $TTMLIR_TOOLCHAIN_DIR
cmake -B env/build env
cmake --build env/build
source env/activate
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DTTMLIR_ENABLE_RUNTIME=ON -DTTMLIR_ENABLE_RUNTIME_TESTS=ON -DTTMLIR_ENABLE_STABLEHLO=ON
cmake --build build --config Release
cmake --build build -- ttrt
cmake --build build -- check-ttmlir

With the toolchain image, you skip the Toolchain build part. The image still has a few quirks, you will need to change the ownership of the toolchain folder to your user (or 777), and you may need to install vim if you use it as the default git editor. I'll fix that in the next iteration.

git clone git@github.com:tenstorrent/tt-mlir.git
cd tt-mlir/
export TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain
sudo mkdir -p $TTMLIR_TOOLCHAIN_DIR && sudo chown -R $USER $TTMLIR_TOOLCHAIN_DIR
source env/activate
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DTTMLIR_ENABLE_RUNTIME=ON -DTTMLIR_ENABLE_RUNTIME_TESTS=ON -DTTMLIR_ENABLE_STABLEHLO=ON
cmake --build build --config Release
cmake --build build -- ttrt
cmake --build build -- check-ttmlir