Skip to content

Commit

Permalink
Factor out build env preparation (#156)
Browse files Browse the repository at this point in the history
Refactor the build env preparation in workflows to use composite action, this will allow us to reuse the logic in integration test.
  • Loading branch information
cloudhan authored Sep 4, 2023
1 parent 142ec8f commit c7decde
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 53 deletions.
File renamed without changes.
83 changes: 83 additions & 0 deletions .github/actions/set-build-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "Setup Build Environment"
description: ""

inputs:
os:
description: "matrix.cases.os"
required: true
cuda-version:
description: "matrix.cases.cuda-version"
required: true
source:
description: "matrix.cases.source"
required: true
toolchain:
description: "matrix.cases.toolchain"
required: false
toolchain-version:
description: "matrix.cases.toolchain-version"
required: false

runs:
using: "composite"
steps:
- name: Install CUDA (NVIDIA, Linux)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'nvidia' }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]'
method: network
- name: Show bin, include, lib (NVIDIA, Linux)
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'nvidia' }}
shell: bash
run: |
tree ${CUDA_PATH}/bin
tree ${CUDA_PATH}/include
tree ${CUDA_PATH}/lib64
- name: Install LLVM ${{ inputs.toolchain-version }}
if: ${{ !startsWith(inputs.os, 'windows') && inputs.toolchain == 'llvm' }}
shell: bash
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ inputs.toolchain-version }}
sudo ln -sf /usr/bin/clang-${{ inputs.toolchain-version }} /usr/bin/clang
clang --version
- name: Install CURAND For LLVM
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.os, 'windows') && inputs.toolchain == 'llvm' }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]' # avoid full cuda install
non-cuda-sub-packages: '["libcurand-dev"]'
method: network
- name: Install CUDA (Ubuntu)
if: ${{ !startsWith(inputs.os, 'windows') && inputs.source == 'ubuntu' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-dev=${{ inputs.cuda-version }} nvidia-cuda-toolkit=${{ inputs.cuda-version }} gcc-9 g++-9
export CC=gcc-9
export CXX=g++-9
echo "CC=gcc-9" >> $GITHUB_ENV
echo "CXX=g++-9" >> $GITHUB_ENV
- name: Install CUDA (Windows)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ startsWith(inputs.os, 'windows') }}
with:
cuda: ${{ inputs.cuda-version }}
sub-packages: '["nvcc", "cudart"]'
method: network
- name: Show bin, include, lib64 (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
shell: pwsh
run: |
tree /F $env:CUDA_PATH/bin
tree /F $env:CUDA_PATH/include
tree /F $env:CUDA_PATH/lib/x64
- name: Set Visual Studio Environment (Windows)
if: ${{ startsWith(inputs.os, 'windows') }}
shell: pwsh
run: .github/actions/Set-VSEnv.ps1 2019
62 changes: 9 additions & 53 deletions .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,65 +41,21 @@ jobs:
path: ~/.cache/bazel
key: bazel-${{ matrix.cases.os }}-cuda-${{ matrix.cases.cuda-version }}-${{ hashFiles('.bazelversion') }}

- name: Install CUDA (NVIDIA, Linux)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'nvidia' }}
- name: Setup build environment
uses: ./.github/actions/set-build-env
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]'
method: network
- name: Show bin, include, lib (NVIDIA, Linux)
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'nvidia' }}
run: |
tree ${CUDA_PATH}/bin
tree ${CUDA_PATH}/include
tree ${CUDA_PATH}/lib64
- name: Install LLVM ${{ matrix.cases.toolchain-version }}
os: ${{ matrix.cases.os }}
cuda-version: ${{ matrix.cases.cuda-version }}
source: ${{ matrix.cases.source }}
toolchain: ${{ matrix.cases.toolchain }}
toolchain-version: ${{ matrix.cases.toolchain-version }}

- name: Bazel build config for LLVM
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.cases.toolchain-version }}
sudo ln -sf /usr/bin/clang-${{ matrix.cases.toolchain-version }} /usr/bin/clang
clang --version
echo "build --config=clang" > $HOME/.bazelrc
echo "build:clang --@rules_cuda//cuda:archs=sm_80" >> $HOME/.bazelrc
echo "build:clang --spawn_strategy=local" >> $HOME/.bazelrc
- name: Install CURAND For LLVM
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.toolchain == 'llvm' }}
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]' # avoid full cuda install
non-cuda-sub-packages: '["libcurand-dev"]'
method: network
- name: Install CUDA (Ubuntu)
if: ${{ !startsWith(matrix.cases.os, 'windows') && matrix.cases.source == 'ubuntu' }}
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-dev=${{ matrix.cases.cuda-version }} nvidia-cuda-toolkit=${{ matrix.cases.cuda-version }} gcc-9 g++-9
export CC=gcc-9
export CXX=g++-9
echo "CC=gcc-9" >> $GITHUB_ENV
echo "CXX=g++-9" >> $GITHUB_ENV
- name: Install CUDA (Windows)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ startsWith(matrix.cases.os, 'windows') }}
with:
cuda: ${{ matrix.cases.cuda-version }}
sub-packages: '["nvcc", "cudart"]'
method: network
- name: Show bin, include, lib64 (Windows)
if: ${{ startsWith(matrix.cases.os, 'windows') }}
run: |
tree /F $env:CUDA_PATH/bin
tree /F $env:CUDA_PATH/include
tree /F $env:CUDA_PATH/lib/x64
- name: Set Visual Studio Environment (Windows)
if: ${{ startsWith(matrix.cases.os, 'windows') }}
run: .github/workflows/Set-VSEnv.ps1 2019
- run: bazelisk build @rules_cuda_examples//basic:all
- run: bazelisk build @rules_cuda_examples//rdc:all
Expand Down

0 comments on commit c7decde

Please sign in to comment.