Skip to content

Commit

Permalink
BUILD(cfg): Add build toolchain for CUDA variant
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSWang committed Sep 10, 2024
1 parent c00b62f commit 9595fc8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
30 changes: 6 additions & 24 deletions .github/workflows/cd_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ jobs:
package-dir: .
output-dir: dist/
config-file: pyproject.toml
env:
CIBW_ENVIRONMENT: >-
PY_CXX=nvcc
PY_OMP=1
PY_CUDA=1
PY_BUILD_PARALLEL='-j'

- name: Verify built distribution
run: python -m twine check --strict dist/*
Expand Down Expand Up @@ -124,19 +118,11 @@ jobs:
with:
fetch-depth: 0

- uses: Jimver/cuda-toolkit@master
id: cuda-toolkit
with:
log-file-suffix: '${{matrix.os}}_cudatoolkit_log.txt'
method: 'network'
sub-packages: '["nvcc"]'
non-cuda-sub-packages: '["libcufft"]'

- name: Set up (Mini)conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: conda_bld
channels: conda-forge
channels: conda-forge,nvidia
channel-priority: strict

- name: Install packaging requirements
Expand All @@ -149,17 +135,13 @@ jobs:
- name: Override version
if: github.event_name == 'workflow_dispatch'
uses: knicknic/os-specific-run@v1.0.4
env:
recipe_file: deploy/pkg/conda_recipe_cuda/meta.yaml
with:
linux: |
vers_tag=${{ github.event.inputs.version_tag }}
cuda_vers=${{ steps.cuda-toolkit.outputs.cuda }}
if [[ ! -z ${vers_tag} ]]; then
sed -i "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
sed -i "s/'CUDA_VERSION', ''/'CUDA_VERSION', '${cuda_vers}'/g" ${recipe_file}
fi
run: |
vers_tag=${{ github.event.inputs.version_tag }}
if [[ ! -z ${vers_tag} ]]; then
sed -i "s/# git_rev:.*/git_rev: ${vers_tag}/g" ${recipe_file}
fi
- name: Build Conda package
env:
Expand Down
10 changes: 9 additions & 1 deletion .pyproject_cuda.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,16 @@ manylinux-aarch64-image = 'manylinux_2_28'

[tool.cibuildwheel.linux]
before-all = [
"yum install -y gsl-devel cuda-toolkit",
"yum install -y gsl-devel",
# Install CUDA Toolkit inside Docker container using package manager,
# matching repository with image OS, and optionally matching CUDA version
# for Pip/Conda consistency.
"yum install -y yum-utils",
"yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo",
"yum install -y cuda-toolkit",
# "yum install -y cuda-toolkit-12-6",
]
environment = { PY_CXX="/usr/local/cuda/bin/nvcc", PY_CXXFLAGS="-I/usr/local/cuda/include", PY_LDFLAGS="-L/usr/local/cuda/lib64", PY_OMP='1', PY_CUDA='1', PY_BUILD_PARALLEL='-j' }

[tool.autopep8]
in-place = true
Expand Down
5 changes: 4 additions & 1 deletion deploy/pkg/conda_recipe_cuda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
target_platform:
- linux-64 # [linux]
- linux-aarch64 # [linux]
# - linux-aarch64 # [linux]

cuda_version:
- 12.0
33 changes: 22 additions & 11 deletions deploy/pkg/conda_recipe_cuda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% set name = 'Triumvirate-CUDA' %}
{% set version = environ.get('GIT_DESCRIBE_TAG', 'v0.5.0') %}
{% set cuda_vers = environ.get('CUDA_VERSION', '') %}
# {% set cuda_vers = environ.get('CUDA_VERSION', '12.0') %}
# {% set cuda_vers_parts = cuda_vers.split('.') %}
# {% set cuda_vers_major_minor = cuda_vers_parts[0] ~ cuda_vers_parts[1] %}
# {% set cuda_vers_int = cuda_vers_major_minor|int %}
# {% set cuda_path = environ.get('CUDA_PATH', '/usr/local/cuda') %}

package:
name: "{{ name|lower }}"
Expand All @@ -13,22 +17,26 @@ source:

build:
number: 0
string: cuda{{ cuda_vers }}_py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
string: cuda{{ cuda_version|replace(".", "") }}py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
script:
# Use Conda-provided compiler.
- export PY_CXX=$CXX
- export PY_CXXFLAGS="${PY_CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
# Enforce OpenMP support.
- export PY_OMP=1
- export PY_CUDA=1
- cp .pyproject_cuda.toml pyproject.toml
- {{ PYTHON }} -m pip install . -vvv
script_env:
- PY_BUILD_PARALLEL="-j"
- PY_CXX="${CONDA_PREFIX}/bin/nvcc"
- PY_CXXFLAGS="-I${CONDA_PREFIX}/include -D_LIBCPP_DISABLE_AVAILABILITY"
- PY_LDFLAGS="-L${CONDA_PREFIX}/lib"
# Enforce OpenMP and CUDA support.
- PY_OMP=1
- PY_CUDA=1
- PY_BUILD_PARALLEL='-j'

requirements:
build:
- {{ compiler('cuda') }}
# Use Nvidia channel libraries.
- cuda-nvcc
- libcufft-dev
# Use conda-forge channel libraries.
- cuda-version {{ cuda_version }}
- python # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- numpy >=2.0 # [build_platform != target_platform]
Expand All @@ -38,15 +46,18 @@ requirements:
host:
- python
- pip >=22.0
# Use Conda-provided libraries.
# Use conda-forge channel libraries.
- cuda-version {{ cuda_version }}
- gsl >=2.7
- libcufft
- libgomp # [linux]
- setuptools >=61.0
- setuptools_scm >=6.4
- cython >=3.0
- extension-helpers >=1.1
- numpy >=2.0
run:
- {{ pin_compatible('cuda-version', min_pin='x', max_pin='x.x') }}
- python >=3.10
- numpy >=1.23
- scipy >=1.13
Expand Down

0 comments on commit 9595fc8

Please sign in to comment.