From 661fa601ee3c51700eccac6f5b16388a3cda6bb9 Mon Sep 17 00:00:00 2001 From: Kevin O'Brien Date: Tue, 19 May 2020 15:48:47 -0400 Subject: [PATCH] add Github workflow to build the prereq Docker image for TravisCI build (#137) * Create build-docker-prereq.ym * Rename build-docker-prereq.ym to build-docker-prereq.yml * Create prereq.Dockerfile * Update build-docker-prereq.yml * Update clone-mlir.sh * Update build-docker-prereq.yml * Update clone-mlir.sh * Update build-docker-prereq.yml * Update clone-mlir.sh * Update prereq.Dockerfile * Update clone-mlir.sh * Update prereq.Dockerfile * Update clone-mlir.sh * Update build-docker-prereq.yml * Update prereq.Dockerfile * Update clone-mlir.sh * Update build-docker-prereq.yml * Update clone-mlir.sh * Update Dockerfile * Update .travis.yml * Update .travis.yml * Update Dockerfile * Update Dockerfile * Update build-docker-prereq.yml * Update Dockerfile * Update prereq.Dockerfile * Update clone-mlir.sh * Update build-docker-prereq.yml * Update .travis.yml Co-authored-by: Gheorghe-Teodor Bercea --- .github/workflows/build-docker-prereq.yml | 28 +++++++++++++++ .github/workflows/prereq.Dockerfile | 43 +++++++++++++++++++++++ docker/Dockerfile | 5 +-- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-docker-prereq.yml create mode 100644 .github/workflows/prereq.Dockerfile diff --git a/.github/workflows/build-docker-prereq.yml b/.github/workflows/build-docker-prereq.yml new file mode 100644 index 0000000..ebec22c --- /dev/null +++ b/.github/workflows/build-docker-prereq.yml @@ -0,0 +1,28 @@ +# This workflow will run whenever there is a change to the version of LLVM the project is based on +# It will create a new Docker image for the TravisCI build and push it to Docker Hub +# This image contains the prereqs for building onnx-mlir including a precompiled copy of the appropriate +# LLVM and MLIR code. + +name: Build Docker Prereq Image + +# Run this workflow when there is a change to clone-mlir.sh (that implies a new version of LLVM is being used) +on: + push: + paths: + - 'utils/clone-mlir.sh' + +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: build image + run: | + docker build --tag onnxmlirczar/onnx-mlir-llvmimage:initial -f $GITHUB_WORKSPACE/.github/workflows/prereq.Dockerfile $GITHUB_WORKSPACE/utils + docker login -u onnxmlirczar -p 143f1da2-332f-45a1-8587-d6cb07c13230 + docker push onnxmlirczar/onnx-mlir-llvmimage:initial diff --git a/.github/workflows/prereq.Dockerfile b/.github/workflows/prereq.Dockerfile new file mode 100644 index 0000000..5b184ad --- /dev/null +++ b/.github/workflows/prereq.Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:focal + +WORKDIR /build + +# install stuff that is needed for compiling LLVM, MLIR and ONNX +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y git cmake ninja-build libprotobuf-dev protobuf-compiler +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update && \ + apt-get -y install \ + make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ + libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \ + libffi-dev liblzma-dev +RUN git clone git://github.com/yyuu/pyenv.git .pyenv +RUN git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv + +ENV HOME=/build +ENV PYENV_ROOT=$HOME/.pyenv +ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH + +RUN pyenv install 3.7.0 + +RUN pyenv global 3.7.0 +RUN pyenv rehash + +# first install MLIR in llvm-project +RUN mkdir bin +ENV PATH=$PATH:/build/bin +COPY clone-mlir.sh bin/clone-mlir.sh +RUN chmod a+x bin/clone-mlir.sh +RUN clone-mlir.sh + +WORKDIR /build/llvm-project/build +RUN cmake -G Ninja ../llvm \ + -DLLVM_ENABLE_PROJECTS=mlir \ + -DLLVM_BUILD_EXAMPLES=ON \ + -DLLVM_TARGETS_TO_BUILD="host" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_ENABLE_RTTI=ON + +RUN cmake --build . --target -- ${MAKEFLAGS} +RUN cmake --build . --target check-mlir diff --git a/docker/Dockerfile b/docker/Dockerfile index aa0ec97..6768776 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,7 @@ -FROM caoimhinuibrian/onnx-mlir-llvmimage:initial +# Grab pre-built LLVM from github packages +FROM onnxmlirczar/onnx-mlir-llvmimage:initial +WORKDIR /build/bin WORKDIR /build ENV HOME=/build ENV PYENV_ROOT=$HOME/.pyenv @@ -7,7 +9,6 @@ ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH RUN pyenv global 3.7.0 RUN pyenv rehash -RUN mkdir bin ENV PATH=$PATH:/build/bin RUN git clone --recursive https://github.com/onnx/onnx-mlir.git COPY compile-onnx-mlir.sh bin/compile-onnx-mlir.sh