-
Notifications
You must be signed in to change notification settings - Fork 3.9k
86 lines (84 loc) · 3.64 KB
/
cuda.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: CUDA GitHub Actions
on:
push:
branches:
- test_cuda
jobs:
test:
name: CUDA
runs-on: [self-hosted, linux]
timeout-minutes: 60
strategy:
fail-fast: false
steps:
- name: Setup or update software on host machine
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
curl \
git \
gnupg-agent \
software-properties-common \
wget
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
curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -sL https://nvidia.github.io/nvidia-docker/$(. /etc/os-release;echo $ID$VERSION_ID)/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
containerd.io \
docker-ce \
docker-ce-cli \
nvidia-docker2
sudo systemctl restart docker
- name: Remove old folder with repository
run: sudo rm -rf $GITHUB_WORKSPACE
- name: Checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 20
submodules: true
ref: 5d79ff20d1b7ae226531e2445b17d747b253a637
- name: Test CUDA
run: |
export ROOT_DOCKER_FOLDER=/LightGBM
cat > docker.env <<EOF
TASK=cuda
COMPILER=gcc
GITHUB_ACTIONS=true
OS_NAME=linux
BUILD_DIRECTORY=$ROOT_DOCKER_FOLDER
CONDA_ENV=test-env
PYTHON_VERSION=3.6
EOF
cat > docker-script.sh <<EOF
export CONDA=\$HOME/miniconda
export PATH=\$CONDA/bin:\$PATH
nvidia-smi
apt-get update
apt-get install --no-install-recommends -y curl wget
curl -sL https://cmake.org/files/v3.19/cmake-3.19.2-Linux-x86_64.sh -o cmake.sh
chmod +x cmake.sh
./cmake.sh --prefix=/usr/local --exclude-subdir
wget -q -O conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x conda.sh
sh conda.sh -b -p \$CONDA
conda config --set always_yes yes --set changeps1 no
conda update -q -y conda
conda create -q -y -n \$CONDA_ENV python=\$PYTHON_VERSION
source activate \$CONDA_ENV
cd \$BUILD_DIRECTORY
conda install -q -y -n \$CONDA_ENV numpy pandas
mkdir \$BUILD_DIRECTORY/build && cd \$BUILD_DIRECTORY/build
sed -i'.bak' 's/std::string device_type = "cpu";/std::string device_type = "cuda";/' \$BUILD_DIRECTORY/include/LightGBM/config.h
grep -q 'std::string device_type = "cuda"' \$BUILD_DIRECTORY/include/LightGBM/config.h || exit -1 # make sure that changes were really done
cmake -DUSE_CUDA=ON ..
make _lightgbm -j4 || exit -1
cd \$BUILD_DIRECTORY/python-package && python setup.py install --precompile --user || exit -1
cd \$BUILD_DIRECTORY/examples/python-guide/
python --version
python simple_example.py
EOF
sudo docker run --env-file docker.env -v "$GITHUB_WORKSPACE":"$ROOT_DOCKER_FOLDER" --rm --gpus all nvidia/cuda:11.0-devel-ubuntu20.04 /bin/bash $ROOT_DOCKER_FOLDER/docker-script.sh