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

Enabling ccache on github builds for Ubuntu #95

Merged
merged 51 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
18f4e30
CI Changes to add tiny regression tests
Apr 8, 2021
f8cf554
Adding an inspect cache step
Apr 9, 2021
6771e4c
Merge branch 'main' into jp/brt-ghci
Apr 9, 2021
ddfb2d5
Removing ccache, pursue in another
Apr 9, 2021
e6b0263
Incorporating Nick's changes through submodule merge
Apr 9, 2021
9b1cdc1
Submodule now points to master
Apr 9, 2021
6fc3207
Restoring ccache enabled workflow file
Apr 9, 2021
5948707
Restoring ccache enabled CMakeLists
Apr 9, 2021
4135d5a
cache -> ccache typo fix
Apr 9, 2021
cd397b8
Moving CCACHE setup to GitHub runner file
Apr 9, 2021
6caa7f2
Find also uses CCACHE dir
Apr 9, 2021
bdc9c52
Updating CMakeLists not to override env
Apr 9, 2021
50d944f
Cache compiler binary's contents
Apr 9, 2021
fe77f9f
Changing a few names to trigger new build; Testing cache looks fun
Apr 9, 2021
aace7bc
Merge branch 'main' into jp/brt-ghci-ccache
May 8, 2021
5c29413
USE_CCACHE=on, -L for inspection
May 8, 2021
cba3257
Adding a ccache_cmd, but will only use in next commit
May 8, 2021
91c8e80
Using ccache_cmd
May 8, 2021
e5b38fb
Removing "
May 9, 2021
5544504
Adding compiler hash script
May 9, 2021
99769e5
Bunch of absolute paths
May 9, 2021
f00ee04
GITHUB_WORKSPACE typo
May 9, 2021
1e5a536
Nah, I'll keep -L and trigger another build
May 9, 2021
759d2c2
Trying something with compiler hash on cache key backup as well
May 9, 2021
6c86e76
builtin, bash it seems
May 9, 2021
47289e0
Empty commit #1
May 9, 2021
f42d04b
Move ccache stats to after compile
May 9, 2021
9fc6836
Reshuffling ccache vars
May 9, 2021
19c71c7
No comments
May 9, 2021
eb9b1df
Updates to Github output set syntax
May 9, 2021
8e6375e
Empty Commit 1
May 9, 2021
54fd63a
Empty Commit 2
May 9, 2021
a8bdbc5
Empty commit 3
May 9, 2021
e9d6faa
Merge branch 'main' into jp/brt-ghci-ccache
May 9, 2021
c9398eb
Merge branch 'main' into jp/brt-ghci-ccache
May 10, 2021
a0d0701
/bin/bash -> bash; ccache_cmd for consistency
May 11, 2021
dd6c378
Adding ccache -s before and after build
May 11, 2021
6aa6005
Merge branch 'jp/brt-ghci-ccache' of github.com:browsermt/bergamot-tr…
May 11, 2021
3b8205d
Adding comments to compiler-hash script
May 11, 2021
06ac142
Let's build cached and non-cached variants together for comparison
May 11, 2021
ed93ebe
Fixing quotes, /bin/bash -> bash
May 11, 2021
c906014
Minor var/env adjustment
May 11, 2021
03f8b1f
Adding ccache -z before the job
May 11, 2021
c96cca4
Merge branch 'main' into jp/brt-ghci-ccache
May 12, 2021
697b979
Merge branch 'main' into jp/brt-ghci-ccache
May 12, 2021
a33e136
Reverting CMakeLists.txt without CCACHE
May 13, 2021
2f99e93
Switching to CMAKE_LANG_COMPILER_LAUNCHER instead of CMakeLists.txt rule
May 13, 2021
55d27a7
Merge branch 'jp/brt-ghci-ccache' of github.com:browsermt/bergamot-tr…
May 13, 2021
decee0c
Merge branch 'main' into jp/brt-ghci-ccache
May 13, 2021
8e0cf60
5G -> 1G cache size
May 13, 2021
aabfe1f
1G -> 2G; Hyperparameter tuning
May 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 105 additions & 48 deletions .github/workflows/native-full_marian-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,21 @@ name: Native (Full Marian) Ubuntu

on:
push:
branches: [ main, ci-test ]
branches: [ main, ci-sandbox ]
pull_request:
branches: [ main, ci-test ]
branches: [ main, ci-sandbox ]

jobs:
build-ubuntu:
strategy:
matrix:
include:
# Ubuntu CPU-only build
- name: "Ubuntu CPU-only"
os: ubuntu-latest
cuda: ""
gcc: 8
cpu: true
gpu: false
# GPU Builds are commented out, for bergamot-translator CI runs.
# Ubuntu GPU-only build
# - name: "Ubuntu GPU-only"
# os: ubuntu-latest
# cuda: "10.2"
# gcc: 7
# cpu: false
# gpu: true
# Ubuntu 20.04 supports CUDA 11+
#- name: "Ubuntu 20.04 CUDA 11.0 gcc-9"
#os: ubuntu-20.04
#cuda: "11.0"
#gcc: 9
#cpu: false
#gpu: true
# Ubuntu 18.04 supports CUDA 10.1+
# - name: "Ubuntu 18.04 CUDA 10.2 gcc-8"
# os: ubuntu-18.04
# cuda: "10.2"
# gcc: 8
# cpu: true
# gpu: true
# Ubuntu 16.04 supports CUDA 8+
# - name: "Ubuntu 16.04 CUDA 9.2 gcc-7"
# os: ubuntu-16.04
# cuda: "9.2"
# gcc: 7
# cpu: true
# gpu: true
cpu: 'ON'
gpu: 'OFF'

runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
Expand All @@ -62,7 +32,11 @@ jobs:
# No need to install libprotobuf{17,10,9v5} on Ubuntu {20,18,16}.04 because
# it is installed together with libprotobuf-dev
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libgoogle-perftools-dev libprotobuf-dev protobuf-compiler libboost-all-dev g++-8
run: |
sudo apt-get update
sudo apt-get install -y \
libgoogle-perftools-dev libprotobuf-dev protobuf-compiler \
libboost-all-dev g++-${{ matrix.gcc }} ccache

# https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
- name: Install MKL
Expand All @@ -71,12 +45,39 @@ jobs:
sudo sh -c "echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list"
sudo apt-get update -o Dir::Etc::sourcelist="/etc/apt/sources.list.d/intel-mkl.list"
sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
if: matrix.cpu == true
if: matrix.cpu == 'ON'

# The script simplifies installation of different versions of CUDA
- name: Install CUDA
run: ./3rd_party/marian-dev/scripts/ci/install_cuda_ubuntu.sh ${{ matrix.cuda }}
if: matrix.gpu == true
if: matrix.gpu == 'ON'

# Lifted from https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")

- name: Setup ccache environment variables
run: |
# Hash compiler content, mtime + size is modded everytime, so.
echo "CCACHE_COMPILERCHECK=content" >> $GITHUB_ENV
echo "CCACHE_BASE_DIR=${{ github.workspace }}" >> $GITHUB_ENV
echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=true" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=6" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=2G" >> $GITHUB_ENV

- name: Cache-op for build-cache through ccache
uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
jerinphilip marked this conversation as resolved.
Show resolved Hide resolved
restore-keys: |
${{ matrix.name }}-ccache-


# Boost is installed on GitHub-hosted runners in a non-standard location
# https://github.com/actions/virtual-environments/issues/687#issuecomment-610471671
Expand All @@ -87,34 +88,90 @@ jobs:
CC=/usr/bin/gcc-${{ matrix.gcc }} CXX=/usr/bin/g++-${{ matrix.gcc }} CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} \
cmake .. \
-DBoost_ARCHITECTURE=-x64 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=Slim \
-DUSE_CCACHE=on \
-DCOMPILE_CPU=${{ matrix.cpu }} \
-DCOMPILE_CUDA=${{ matrix.gpu }} \
-DCOMPILE_EXAMPLES=on \
-DCOMPILE_SERVER=on \
-DCOMPILE_EXAMPLES=off \
-DCOMPILE_SERVER=off \
-DCOMPILE_TESTS=on \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-${{ matrix.cuda }} \
-DUSE_FBGEMM=${{ matrix.cpu }} \
-DUSE_SENTENCEPIECE=on \
-DUSE_STATIC_LIBS=on \
-DUSE_WASM_COMPATIBLE_SOURCE=off

- name: Compile
- name: Compile bergamot-translator
working-directory: build
run: make -j2

- name: Run unit tests
working-directory: build
run: make test
# GitHub-hosted VMs do not have GPUs, so can not be run in CUDA builds
if: matrix.gpu == false
if: matrix.gpu == 'OFF'

- name: Print versions
working-directory: build
run: |
./marian --version
./marian-decoder --version
./marian-scorer --version
./marian-server --version
./spm_encode --version
./app/marian-decoder-new --version

- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: bergamot-translator-artifacts
path: |
./build/app/service-cli*
./build/app/bergamot-translator-app*
./build/app/marian-decoder-new

regression-tests:
strategy:
matrix:
include:
- name: "Regression Tests"
os: ubuntu-latest
cuda: ""
gcc: 8
cpu: 'ON'
gpu: 'OFF'

needs: build-ubuntu
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Download bergamot-translator-build artifacts
uses: actions/download-artifact@v2
with:
name: bergamot-translator-artifacts
path: build/app/

- name: Set permissions on apps
working-directory: build/app
run: |
chmod +x *
ls -l


- name: Install regression-test framework (BRT)
working-directory: bergamot-translator-tests
run : make install

- name: Run regression-tests (BRT)
working-directory: bergamot-translator-tests
run : MARIAN=../build ./run_brt.sh

- name: Upload regression-tests artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: brt-artifacts
path: |
bergamot-translator-tests/**/*.expected
bergamot-translator-tests/**/*.log
bergamot-translator-tests/**/*.out
4 changes: 2 additions & 2 deletions .github/workflows/wasm-custom_marian-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: WASM (Custom Marian) Ubuntu

on:
push:
branches: [ main ]
branches: [ main, ci-sandbox ]
pull_request:
branches: [ main ]
branches: [ main, ci-sandbox ]

jobs:
build-wasm:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "3rd_party/ssplit-cpp"]
path = 3rd_party/ssplit-cpp
url = https://github.com/browsermt/ssplit-cpp
[submodule "bergamot-translator-tests"]
path = bergamot-translator-tests
url = https://github.com/browsermt/bergamot-translator-tests
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include(CMakeDependentOption)
option(COMPILE_WASM "Compile for WASM" OFF)
option(USE_WASM_COMPATIBLE_SOURCE "Use wasm compatible sources" ON)
option(COMPILE_TESTS "Compile bergamot-tests" OFF)
option(USE_CCACHE "Compile with ccache" OFF)

SET(PACKAGE_DIR "" CACHE STRING "Directory including all the files to be packaged (pre-loaded) in wasm builds")

Expand All @@ -29,6 +30,23 @@ if (USE_WASM_COMPATIBLE_SOURCE)
SET(USE_INTERNAL_PCRE2 ON CACHE BOOL "Use internal PCRE2 instead of system PCRE2")
endif()

# use ccache (https://ccache.dev) for faster compilation if requested and available
jerinphilip marked this conversation as resolved.
Show resolved Hide resolved
if(USE_CCACHE)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Will be using ccache for faster repeat compilation (use cmake -DUSE_CCACHE=off to disable).")

# Configurations so cache size doesn't exceed certain limits on GitHub runners.
if (DEFINED ENV{CCACHE_DIR})
message(STATUS "Setting ccache-dir to $ENV{CCACHE_DIR}")
endif()

set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
else(CCACHE_PROGRAM)
message(WARNING "Compilation with ccache requested but no ccache found.")
endif(CCACHE_PROGRAM)
endif(USE_CCACHE)

# Documentation: https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
# Ensures the submodules are set correctly during a build.
find_package(Git QUIET)
Expand Down
1 change: 1 addition & 0 deletions bergamot-translator-tests