Skip to content

Commit f49a6cc

Browse files
authored
Merge pull request #224 from TomographicImaging/rocky8
2 parents 84ec692 + e45e49e commit f49a6cc

8 files changed

Lines changed: 178 additions & 27 deletions

File tree

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ps1 text eol=crlf

‎.github/workflows/build.yml‎

Lines changed: 79 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@ jobs:
77
runs-on: [self-hosted, python, cuda]
88
strategy: {matrix: {cuda-version: [12]}}
99
steps:
10-
- uses: actions/checkout@v6
10+
- uses: actions/checkout@v7
1111
with: {fetch-depth: 0, submodules: recursive}
12-
- uses: prefix-dev/rattler-build-action@v0.2.38 # https://github.com/prefix-dev/rattler-build/pull/2484
12+
- uses: prefix-dev/rattler-build-action@v0.2.39
1313
with:
14-
recipe-path: recipe.yaml
14+
recipe-path: conda/recipe.yaml
15+
rattler-build-version: v0.80.0
1516
build-args: --experimental --variant cuda_version_major=${{ matrix.cuda-version }}
1617
env:
1718
TESTS_FORCE_GPU: "1"
1819
test:
19-
runs-on: ${{ matrix.os }}-${{ matrix.os == 'ubuntu' && '22.04' || 'latest' }}
20+
runs-on: ${{ matrix.os }}-latest
2021
strategy:
2122
matrix:
2223
python-version: ['3.10', '3.x'] # min & max supported
2324
os: [ubuntu, windows]
2425
steps:
25-
- uses: actions/checkout@v6
26+
- uses: actions/checkout@v7
2627
with: {fetch-depth: 0, submodules: recursive}
27-
- uses: actions/setup-python@v6
28+
- uses: actions/setup-python@v7
2829
with:
2930
python-version: ${{ matrix.python-version }}
3031
- name: build
@@ -36,29 +37,91 @@ jobs:
3637
run: python -m unittest discover -v -s ./test
3738
env: {PYTHONPATH: ./src/Python}
3839
conda-build:
39-
runs-on: ${{ matrix.os }}-${{ matrix.os == 'ubuntu' && '22.04' || 'latest' }}
40+
runs-on: ${{ matrix.os }}-latest
41+
defaults: {run: {shell: 'bash -el {0}'}}
4042
strategy:
4143
matrix:
4244
os: [ubuntu, windows]
4345
cuda-version: [None, 12, 13]
46+
env:
47+
CCACHE_DIR: ${{ github.workspace }}/.ccache
48+
CCACHE_MAXSIZE: 100M
49+
CHANNELS: -c conda-forge -c ccpi
4450
steps:
45-
- uses: actions/checkout@v6
51+
- uses: actions/checkout@v7
4652
with: {fetch-depth: 0, submodules: recursive}
47-
- if: matrix.os == 'windows' && matrix.cuda-version == 'None'
48-
uses: ilammy/msvc-dev-cmd@v1
49-
- uses: prefix-dev/rattler-build-action@v0.2.38 # https://github.com/prefix-dev/rattler-build/pull/2484
53+
- name: Cache ccache
54+
uses: actions/cache@v6
5055
with:
51-
recipe-path: recipe.yaml
52-
build-args: --experimental --variant cuda_version_major=${{ matrix.cuda-version }} ${{ matrix.cuda-version == 'None' && ' ' || '--no-test' }}
53-
artifact-name: conda-${{ matrix.os }}-${{ matrix.cuda-version }}
56+
path: ${{ env.CCACHE_DIR }}
57+
key: ccache-${{ runner.os }}-cu${{ matrix.cuda-version }}-${{ hashFiles('conda/recipe.yaml', 'conda/variants.yaml') }}
58+
restore-keys: ccache-${{ runner.os }}-cu${{ matrix.cuda-version }}-
59+
- name: config
60+
id: config
61+
run: |
62+
# avoid "hardlink different from source"
63+
git config --global core.commitGraph false
64+
case ${{ matrix.os }} in
65+
windows)
66+
echo target=win-64 >> $GITHUB_OUTPUT
67+
;;
68+
*)
69+
echo target=linux-64 >> $GITHUB_OUTPUT
70+
;;
71+
esac
72+
- uses: prefix-dev/rattler-build-action@v0.2.39
73+
with:
74+
recipe-path: conda/recipe.yaml
75+
rattler-build-version: v0.80.0
76+
# --no-build-id: required for ccache
77+
build-args: >
78+
--experimental --target-platform ${{ steps.config.outputs.target }}
79+
-c conda-forge -c ccpi
80+
--test skip --variant cuda_version_major=${{ matrix.cuda-version }}
81+
--no-build-id
82+
artifact-name: conda-${{ steps.config.outputs.target }}-${{ matrix.cuda-version }}
83+
- if: startsWith(matrix.os, 'ubuntu')
84+
name: check glibc support
85+
env:
86+
GLIBC_MAX: '2.28' # see recipe.yaml
87+
run: |
88+
set -euo pipefail
89+
d=$(mktemp -d)
90+
unzip -q output/linux-64/*.conda 'pkg-*' -d "$d"
91+
tar --zstd -xf "$d"/pkg-*.tar.zst -C "$d"
92+
max=$(find "$d" -name '*.so' -type f -exec objdump -T {} + | grep -oE 'GLIBC_[0-9.]+' | sort -Vu | tail -1 || true)
93+
[[ -n "$max" ]] || { echo "FAIL: no GLIBC symbols found in package" >&2; exit 1; }
94+
echo "expected max glibc symbol: GLIBC_${GLIBC_MAX} ; found: $max"
95+
if [[ $(printf '%s\n%s\n' "$GLIBC_MAX" "${max#GLIBC_}" | sort -V | tail -1) != "$GLIBC_MAX" ]] ; then
96+
echo "FAIL: $max > GLIBC_${GLIBC_MAX}" >&2
97+
exit 1
98+
fi
99+
- if: matrix.cuda-version == 'None'
100+
name: test
101+
env:
102+
TMPDIR: ${{ github.workspace }}/.tmp-rattler
103+
run: |
104+
mkdir -p "$TMPDIR"
105+
for pkg in output/*/*.conda; do
106+
echo "::group::$(basename $pkg)"
107+
rattler-build test -p "$pkg" -c ./output $CHANNELS
108+
echo "::endgroup::"
109+
done
110+
- if: failure()
111+
name: Upload debug build logs
112+
uses: actions/upload-artifact@v7
113+
with:
114+
name: conda-build-logs-cu${{ matrix.cuda-version }}-${{ matrix.os }}
115+
path: output/bld
116+
retention-days: 7
54117
conda-upload:
55118
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')
56119
defaults: {run: {working-directory: output}}
57120
runs-on: ubuntu-slim
58121
needs: conda-build
59122
steps:
60-
- uses: actions/checkout@v6
61-
- uses: prefix-dev/rattler-build-action@v0.2.37
123+
- uses: actions/checkout@v7
124+
- uses: prefix-dev/rattler-build-action@v0.2.39
62125
with: {setup-only: true}
63126
- uses: actions/download-artifact@v8
64127
with: {pattern: conda-*, path: output, merge-multiple: true}

‎Installation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Python binaries are distributed via the [`ccpi`](https://anaconda.org/ccpi/ccpi-
4646
#### Python (rattler-build)
4747

4848
```sh
49-
rattler-build build --experimental
49+
rattler-build build -r conda --experimental
5050
conda install ccpi-regulariser=*=cuda* -c output -c conda-forge
5151
cd demos/
5252
python demo_cpu_regularisers.py # to run CPU demo

‎conda/README.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ccpi-regulariser conda package
2+
3+
## prerequisites
4+
5+
```sh
6+
conda install conda-forge::rattler-build
7+
git clone https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit
8+
cd CCPi-Regularisation-Toolkit
9+
```
10+
11+
## rattler-build (with ccache)
12+
13+
- Platforms: `linux-64`, `win-64`
14+
- CUDA: `None` (CPU), `12`, `13`
15+
16+
See the top of [recipe.yaml](./recipe.yaml) for invocation.
17+
18+
## install
19+
20+
```sh
21+
rattler-build publish output/*64/*.conda --to ./channel
22+
# install in env
23+
conda create -n ccpi python -c file://$PWD/channel -c conda-forge -c ccpi ccpi-regulariser
24+
conda activate ccpi
25+
```
26+
27+
## Notes
28+
29+
- `-c channel` order matters
30+
- `-v` for verbose build output
31+
- disable ccache:
32+
```sh
33+
CMAKE_C_COMPILER_LAUNCHER="" CMAKE_CXX_COMPILER_LAUNCHER="" CMAKE_CUDA_COMPILER_LAUNCHER="" rattler-build ...
34+
```

recipe.yaml renamed to conda/recipe.yaml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
schema_version: 1
22

3+
# Usage:
4+
# rattler-build build -r conda -c conda-forge -c ccpi --experimental
5+
# [--no-build-id] [--test skip] [--variant cuda_version_major={None,12,13}] [--target-platform {linux-64,win-64}]
6+
#
7+
# Example (CPU, no tests):
8+
# rattler-build build -r conda -c conda-forge -c ccpi --experimental --no-build-id --test skip --variant cuda_version_major=None
9+
#
10+
# Notes:
11+
# - --experimental: load_from_file & git.latest_tag_distance
12+
# - --no-build-id: needed for ccache (env defaults CCACHE_DIR='', CCACHE_MAXSIZE=5G)
13+
314
context:
4-
# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#loading-data-from-other-files
5-
project: ${{ load_from_file("src/Python/pyproject.toml").project }} # ratter-build --experimental
15+
project: ${{ load_from_file("../src/Python/pyproject.toml").project }}
616
python_min: "3.10"
7-
git_number: ${{ git.latest_tag_distance(".") | int }} # ratter-build>=0.65 --experimental
17+
git_number: ${{ git.latest_tag_distance("..") | int }}
818
build_number: ${{ git_number + (0 if cuda_version_major == "None" else 200) }}
919
test_gpu: ${{ env.get("TESTS_FORCE_GPU", default="") | bool }}
20+
ccache_dir: ${{ env.get("CCACHE_DIR", default="") }}
21+
ccache_maxsize: ${{ env.get("CCACHE_MAXSIZE", default="5G") }}
22+
ccache_c: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER", default="ccache") }}
23+
ccache_cxx: ${{ env.get("CMAKE_CXX_COMPILER_LAUNCHER", default="ccache") }}
24+
ccache_cuda: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER", default="ccache") }}
1025

1126
package:
1227
name: ${{ project.name }}
1328
version: ${{ project.version }}
1429

1530
source:
16-
path: .
31+
path: ..
1732

1833
build:
1934
number: ${{ build_number }}
@@ -23,6 +38,8 @@ build:
2338
# TODO: use scikit-build-core & setuptools_scm instead
2439
- if: win
2540
then:
41+
# fix conda-forge::cuda-cccl win-64 cmake config headers
42+
- powershell -NoProfile -File "%RECIPE_DIR%\win-cccl-fix.ps1"
2643
- cmake -S . %CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX=%SRC_DIR%\src\Python\ccpi\filters\ %CMAKE_EXTRA_ARGS%
2744
- cmake --build . --target install --config RelWithDebInfo
2845
- pip install -vv %SRC_DIR%\src\Python --prefix=%PREFIX%
@@ -31,19 +48,28 @@ build:
3148
- cmake --build . --target install
3249
- pip install -vv $SRC_DIR/src/Python --prefix=$PREFIX
3350
env:
34-
CMAKE_EXTRA_ARGS: -DBUILD_PYTHON_WRAPPERS=ON -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CUDA=${{ "OFF" if cuda_version_major == "None" else "ON" }}
51+
CMAKE_EXTRA_ARGS: -DBUILD_PYTHON_WRAPPER=ON -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CUDA=${{ "OFF" if cuda_version_major == "None" else "ON" }}
52+
CMAKE_C_COMPILER_LAUNCHER: ${{ ccache_c }}
53+
CMAKE_CXX_COMPILER_LAUNCHER: ${{ ccache_cxx }}
54+
CMAKE_CUDA_COMPILER_LAUNCHER: ${{ ccache_cuda }}
55+
CCACHE_DIR: ${{ ccache_dir }}
56+
CCACHE_MAXSIZE: ${{ ccache_maxsize }}
3557
python:
3658
version_independent: true
3759

3860
requirements:
3961
build:
62+
- ccache
4063
- cmake
4164
- ninja
4265
- ${{ compiler('cxx') }}
66+
# pin minimum supported glibc ~=2.28 (RHEL/Rocky 8+)
67+
- if: linux
68+
then: sysroot_linux-64 2.28.*
4369
- if: cuda_version_major != "None"
4470
then:
4571
- cuda-version ${{ cuda_version_major }}.*
46-
- cuda-nvcc
72+
- ${{ compiler('cuda') }}
4773
host:
4874
- python ${{ python_min }}.*
4975
- if: linux

‎conda/variants.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cuda_version_major:
2+
- None
3+
- 12
4+
- 13
5+
# conda-forge CUDA compiler package (see cuda-feedstock); makes compiler('cuda')
6+
# resolve to cuda-nvcc_linux-64 instead of the dead cuda_linux-64 metapackage.
7+
cuda_compiler:
8+
- cuda-nvcc

‎conda/win-cccl-fix.ps1‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# work-around conda-forge::cuda-cccl win-64 packaging bug:
2+
# copy Library\include\targets\x64\ to Library\lib\include{,\cccl}
3+
# so {thrust,cub,libcudacxx}-header-search.cmake finds headers
4+
$ErrorActionPreference = "Stop"
5+
$src = Join-Path $env:PREFIX "Library\include\targets\x64"
6+
$dst = Join-Path $env:PREFIX "Library\lib\include"
7+
if (Test-Path $src) {
8+
foreach ($d in Get-ChildItem $src -Directory) {
9+
$t = Join-Path $dst $d.Name
10+
if (-not (Test-Path $t)) {
11+
Copy-Item -Recurse $d.FullName $t
12+
Write-Host "cccl-fix: copied $($d.Name) -> $t"
13+
}
14+
}
15+
$v12 = Join-Path $dst "thrust\version.h"
16+
$v13 = Join-Path $dst "cccl\thrust\version.h"
17+
if (-not (Test-Path $v12) -and -not (Test-Path $v13)) {
18+
throw "cccl-fix: thrust\version.h not found under $dst after copy"
19+
}
20+
Write-Host "cccl-fix: headers in place at $dst"
21+
} else {
22+
Write-Host "cccl-fix: no $src (nothing to do)"
23+
}

‎variants.yaml‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)