From a21e48fb4f0beec0f83987112ff61b23a0140080 Mon Sep 17 00:00:00 2001 From: Roman Grundkiewicz Date: Fri, 21 Aug 2020 18:50:07 +0100 Subject: Add GitHub workflows with CUDA and MKL (#700) * Add GitHub workflows with CUDA * Install MKL on Windows * Upload CPU-only executables from Windows and Ubuntu as artifacts * Clean up workflows --- .github/workflows/build-macos-10.15-cpu.yml | 51 ----------------- .github/workflows/build-ubuntu-18.04-cpu.yml | 64 --------------------- .github/workflows/build-windows-2019-cpu.yml | 49 ---------------- .github/workflows/macos-cpu.yml | 51 +++++++++++++++++ .github/workflows/ubuntu-cpu.yml | 75 +++++++++++++++++++++++++ .github/workflows/ubuntu-gpu.yml | 84 ++++++++++++++++++++++++++++ .github/workflows/windows-cpu.yml | 66 ++++++++++++++++++++++ .github/workflows/windows-gpu.yml | 63 +++++++++++++++++++++ 8 files changed, 339 insertions(+), 164 deletions(-) delete mode 100644 .github/workflows/build-macos-10.15-cpu.yml delete mode 100644 .github/workflows/build-ubuntu-18.04-cpu.yml delete mode 100644 .github/workflows/build-windows-2019-cpu.yml create mode 100644 .github/workflows/macos-cpu.yml create mode 100644 .github/workflows/ubuntu-cpu.yml create mode 100644 .github/workflows/ubuntu-gpu.yml create mode 100644 .github/workflows/windows-cpu.yml create mode 100644 .github/workflows/windows-gpu.yml (limited to '.github') diff --git a/.github/workflows/build-macos-10.15-cpu.yml b/.github/workflows/build-macos-10.15-cpu.yml deleted file mode 100644 index 824915b8..00000000 --- a/.github/workflows/build-macos-10.15-cpu.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: macos-10.5-cpu - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: macos-10.15 - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Install dependencies - run: brew install openblas protobuf - - # Openblas location is exported explicitly because openblas is keg-only, - # which means it was not symlinked into /usr/local/. - # CMake cannot find BLAS on GitHub runners if Marian is being compiled - # statically, hence USE_STATIC_LIBS=off - - name: Configure CMake - run: | - export LDFLAGS="-L/usr/local/opt/openblas/lib" - export CPPFLAGS="-I/usr/local/opt/openblas/include" - mkdir -p build - cd build - cmake .. -DCOMPILE_CPU=on -DCOMPILE_CUDA=off -DCOMPILE_EXAMPLES=on -DCOMPILE_SERVER=on -DCOMPILE_TESTS=on \ - -DUSE_FBGEMM=on -DUSE_SENTENCEPIECE=on -DUSE_STATIC_LIBS=off - - - name: Compile - working-directory: build - run: make -j2 - - - name: Run unit tests - working-directory: build - run: make test - - - name: Print versions - working-directory: build - run: | - ./marian --version - ./marian-decoder --version - ./marian-scorer --version - ./spm_encode --version - diff --git a/.github/workflows/build-ubuntu-18.04-cpu.yml b/.github/workflows/build-ubuntu-18.04-cpu.yml deleted file mode 100644 index 0b37e4f4..00000000 --- a/.github/workflows/build-ubuntu-18.04-cpu.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: ubuntu-18.04-cpu - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - # The following packages are already installed on GitHub-hosted runners: build-essential openssl libssl-dev - - name: Install dependencies - run: sudo apt-get install --no-install-recommends libgoogle-perftools-dev libprotobuf10 libprotobuf-dev protobuf-compiler - - # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html - - name: Install MKL - run: | - wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add - - 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 --no-install-recommends intel-mkl-64bit-2020.0-088 - - - name: Print Boost paths - run: | - ls $BOOST_ROOT_1_69_0 - ls $BOOST_ROOT_1_69_0/include - ls $BOOST_ROOT_1_69_0/lib - - # Boost is already installed on GitHub-hosted runners in a non-standard location - # https://github.com/actions/virtual-environments/issues/687#issuecomment-610471671 - - name: Configure CMake - run: | - mkdir -p build - cd build - cmake .. -DCOMPILE_CPU=on -DCOMPILE_CUDA=off -DCOMPILE_EXAMPLES=on -DCOMPILE_SERVER=on -DCOMPILE_TESTS=on \ - -DUSE_FBGEMM=on -DUSE_SENTENCEPIECE=on \ - -DBOOST_ROOT=$BOOST_ROOT_1_69_0 -DBOOST_INCLUDEDIR=$BOOST_ROOT_1_69_0/include -DBOOST_LIBRARYDIR=$BOOST_ROOT_1_69_0/lib \ - -DBoost_ARCHITECTURE=-x64 - - - name: Compile - working-directory: build - run: make -j2 - - - name: Run unit tests - working-directory: build - run: make test - - - name: Print versions - working-directory: build - run: | - ./marian --version - ./marian-decoder --version - ./marian-scorer --version - ./spm_encode --version - diff --git a/.github/workflows/build-windows-2019-cpu.yml b/.github/workflows/build-windows-2019-cpu.yml deleted file mode 100644 index 13ef6614..00000000 --- a/.github/workflows/build-windows-2019-cpu.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: windows-2019-cpu - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: windows-2019 - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Prepare vcpkg - uses: lukka/run-vcpkg@v3 - with: - vcpkgArguments: protobuf - vcpkgGitCommitId: 6185aa76504a5025f36754324abf307cc776f3da - vcpkgDirectory: ${{ github.workspace }}/vcpkg/ - vcpkgTriplet: x64-windows-static - - # Note that we build with a simplified CMake settings JSON file - - name: Run CMake - uses: lukka/run-cmake@v2 - with: - buildDirectory: ${{ github.workspace }}/build/ - cmakeAppendedArgs: -G Ninja - cmakeListsOrSettingsJson: CMakeSettingsJson - cmakeSettingsJsonPath: ${{ github.workspace }}/CMakeSettingsCI.json - useVcpkgToolchainFile: true - - - name: Run unit tests - working-directory: build/Debug/ - run: ctest - - - name: Print versions - working-directory: build/Debug/ - run: | - .\marian.exe --version - .\marian-decoder.exe --version - .\marian-scorer.exe --version - .\spm_encode.exe --version - diff --git a/.github/workflows/macos-cpu.yml b/.github/workflows/macos-cpu.yml new file mode 100644 index 00000000..07f2a9dd --- /dev/null +++ b/.github/workflows/macos-cpu.yml @@ -0,0 +1,51 @@ +name: macOS CPU-only + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: macos-10.15 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install dependencies + run: brew install openblas protobuf + + # Openblas location is exported explicitly because openblas is keg-only, + # which means it was not symlinked into /usr/local/. + # CMake cannot find BLAS on GitHub runners if Marian is being compiled + # statically, hence USE_STATIC_LIBS=off + - name: Configure CMake + run: | + export LDFLAGS="-L/usr/local/opt/openblas/lib" + export CPPFLAGS="-I/usr/local/opt/openblas/include" + mkdir -p build + cd build + cmake .. -DCOMPILE_CPU=on -DCOMPILE_CUDA=off -DCOMPILE_EXAMPLES=on -DCOMPILE_SERVER=on -DCOMPILE_TESTS=on \ + -DUSE_FBGEMM=on -DUSE_SENTENCEPIECE=on -DUSE_STATIC_LIBS=off + + - name: Compile + working-directory: build + run: make -j2 + + - name: Run unit tests + working-directory: build + run: make test + + - name: Print versions + working-directory: build + run: | + ./marian --version + ./marian-decoder --version + ./marian-scorer --version + ./spm_encode --version + diff --git a/.github/workflows/ubuntu-cpu.yml b/.github/workflows/ubuntu-cpu.yml new file mode 100644 index 00000000..4217053c --- /dev/null +++ b/.github/workflows/ubuntu-cpu.yml @@ -0,0 +1,75 @@ +name: Ubuntu 18.04 CPU-only + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-and-upload: + + runs-on: ubuntu-18.04 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + # The following packages are already installed on GitHub-hosted runners: build-essential openssl libssl-dev + - name: Install dependencies + run: sudo apt-get install --no-install-recommends libgoogle-perftools-dev libprotobuf10 libprotobuf-dev protobuf-compiler + + # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html + - name: Install MKL + run: | + wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add - + 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 --no-install-recommends intel-mkl-64bit-2020.0-088 + + - name: Print Boost paths + run: | + ls $BOOST_ROOT_1_69_0 + ls $BOOST_ROOT_1_69_0/include + ls $BOOST_ROOT_1_69_0/lib + + # Boost is already installed on GitHub-hosted runners in a non-standard location + # https://github.com/actions/virtual-environments/issues/687#issuecomment-610471671 + - name: Configure CMake + run: | + mkdir -p build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release \ + -DCOMPILE_CPU=on -DCOMPILE_CUDA=off -DCOMPILE_EXAMPLES=on -DCOMPILE_SERVER=on -DCOMPILE_TESTS=on \ + -DUSE_FBGEMM=on -DUSE_SENTENCEPIECE=on \ + -DBOOST_ROOT=$BOOST_ROOT_1_69_0 -DBOOST_INCLUDEDIR=$BOOST_ROOT_1_69_0/include -DBOOST_LIBRARYDIR=$BOOST_ROOT_1_69_0/lib \ + -DBoost_ARCHITECTURE=-x64 + + - name: Compile + working-directory: build + run: make -j2 + + - name: Run unit tests + working-directory: build + run: make test + + - name: Print versions + working-directory: build + run: | + ./marian --version + ./marian-decoder --version + ./marian-scorer --version + ./spm_encode --version + + - name: Prepare archive + working-directory: build + run: tar zcvf marian-ubuntu-release-static.tar.gz marian* + + # Marian is built with FBGEMM, so there are some restrictions on what CPUs the executables can be run + - name: Upload archive + uses: actions/upload-artifact@v2 + with: + name: marian-ubuntu-release-static.tar.gz + path: build/marian-ubuntu-release-static.tar.gz diff --git a/.github/workflows/ubuntu-gpu.yml b/.github/workflows/ubuntu-gpu.yml new file mode 100644 index 00000000..ccea606b --- /dev/null +++ b/.github/workflows/ubuntu-gpu.yml @@ -0,0 +1,84 @@ +name: Ubuntu CPU+CUDA + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + include: + # Ubuntu 20.04 supports CUDA 11+ + # Ubuntu 18.04 supports CUDA 10.1+ + - os: ubuntu-18.04 + cuda: "10.2" + gcc: 8 + # Ubuntu 16.04 supports CUDA 8+ + - os: ubuntu-16.04 + cuda: "10.2" + gcc: 7 + - os: ubuntu-16.04 + cuda: 9.2 + gcc: 7 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + # The following packages are already installed on GitHub-hosted runners: build-essential openssl libssl-dev + # 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 install -y libgoogle-perftools-dev libprotobuf-dev protobuf-compiler + + # https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html + - name: Install MKL + run: | + wget -qO- "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB" | sudo apt-key add - + 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 + + # The script simplifies installation of different versions of CUDA + - name: Install CUDA + run: ./scripts/ci/install_cuda_ubuntu.sh ${{ matrix.cuda }} + + # Boost is already installed on GitHub-hosted runners in a non-standard location + # https://github.com/actions/virtual-environments/issues/687#issuecomment-610471671 + - name: Configure CMake + run: | + mkdir -p build + cd build + CC=/usr/bin/gcc-${{ matrix.gcc }} CXX=/usr/bin/g++-${{ matrix.gcc }} CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} \ + cmake .. \ + -DCOMPILE_CPU=on -DCOMPILE_CUDA=on -DCOMPILE_EXAMPLES=on -DCOMPILE_SERVER=on -DCOMPILE_TESTS=on \ + -DUSE_FBGEMM=on -DUSE_SENTENCEPIECE=on \ + -DBOOST_ROOT=$BOOST_ROOT_1_69_0 -DBOOST_INCLUDEDIR=$BOOST_ROOT_1_69_0/include -DBOOST_LIBRARYDIR=$BOOST_ROOT_1_69_0/lib \ + -DBoost_ARCHITECTURE=-x64 \ + -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-${{ matrix.cuda }} + + - name: Compile + working-directory: build + run: make -j2 + + # Unit tests are not run because GitHub-hosted runners do not have GPUs + # TODO: add a flag to CMake to compile unit tests only on CPU + #- name: Run unit tests + #working-directory: build + #run: make test + + - name: Print versions + working-directory: build + run: | + ./marian --version + ./marian-decoder --version + ./marian-scorer --version + ./spm_encode --version + diff --git a/.github/workflows/windows-cpu.yml b/.github/workflows/windows-cpu.yml new file mode 100644 index 00000000..b6543d0d --- /dev/null +++ b/.github/workflows/windows-cpu.yml @@ -0,0 +1,66 @@ +name: Windows CPU-only + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-and-upload: + + runs-on: windows-2019 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Download MKL + run: | + Invoke-WebRequest -Uri https://romang.blob.core.windows.net/mariandev/ci/mkl-2020.1-windows-static.zip -TimeoutSec 600 -OutFile mkl.zip + Expand-Archive -Force mkl.zip ${{ github.workspace }}/mkl + # Set MKLROOT environment variables so that CMake can find MKL. + # GITHUB_WORKSPACE is an environment variable available on all GitHub-hosted runners + echo "::set-env name=MKLROOT::$env:GITHUB_WORKSPACE/mkl" + shell: powershell + + - name: Prepare vcpkg + uses: lukka/run-vcpkg@v2 + with: + vcpkgArguments: protobuf + vcpkgGitCommitId: 6185aa76504a5025f36754324abf307cc776f3da + vcpkgDirectory: ${{ github.workspace }}/vcpkg/ + vcpkgTriplet: x64-windows-static + + # Build with a simplified CMake settings JSON file + - name: Run CMake + uses: lukka/run-cmake@v2 + with: + buildDirectory: ${{ github.workspace }}/build/ + cmakeAppendedArgs: -G Ninja + cmakeListsOrSettingsJson: CMakeSettingsJson + # JSON file must be in the same directory as the main CMakeLists.txt + cmakeSettingsJsonPath: ${{ github.workspace }}/_CMakeSettingsCI_CPU.json + useVcpkgToolchainFile: true + + - name: Run unit tests + working-directory: build/Release/ + run: ctest + + #- name: Print versions + #working-directory: build/Release/ + #run: | + #.\marian.exe --version + #.\marian-decoder.exe --version + #.\marian-scorer.exe --version + #.\spm_encode.exe --version + #shell: powershell + + # Marian is built with FBGEMM, so there are some restrictions on what CPUs the executables can be run + - name: Upload archive + uses: actions/upload-artifact@v2 + with: + name: marian-windows-release-static + path: build/Release/marian*.exe diff --git a/.github/workflows/windows-gpu.yml b/.github/workflows/windows-gpu.yml new file mode 100644 index 00000000..360b64f4 --- /dev/null +++ b/.github/workflows/windows-gpu.yml @@ -0,0 +1,63 @@ +name: Windows CPU+CUDA + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: windows-2019 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install CUDA + run: | + .\scripts\ci\install_cuda_windows.ps1 "10.2" + # Set path to CUDA for subsequent steps so that CMake can find it + echo "::set-env name=CUDA_PATH::$env:CUDA_PATH" + echo "::add-path::$env:CUDA_PATH/bin" + shell: powershell + + - name: Download MKL + run: | + Invoke-WebRequest -Uri https://romang.blob.core.windows.net/mariandev/ci/mkl-2020.1-windows-static.zip -TimeoutSec 600 -OutFile mkl.zip + Expand-Archive -Force mkl.zip ${{ github.workspace }}/mkl + # Set MKLROOT environment variables so that CMake can find MKL. + # GITHUB_WORKSPACE is an environment variable available on all GitHub-hosted runners + echo "::set-env name=MKLROOT::$env:GITHUB_WORKSPACE/mkl" + shell: powershell + + - name: Prepare vcpkg + uses: lukka/run-vcpkg@v2 + with: + vcpkgArguments: protobuf + vcpkgGitCommitId: 6185aa76504a5025f36754324abf307cc776f3da + vcpkgDirectory: ${{ github.workspace }}/vcpkg/ + vcpkgTriplet: x64-windows-static + + # Build with a simplified CMake settings JSON file. + # On Windows+CUDA we compile with COMPILE_CUDA=on and USE_NCCL=off + - name: Run CMake + uses: lukka/run-cmake@v2 + with: + buildDirectory: ${{ github.workspace }}/build/ + cmakeAppendedArgs: -G Ninja + cmakeListsOrSettingsJson: CMakeSettingsJson + # JSON file must be in the same directory as the main CMakeLists.txt + cmakeSettingsJsonPath: ${{ github.workspace }}/_CMakeSettingsCI_GPU.json + useVcpkgToolchainFile: true + + - name: Print versions + working-directory: build/Debug/ + run: | + .\marian.exe --version + .\marian-decoder.exe --version + .\marian-scorer.exe --version + .\spm_encode.exe --version -- cgit v1.2.3