mirror of https://github.com/hpcaitech/ColossalAI
[setup] make cuda extension build optional (#2336)
* [setup] make cuda extension build optional * polish code * polish code * polish codepull/2338/head
parent
8711310cda
commit
f1bc2418c4
|
@ -5,13 +5,31 @@ on:
|
||||||
types: [synchronize, labeled]
|
types: [synchronize, labeled]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
detect:
|
||||||
name: Build and Test Colossal-AI
|
name: Detect kernel-related file change
|
||||||
if: |
|
if: |
|
||||||
github.event.pull_request.draft == false &&
|
github.event.pull_request.draft == false &&
|
||||||
github.base_ref == 'main' &&
|
github.base_ref == 'main' &&
|
||||||
github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' &&
|
github.event.pull_request.base.repo.full_name == 'hpcaitech/ColossalAI' &&
|
||||||
contains( github.event.pull_request.labels.*.name, 'Run Build and Test')
|
contains( github.event.pull_request.labels.*.name, 'Run Build and Test')
|
||||||
|
outputs:
|
||||||
|
changedFiles: ${{ steps.find-changed-files.outputs.changedFiles }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Find the changed files
|
||||||
|
id: find-changed-files
|
||||||
|
uses: tj-actions/changed-files@v34
|
||||||
|
with:
|
||||||
|
since_last_remote_commit: true
|
||||||
|
files: |
|
||||||
|
op_builder/**
|
||||||
|
colossalai/kernel/**
|
||||||
|
setup.py
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build and Test Colossal-AI
|
||||||
|
needs: detect
|
||||||
runs-on: [self-hosted, gpu]
|
runs-on: [self-hosted, gpu]
|
||||||
container:
|
container:
|
||||||
image: hpcaitech/pytorch-cuda:1.11.0-11.3.0
|
image: hpcaitech/pytorch-cuda:1.11.0-11.3.0
|
||||||
|
@ -35,23 +53,14 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ssh-key: ${{ secrets.SSH_KEY_FOR_CI }}
|
ssh-key: ${{ secrets.SSH_KEY_FOR_CI }}
|
||||||
|
|
||||||
- name: Find the changed files
|
|
||||||
id: find-changed-files
|
|
||||||
uses: tj-actions/changed-files@v34
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
op_builder/**
|
|
||||||
colossalai/kernel/**
|
|
||||||
setup.py
|
|
||||||
|
|
||||||
- name: Restore cache
|
- name: Restore cache
|
||||||
if: steps.find-changed-files.outputs.any_changed != 'true'
|
if: needs.detect.outputs.anyChanged == 'true'
|
||||||
run: |
|
run: |
|
||||||
[ ! -z "$(ls -A /github/home/cuda_ext_cache/)" ] && cp -r /github/home/cuda_ext_cache/* /__w/ColossalAI/ColossalAI/
|
[ ! -z "$(ls -A /github/home/cuda_ext_cache/)" ] && cp -r /github/home/cuda_ext_cache/* /__w/ColossalAI/ColossalAI/
|
||||||
|
|
||||||
- name: Install Colossal-AI
|
- name: Install Colossal-AI
|
||||||
run: |
|
run: |
|
||||||
pip install -v -e .
|
CUDA_EXT=1 pip install -v -e .
|
||||||
pip install -r requirements/requirements-test.txt
|
pip install -r requirements/requirements-test.txt
|
||||||
|
|
||||||
- name: Unit Testing
|
- name: Unit Testing
|
||||||
|
|
|
@ -33,8 +33,7 @@ jobs:
|
||||||
- name: Install Colossal-AI
|
- name: Install Colossal-AI
|
||||||
run: |
|
run: |
|
||||||
[ ! -z "$(ls -A /github/home/cuda_ext_cache/)" ] && cp -r /github/home/cuda_ext_cache/* /__w/ColossalAI/ColossalAI/
|
[ ! -z "$(ls -A /github/home/cuda_ext_cache/)" ] && cp -r /github/home/cuda_ext_cache/* /__w/ColossalAI/ColossalAI/
|
||||||
pip install -r requirements/requirements.txt
|
CUDA_EXT=1 pip install -v -e .
|
||||||
pip install -v -e .
|
|
||||||
cp -r /__w/ColossalAI/ColossalAI/build /github/home/cuda_ext_cache/
|
cp -r /__w/ColossalAI/ColossalAI/build /github/home/cuda_ext_cache/
|
||||||
pip install -r requirements/requirements-test.txt
|
pip install -r requirements/requirements-test.txt
|
||||||
- name: Unit Testing
|
- name: Unit Testing
|
||||||
|
|
13
setup.py
13
setup.py
|
@ -18,15 +18,22 @@ try:
|
||||||
TORCH_AVAILABLE = True
|
TORCH_AVAILABLE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
TORCH_AVAILABLE = False
|
TORCH_AVAILABLE = False
|
||||||
|
CUDA_HOME = None
|
||||||
|
|
||||||
|
|
||||||
# ninja build does not work unless include_dirs are abs path
|
# ninja build does not work unless include_dirs are abs path
|
||||||
this_dir = os.path.dirname(os.path.abspath(__file__))
|
this_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
build_cuda_ext = True
|
build_cuda_ext = False
|
||||||
ext_modules = []
|
ext_modules = []
|
||||||
|
|
||||||
if int(os.environ.get('NO_CUDA_EXT', '0')) == 1 or not TORCH_AVAILABLE:
|
if int(os.environ.get('CUDA_EXT', '0')) == 1:
|
||||||
build_cuda_ext = False
|
if not TORCH_AVAILABLE:
|
||||||
|
raise ModuleNotFoundError("PyTorch is not found while CUDA_EXT=1. You need to install PyTorch first in order to build CUDA extensions")
|
||||||
|
|
||||||
|
if not CUDA_HOME:
|
||||||
|
raise RuntimeError("CUDA_HOME is not found while CUDA_EXT=1. You need to export CUDA_HOME environment vairable or install CUDA Toolkit first in order to build CUDA extensions")
|
||||||
|
|
||||||
|
build_cuda_ext = True
|
||||||
|
|
||||||
|
|
||||||
def check_cuda_torch_binary_vs_bare_metal(cuda_dir):
|
def check_cuda_torch_binary_vs_bare_metal(cuda_dir):
|
||||||
|
|
Loading…
Reference in New Issue