Skip to content

Commit

Permalink
Use n150 for Docker CI image.
Browse files Browse the repository at this point in the history
  • Loading branch information
uazizTT committed Oct 29, 2024
2 parents 46675ae + 9aec852 commit d6cb7d5
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && apt-get install -y \
software-properties-common \
build-essential \
python3-dev \
python3-venv \
python3-pip \
git \
git-lfs \
libhwloc-dev \
pandoc \
libtbb-dev \
libcapstone-dev \
pkg-config \
linux-tools-generic \
ninja-build \
wget \
libgtest-dev \
cmake \
ccache \
doxygen \
graphviz \
patchelf \
libyaml-cpp-dev \
libboost-all-dev

# Install clang 17
RUN wget https://apt.llvm.org/llvm.sh && \
chmod u+x llvm.sh && \
./llvm.sh 17 && \
apt install -y libc++-17-dev libc++abi-17-dev && \
ln -s /usr/bin/clang-17 /usr/bin/clang && \
ln -s /usr/bin/clang++-17 /usr/bin/clang++

# Install python packages
RUN pip install cmake

# Install Googletest
RUN git clone https://github.com/google/googletest.git -b release-1.12.1 && \
cd googletest && \
mkdir build && \
cd build && \
cmake .. -DBUILD_GMOCK=OFF && \
make && \
make install && \
cd ../.. && \
rm -rf googletest
37 changes: 37 additions & 0 deletions .github/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ARG GIT_SHA
ARG FROM_TAG=${GIT_SHA:-latest}

FROM ghcr.io/tenstorrent/tt-torch/tt-torch-base-ubuntu-22-04:${FROM_TAG} AS ci-build
SHELL ["/bin/bash", "-c"]

# Create a directory for the build and toolchain
ARG GIT_SHA
ENV PROJECT_NAME=tt-torch
ENV BUILD_DIR=/home/build
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain

RUN echo "Building $PROJECT_NAME at $GIT_SHA"

RUN mkdir -p $BUILD_DIR && \
mkdir -p $TTMLIR_TOOLCHAIN_DIR

# Copy the project from host, cloned in build-image.yml
COPY . $BUILD_DIR/$PROJECT_NAME

# Build the toolchain
WORKDIR $BUILD_DIR/$PROJECT_NAME
RUN cmake -B toolchain -DTOOLCHAIN=ON third_party/ && \
cd third_party/tt-mlir/src/tt-mlir/ && \
source env/activate && \
cmake -B env/build env && \
cmake --build env/build

# Final stage
FROM ghcr.io/tenstorrent/tt-torch/tt-torch-base-ubuntu-22-04:${FROM_TAG} AS ci

# Copy the TTMLIR_TOOLCHAIN_DIR from the previous stage
ENV TTMLIR_TOOLCHAIN_DIR=/opt/ttmlir-toolchain
RUN echo "Copying from ci-build stage $TTMLIR_TOOLCHAIN_DIR"
COPY --from=ci-build $TTMLIR_TOOLCHAIN_DIR $TTMLIR_TOOLCHAIN_DIR

RUN du -h --max-depth=2 $TTMLIR_TOOLCHAIN_DIR
144 changes: 144 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Build and Test

on:
workflow_dispatch:
workflow_call:
pull_request:
branches: [ "main" ]

jobs:
# build-ttxla:

# timeout-minutes: 120
# strategy:
# fail-fast: false

# name: Build and test tt-torch
# runs-on: n150

# container:
# image: ghcr.io/tenstorrent/tt-mlir/tt-mlir-ci-ubuntu-22-04:latest #TODO update this to the correct image
# options: --user root

# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# lfs: true

# - name: Set reusable strings
# id: strings
# shell: bash
# run: |
# echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
# echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
# echo "metal-lib-dir=$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib" >> "$GITHUB_OUTPUT"
# echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"

# - name: Git safe dir
# run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}


# # Build project

# - name: Configure CMake
# shell: bash
# run: |
# source venv/activate
# cmake -G Ninja \
# -B ${{ steps.strings.outputs.build-output-dir }} \
# -S ${{ steps.strings.outputs.work-dir }}

# - name: Build
# shell: bash
# run: |
# source venv/activate
# cmake --build ${{ steps.strings.outputs.build-output-dir }}
# cmake --install ${{ steps.strings.outputs.build-output-dir }}


# # This is needed to preserve file permissions
# # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
# - name: 'Tar install directory and metal lib directory'
# shell: bash
# working-directory: ${{ steps.strings.outputs.install-output-dir }}
# run: |
# tar cvf artifact.tar .

# - name: Upload install folder to archive
# uses: actions/upload-artifact@v4
# with:
# name: install-artifacts
# path: ${{ steps.strings.outputs.build-output-dir }}/artifact.tar

# - name: Get the latest tag
# shell: bash
# run: |
# latest_tag=$(git describe --tags --abbrev=0)
# latest_tag=${latest_tag#v}
# echo "latest_tag=$latest_tag" >> $GITHUB_ENV
# commit_count=$(git rev-list ${{ env.latest_tag }}..HEAD --count)
# echo "commit_count=$commit_count" >> $GITHUB_ENV
# version="${{ env.latest_tag }}.${{ env.commit_count }}"
# echo "version=$version" >> $GITHUB_ENV
# echo $version


# # Run tests on TT hardware

build-and-run-tests:
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
build: [
{runs-on: n150, name: "run"},
# {runs-on: n300, name: "run"}, #TODO: https://github.com/tenstorrent/tt-xla/issues/9
]

runs-on:
- n150

container:
image: ghcr.io/tenstorrent/tt-mlir/tt-mlir-ci-ubuntu-22-04:latest
options: --user root --device /dev/tenstorrent/0
volumes:
- /dev/hugepages:/dev/hugepages
- /dev/hugepages-1G:/dev/hugepages-1G
- /etc/udev/rules.d:/etc/udev/rules.d
- /lib/modules:/lib/modules
- /opt/tt_metal_infra/provisioning/provisioning_env:/opt/tt_metal_infra/provisioning/provisioning_env

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: true

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
# Build project
- name: Configure CMake
shell: bash
run: |
source venv/activate
cmake -G Ninja \
-B ${{ steps.strings.outputs.build-output-dir }} \
-S ${{ steps.strings.outputs.work-dir }}
- name: Build
shell: bash
run: |
source venv/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }}
cmake --install ${{ steps.strings.outputs.build-output-dir }}
- name: Run tests
shell: bash
run: |
export LD_LIBRARY_PATH="/opt/ttmlir-toolchain/lib/:${{ steps.strings.outputs.install-output-dir }}/lib:${LD_LIBRARY_PATH}"
source venv/activate
pytest -v tests/
78 changes: 78 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

name: Build and Publish Docker Image

on:
workflow_dispatch:
workflow_call:

jobs:
build:

runs-on:
- n150

env:
BASE_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-torch-base-ubuntu-22-04
CI_IMAGE_NAME: ghcr.io/${{ github.repository }}/tt-torch-ci-ubuntu-22-04

steps:

- name: Fix permissions
run: sudo chmod 777 -R $GITHUB_WORKSPACE

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
lfs: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build images

- name: Build and export base Docker image
uses: docker/build-push-action@v6
with:
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:${{ github.sha }}
- name: Build and export CI Docker image
uses: docker/build-push-action@v6
with:
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:${{ github.sha }}
# Tag images as latest

- name: Build and push base Docker image
uses: docker/build-push-action@v6
with:
file: .github/Dockerfile.base
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.BASE_IMAGE_NAME}}:latest
- name: Build and push CI Docker image
uses: docker/build-push-action@v6
with:
file: .github/Dockerfile.ci
push: true
build-args: |
GIT_SHA=${{ github.sha }}
tags: |
${{ env.CI_IMAGE_NAME}}:latest

0 comments on commit d6cb7d5

Please sign in to comment.