Unverified Commit 4b5d549d authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[ci] simplify CI configurations, parallelize compilation, test CUDA on Ubuntu 22.04 (#6458)

parent dd9da91f
...@@ -27,10 +27,10 @@ install: ...@@ -27,10 +27,10 @@ install:
- set PYTHON_VERSION=%CONFIGURATION% - set PYTHON_VERSION=%CONFIGURATION%
- set CONDA_ENV="test-env" - set CONDA_ENV="test-env"
- ps: | - ps: |
$env:CMAKE_BUILD_PARALLEL_LEVEL = 4
$env:MINICONDA = "C:\Miniconda3-x64" $env:MINICONDA = "C:\Miniconda3-x64"
$env:PATH = "$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH" $env:PATH = "$env:MINICONDA;$env:MINICONDA\Scripts;$env:PATH"
$env:BUILD_SOURCESDIRECTORY = "$env:APPVEYOR_BUILD_FOLDER" $env:BUILD_SOURCESDIRECTORY = "$env:APPVEYOR_BUILD_FOLDER"
$env:LGB_VER = (Get-Content $env:APPVEYOR_BUILD_FOLDER\VERSION.txt).trim()
build: false build: false
......
...@@ -10,6 +10,8 @@ SANITIZERS=${SANITIZERS:-""} ...@@ -10,6 +10,8 @@ SANITIZERS=${SANITIZERS:-""}
ARCH=$(uname -m) ARCH=$(uname -m)
LGB_VER=$(head -n 1 ${BUILD_DIRECTORY}/VERSION.txt)
if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then if [[ $OS_NAME == "macos" ]] && [[ $COMPILER == "gcc" ]]; then
export CXX=g++-11 export CXX=g++-11
export CC=gcc-11 export CC=gcc-11
......
...@@ -6,6 +6,8 @@ function Check-Output { ...@@ -6,6 +6,8 @@ function Check-Output {
} }
} }
$env:LGB_VER = (Get-Content $env:BUILD_SOURCESDIRECTORY\VERSION.txt).trim()
# unify environment variable for Azure DevOps and AppVeyor # unify environment variable for Azure DevOps and AppVeyor
if (Test-Path env:APPVEYOR) { if (Test-Path env:APPVEYOR) {
$env:APPVEYOR = "true" $env:APPVEYOR = "true"
......
...@@ -8,53 +8,41 @@ on: ...@@ -8,53 +8,41 @@ on:
branches: branches:
- master - master
- release/* - release/*
# Run manually by clicking a button in the UI
workflow_dispatch:
inputs:
restart_docker:
description: 'Restart nvidia-docker on the runner before building?'
required: true
type: boolean
default: false
# automatically cancel in-progress builds if another commit is pushed # automatically cancel in-progress builds if another commit is pushed
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
env:
github_actions: 'true'
os_name: linux
conda_env: test-env
jobs: jobs:
test: # Optionally reinstall + restart docker on the runner before building.
name: ${{ matrix.task }} ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }}) # This is safe as long as only 1 of these jobs runs at a time.
restart-docker:
name: set up docker
runs-on: [self-hosted, linux] runs-on: [self-hosted, linux]
timeout-minutes: 60 timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- method: wheel
compiler: gcc
python_version: "3.11"
cuda_version: "11.8.0"
task: cuda
- method: source
compiler: gcc
python_version: "3.9"
cuda_version: "12.2.0"
task: cuda
- method: pip
compiler: clang
python_version: "3.10"
cuda_version: "11.8.0"
task: cuda
steps: steps:
- name: Setup or update software on host machine - name: Setup or update software on host machine
if: ${{ inputs.restart_docker }}
run: | run: |
# install core packages
sudo apt-get update sudo apt-get update
sudo apt-get install --no-install-recommends -y \ sudo apt-get install --no-install-recommends -y \
apt-transport-https \ apt-transport-https \
ca-certificates \ ca-certificates \
curl \ curl \
git \
gnupg-agent \ gnupg-agent \
lsb-release \ lsb-release \
software-properties-common software-properties-common
# set up nvidia-docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y
curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
...@@ -67,43 +55,76 @@ jobs: ...@@ -67,43 +55,76 @@ jobs:
nvidia-docker2 nvidia-docker2
sudo chmod a+rw /var/run/docker.sock sudo chmod a+rw /var/run/docker.sock
sudo systemctl restart docker sudo systemctl restart docker
- name: Remove old folder with repository - name: mark job successful
run: sudo rm -rf $GITHUB_WORKSPACE run: |
exit 0
test:
name: ${{ matrix.task }} ${{ matrix.cuda_version }} ${{ matrix.method }} (linux, ${{ matrix.compiler }}, Python ${{ matrix.python_version }})
runs-on: [self-hosted, linux]
needs: [restart-docker]
container:
image: ${{ matrix.image }}
env:
CMAKE_BUILD_PARALLEL_LEVEL: 4
COMPILER: ${{ matrix.compiler }}
CONDA: /tmp/miniforge
CONDA_ENV: test-env
DEBIAN_FRONTEND: noninteractive
METHOD: ${{ matrix.method }}
OS_NAME: linux
PYTHON_VERSION: ${{ matrix.python_version }}
TASK: ${{ matrix.task }}
options: --gpus all
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- method: wheel
compiler: gcc
python_version: "3.11"
cuda_version: "11.8.0"
image: nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04
task: cuda
- method: source
compiler: gcc
python_version: "3.9"
cuda_version: "12.2.0"
image: nvcr.io/nvidia/cuda:12.2.0-devel-ubuntu22.04
task: cuda
- method: pip
compiler: clang
python_version: "3.10"
cuda_version: "11.8.0"
image: nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu20.04
task: cuda
steps:
- name: Install latest git
run: |
apt-get update
apt-get install --no-install-recommends -y \
ca-certificates \
software-properties-common
add-apt-repository ppa:git-core/ppa -y
apt-get update
apt-get install --no-install-recommends -y \
git
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v1 uses: actions/checkout@v4
with: with:
fetch-depth: 5 fetch-depth: 5
submodules: true submodules: true
- name: Setup and run tests - name: Setup and run tests
run: | run: |
export ROOT_DOCKER_FOLDER=/LightGBM export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
cat > docker.env <<EOF export PATH=$CONDA/bin:$PATH
GITHUB_ACTIONS=${{ env.github_actions }}
OS_NAME=${{ env.os_name }} # check GPU usage
COMPILER=${{ matrix.compiler }} nvidia-smi
TASK=${{ matrix.task }}
METHOD=${{ matrix.method }} # build and test
CONDA_ENV=${{ env.conda_env }} $GITHUB_WORKSPACE/.ci/setup.sh
PYTHON_VERSION=${{ matrix.python_version }} $GITHUB_WORKSPACE/.ci/test.sh
BUILD_DIRECTORY=$ROOT_DOCKER_FOLDER
LGB_VER=$(head -n 1 VERSION.txt)
EOF
cat > docker-script.sh <<EOF
export CONDA=\$HOME/miniforge
export PATH=\$CONDA/bin:\$PATH
nvidia-smi
$ROOT_DOCKER_FOLDER/.ci/setup.sh || exit 1
$ROOT_DOCKER_FOLDER/.ci/test.sh || exit 1
EOF
cuda_version="${{ matrix.cuda_version }}"
cuda_major=${cuda_version%%.*}
docker_img="nvcr.io/nvidia/cuda:${cuda_version}-devel"
if [[ ${cuda_major} -eq 11 ]]; then
docker_img="${docker_img}-ubuntu18.04"
elif [[ ${cuda_major} -ge 12 ]]; then
docker_img="${docker_img}-ubuntu20.04"
fi
docker run --env-file docker.env -v "$GITHUB_WORKSPACE":"$ROOT_DOCKER_FOLDER" --rm --gpus all "$docker_img" /bin/bash $ROOT_DOCKER_FOLDER/docker-script.sh
all-cuda-jobs-successful: all-cuda-jobs-successful:
if: always() if: always()
runs-on: ubuntu-latest runs-on: ubuntu-latest
......
...@@ -9,7 +9,6 @@ on: ...@@ -9,7 +9,6 @@ on:
env: env:
CONDA_ENV: test-env CONDA_ENV: test-env
GITHUB_ACTIONS: 'true'
OS_NAME: 'linux' OS_NAME: 'linux'
PYTHON_VERSION: '3.11' PYTHON_VERSION: '3.11'
TASK: 'check-links' TASK: 'check-links'
......
...@@ -15,8 +15,8 @@ concurrency: ...@@ -15,8 +15,8 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
CMAKE_BUILD_PARALLEL_LEVEL: 4
CONDA_ENV: test-env CONDA_ENV: test-env
GITHUB_ACTIONS: 'true'
jobs: jobs:
test: test:
...@@ -73,7 +73,6 @@ jobs: ...@@ -73,7 +73,6 @@ jobs:
export OS_NAME="linux" export OS_NAME="linux"
fi fi
export BUILD_DIRECTORY="$GITHUB_WORKSPACE" export BUILD_DIRECTORY="$GITHUB_WORKSPACE"
export LGB_VER=$(head -n 1 VERSION.txt)
export CONDA=${HOME}/miniforge export CONDA=${HOME}/miniforge
export PATH=${CONDA}/bin:${PATH} export PATH=${CONDA}/bin:${PATH}
$GITHUB_WORKSPACE/.ci/setup.sh || exit 1 $GITHUB_WORKSPACE/.ci/setup.sh || exit 1
......
...@@ -15,6 +15,7 @@ concurrency: ...@@ -15,6 +15,7 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
CMAKE_BUILD_PARALLEL_LEVEL: 4
# hack to get around this: # hack to get around this:
# https://stat.ethz.ch/pipermail/r-package-devel/2020q3/005930.html # https://stat.ethz.ch/pipermail/r-package-devel/2020q3/005930.html
_R_CHECK_SYSTEM_CLOCK_: 0 _R_CHECK_SYSTEM_CLOCK_: 0
...@@ -189,7 +190,6 @@ jobs: ...@@ -189,7 +190,6 @@ jobs:
run: | run: |
export TASK="${{ matrix.task }}" export TASK="${{ matrix.task }}"
export COMPILER="${{ matrix.compiler }}" export COMPILER="${{ matrix.compiler }}"
export GITHUB_ACTIONS="true"
if [[ "${{ matrix.os }}" == "macos-13" ]]; then if [[ "${{ matrix.os }}" == "macos-13" ]]; then
export OS_NAME="macos" export OS_NAME="macos"
elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then elif [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
...@@ -216,7 +216,6 @@ jobs: ...@@ -216,7 +216,6 @@ jobs:
$env:R_VERSION = "${{ matrix.r_version }}" $env:R_VERSION = "${{ matrix.r_version }}"
$env:R_BUILD_TYPE = "${{ matrix.build_type }}" $env:R_BUILD_TYPE = "${{ matrix.build_type }}"
$env:COMPILER = "${{ matrix.compiler }}" $env:COMPILER = "${{ matrix.compiler }}"
$env:GITHUB_ACTIONS = "true"
$env:TASK = "${{ matrix.task }}" $env:TASK = "${{ matrix.task }}"
& "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1" & "$env:GITHUB_WORKSPACE/.ci/test_windows.ps1"
test-r-sanitizers: test-r-sanitizers:
......
...@@ -19,7 +19,6 @@ concurrency: ...@@ -19,7 +19,6 @@ concurrency:
env: env:
COMPILER: 'gcc' COMPILER: 'gcc'
CONDA_ENV: test-env CONDA_ENV: test-env
GITHUB_ACTIONS: 'true'
OS_NAME: 'linux' OS_NAME: 'linux'
PYTHON_VERSION: '3.11' PYTHON_VERSION: '3.11'
......
...@@ -11,6 +11,7 @@ pr: ...@@ -11,6 +11,7 @@ pr:
variables: variables:
AZURE: 'true' AZURE: 'true'
PYTHON_VERSION: '3.11' PYTHON_VERSION: '3.11'
CMAKE_BUILD_PARALLEL_LEVEL: 4
CONDA_ENV: test-env CONDA_ENV: test-env
runCodesignValidationInjection: false runCodesignValidationInjection: false
skipComponentGovernanceDetection: true skipComponentGovernanceDetection: true
...@@ -82,7 +83,6 @@ jobs: ...@@ -82,7 +83,6 @@ jobs:
steps: steps:
- script: | - script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY" echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
echo "##vso[task.setvariable variable=LGB_VER]$(head -n 1 VERSION.txt)"
echo "##vso[task.prependpath]/usr/lib64/openmpi/bin" echo "##vso[task.prependpath]/usr/lib64/openmpi/bin"
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
displayName: 'Set variables' displayName: 'Set variables'
...@@ -159,7 +159,6 @@ jobs: ...@@ -159,7 +159,6 @@ jobs:
steps: steps:
- script: | - script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY" echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
echo "##vso[task.setvariable variable=LGB_VER]$(head -n 1 VERSION.txt)"
CONDA=$HOME/miniforge CONDA=$HOME/miniforge
echo "##vso[task.setvariable variable=CONDA]$CONDA" echo "##vso[task.setvariable variable=CONDA]$CONDA"
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
...@@ -225,7 +224,6 @@ jobs: ...@@ -225,7 +224,6 @@ jobs:
CONDA_ENV=$CONDA_ENV CONDA_ENV=$CONDA_ENV
PYTHON_VERSION=$PYTHON_VERSION PYTHON_VERSION=$PYTHON_VERSION
BUILD_DIRECTORY=$ROOT_DOCKER_FOLDER BUILD_DIRECTORY=$ROOT_DOCKER_FOLDER
LGB_VER=$(head -n 1 VERSION.txt)
PRODUCES_ARTIFACTS=$PRODUCES_ARTIFACTS PRODUCES_ARTIFACTS=$PRODUCES_ARTIFACTS
BUILD_ARTIFACTSTAGINGDIRECTORY=$BUILD_ARTIFACTSTAGINGDIRECTORY BUILD_ARTIFACTSTAGINGDIRECTORY=$BUILD_ARTIFACTSTAGINGDIRECTORY
EOF EOF
...@@ -283,7 +281,6 @@ jobs: ...@@ -283,7 +281,6 @@ jobs:
steps: steps:
- script: | - script: |
echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY" echo "##vso[task.setvariable variable=BUILD_DIRECTORY]$BUILD_SOURCESDIRECTORY"
echo "##vso[task.setvariable variable=LGB_VER]$(head -n 1 VERSION.txt)"
CONDA=$AGENT_HOMEDIRECTORY/miniforge CONDA=$AGENT_HOMEDIRECTORY/miniforge
echo "##vso[task.setvariable variable=CONDA]$CONDA" echo "##vso[task.setvariable variable=CONDA]$CONDA"
echo "##vso[task.prependpath]$CONDA/bin" echo "##vso[task.prependpath]$CONDA/bin"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment