Skip to content

Commit

Permalink
Factor out build env preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhan committed Sep 2, 2023
1 parent 40a874f commit 2052587
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 53 deletions.
File renamed without changes.
66 changes: 66 additions & 0 deletions .github/actions/set-build-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

name: "Setup Build Environment"

inputs:
case:
description: "case from workflow matrix"
required: true

runs:
using: "composite"
steps:
- name: Install CUDA (NVIDIA, Linux)
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.case.os, 'windows') && inputs.case.source == 'nvidia' }}
with:
cuda: ${{ inputs.case.cuda-version }}
sub-packages: '["nvcc", "cudart-dev"]'
method: network
- name: Show bin, include, lib (NVIDIA, Linux)
if: ${{ !startsWith(inputs.case.os, 'windows') && inputs.case.source == 'nvidia' }}
run: |
tree ${CUDA_PATH}/bin
tree ${CUDA_PATH}/include
tree ${CUDA_PATH}/lib64
- name: Install LLVM ${{ inputs.case.toolchain-version }}
if: ${{ !startsWith(inputs.case.os, 'windows') && inputs.case.toolchain == 'llvm' }}
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ inputs.case.toolchain-version }}
sudo ln -sf /usr/bin/clang-${{ inputs.case.toolchain-version }} /usr/bin/clang
clang --version
- name: Install CURAND For LLVM
uses: Jimver/cuda-toolkit@v0.2.11
if: ${{ !startsWith(inputs.case.os, 'windows') && inputs.case.toolchain == 'llvm' }}
with:
cuda: ${{ inputs.case.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.case.os, 'windows') && inputs.case.source == 'ubuntu' }}
run: |
sudo apt-get update
sudo apt-get install -y nvidia-cuda-dev=${{ inputs.case.cuda-version }} nvidia-cuda-toolkit=${{ inputs.case.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.case.os, 'windows') }}
with:
cuda: ${{ inputs.case.cuda-version }}
sub-packages: '["nvcc", "cudart"]'
method: network
- name: Show bin, include, lib64 (Windows)
if: ${{ startsWith(inputs.case.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(inputs.case.os, 'windows') }}
run: .github/actions/Set-VSEnv.ps1 2019
57 changes: 4 additions & 53 deletions .github/workflows/build-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,65 +41,16 @@ 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' }}
- 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 }}
case: ${{ matrix.cases }}

- 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 2052587

Please sign in to comment.