From e5fae8ec3445e1def162b8ef1a0659a43c6b9062 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 9 Oct 2025 15:12:01 +0100 Subject: [PATCH 01/23] bump numpy, python versions - fixes #215 --- .github/workflows/build.yml | 28 +++++++++++++--------------- recipe/conda_build_config.yaml | 21 +-------------------- recipe/meta.yaml | 20 +++++++++----------- 3 files changed, 23 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 912d3a6..a957c3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,6 @@ name: build on: - release: - types: [published] + release: {types: [published]} push: branches: [master] tags: ['**'] @@ -13,8 +12,8 @@ jobs: runs-on: [self-hosted, python, cuda] strategy: matrix: - python-version: [3.11] - numpy-version: [1.25] + python-version: [3.12] + numpy-version: [1.26] steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -35,11 +34,11 @@ jobs: which cmake || conda install -yq cmake cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install - pip install ./src/Python + pip install ./src/Python numpy==${{ numpy-version }} - name: test run: | conda activate "${{ steps.reqs.outputs.envname }}" - PYTHONPATH=./src/Python python -m unittest discover ./test + PYTHONPATH=./src/Python python -m unittest discover -v -s ./test - if: always() name: Post Run conda-incubator/setup-miniconda@v3 shell: bash @@ -52,12 +51,12 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.10', 3.11] - numpy-version: [1.23, 1.26] + python-version: ['3.10', 3.12] + numpy-version: [2.*] os: [ubuntu-latest, windows-latest] include: - - python-version: 3.12 # needs numpy>=1.26 - numpy-version: 1.26 + - python-version: '3.10' + numpy-version: 1.23 os: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -69,16 +68,15 @@ jobs: run: | cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install - pip install ./src/Python + pip install ./src/Python numpy==${{ numpy-version }} - name: test - run: PYTHONPATH=./src/Python python -m unittest discover ./test + run: PYTHONPATH=./src/Python python -m unittest discover -v -s ./test conda: defaults: {run: {shell: 'bash -el {0}'}} runs-on: ubuntu-latest strategy: matrix: - python-version: [3.11] # penultimate supported - numpy-version: [1.25] + python-version: ['3.10', 3.11, 3.12, 3.13] # penultimate supported steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -91,7 +89,7 @@ jobs: working-directory: recipe run: | conda install boa - conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --numpy=${{ matrix.numpy-version }} --output-folder . + conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder . - name: Upload artifact of the conda package uses: actions/upload-artifact@v4 with: diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index 3124e35..9ad4bc7 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -1,24 +1,5 @@ -#creates pairs of versions using zip_keys, lists must be the same length python: - 3.10 - - 3.10 - - 3.10 - - 3.10 - - 3.11 - - 3.11 - - 3.11 - 3.11 - 3.12 -numpy: - - 1.23 - - 1.24 - - 1.25 - - 1.26 - - 1.23 - - 1.24 - - 1.25 - - 1.26 - - 1.26 -zip_keys: - - python - - numpy + - 3.13 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 8347dcc..c80c102 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -16,24 +16,22 @@ test: source_files: - ./test/ commands: - - python -c "import os; print (os.getcwd())" - - python -m unittest discover -s test + - python -m unittest discover -v -s test requirements: build: - - python - - numpy {{ numpy }} + - cmake + - ninja + - {{ compiler('cxx') }} + + host: + - python x.x - setuptools - pip - - vc 14 # [win] - - cmake run: - - {{ pin_compatible('numpy', min_pin='x.x', max_pin='x.x') }} - - python - - vc 14 # [win] - - libgcc-ng # [unix] + - numpy about: - home: https://tomographicimaging.github.io/CIL/ + home: https://TomographicImaging.github.io/CIL license: Apache-2.0 summary: 'The set of CPU/GPU optimised regularisation modules for iterative image reconstruction and other image processing tasks' From ebd12d1b1be33323e84462778496874ce34e35dc Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 9 Oct 2025 15:24:33 +0100 Subject: [PATCH 02/23] fix build --- .github/workflows/build.yml | 5 +- build/FindAnacondaEnvironment.cmake | 154 ---------------------------- build/build-install.sh | 4 - build/jenkins-build.sh | 2 - build/run.sh | 28 ----- recipe/bld.bat | 8 +- recipe/build.sh | 7 +- 7 files changed, 11 insertions(+), 197 deletions(-) delete mode 100644 build/FindAnacondaEnvironment.cmake delete mode 100755 build/build-install.sh delete mode 100755 build/jenkins-build.sh delete mode 100755 build/run.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a957c3a..e5f65a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,15 +86,14 @@ jobs: mamba-version: "*" channels: conda-forge - name: conda build & test - working-directory: recipe run: | conda install boa - conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder . + conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist - name: Upload artifact of the conda package uses: actions/upload-artifact@v4 with: name: ccpi-regulariser-package - path: recipe/linux-64/ccpi-regulariser* + path: dist/linux-64/ccpi-regulariser* pass: needs: [test-cuda, test, conda] runs-on: ubuntu-latest diff --git a/build/FindAnacondaEnvironment.cmake b/build/FindAnacondaEnvironment.cmake deleted file mode 100644 index 6475128..0000000 --- a/build/FindAnacondaEnvironment.cmake +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright 2017 Edoardo Pasca -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# #.rst: -# FindAnacondaEnvironment -# -------------- -# -# Find Python executable and library for a specific Anaconda environment -# -# This module finds the Python interpreter for a specific Anaconda enviroment, -# if installed and determines where the include files and libraries are. -# This code sets the following variables: -# -# :: -# PYTHONINTERP_FOUND - if the Python interpret has been found -# PYTHON_EXECUTABLE - the Python interpret found -# PYTHON_LIBRARY - path to the python library -# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) -# PYTHON_INCLUDE_DIRS - path to where Python.h is found -# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) -# PYTHON_VERSION_MAJOR - major Python version -# PYTHON_VERSION_MINOR - minor Python version -# PYTHON_VERSION_PATCH - patch Python version - - - -function (findPythonForAnacondaEnvironment env) - if (WIN32) - file(TO_CMAKE_PATH ${env}/python.exe PYTHON_EXECUTABLE) - elseif (UNIX) - file(TO_CMAKE_PATH ${env}/bin/python PYTHON_EXECUTABLE) - endif() - - - message("findPythonForAnacondaEnvironment Found Python Executable" ${PYTHON_EXECUTABLE}) - ####### FROM FindPythonInterpr ######## - # determine python version string - if(PYTHON_EXECUTABLE) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c - "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" - OUTPUT_VARIABLE _VERSION - RESULT_VARIABLE _PYTHON_VERSION_RESULT - ERROR_QUIET) - if(NOT _PYTHON_VERSION_RESULT) - string(REPLACE ";" "." _PYTHON_VERSION_STRING "${_VERSION}") - list(GET _VERSION 0 _PYTHON_VERSION_MAJOR) - list(GET _VERSION 1 _PYTHON_VERSION_MINOR) - list(GET _VERSION 2 _PYTHON_VERSION_PATCH) - if(PYTHON_VERSION_PATCH EQUAL 0) - # it's called "Python 2.7", not "2.7.0" - string(REGEX REPLACE "\\.0$" "" _PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}") - endif() - else() - # sys.version predates sys.version_info, so use that - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" - OUTPUT_VARIABLE _VERSION - RESULT_VARIABLE _PYTHON_VERSION_RESULT - ERROR_QUIET) - if(NOT _PYTHON_VERSION_RESULT) - string(REGEX REPLACE " .*" "" _PYTHON_VERSION_STRING "${_VERSION}") - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" _PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" _PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") - if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)") - set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}") - else() - set(PYTHON_VERSION_PATCH "0") - endif() - else() - # sys.version was first documented for Python 1.5, so assume - # this is older. - set(PYTHON_VERSION_STRING "1.4" PARENT_SCOPE) - set(PYTHON_VERSION_MAJOR "1" PARENT_SCOPE) - set(PYTHON_VERSION_MINOR "4" PARENT_SCOPE) - set(PYTHON_VERSION_PATCH "0" PARENT_SCOPE) - endif() - endif() - unset(_PYTHON_VERSION_RESULT) - unset(_VERSION) - endif() - ############################################### - - set (PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE) - set (PYTHONINTERP_FOUND "ON" PARENT_SCOPE) - set (PYTHON_VERSION_STRING ${_PYTHON_VERSION_STRING} PARENT_SCOPE) - set (PYTHON_VERSION_MAJOR ${_PYTHON_VERSION_MAJOR} PARENT_SCOPE) - set (PYTHON_VERSION_MINOR ${_PYTHON_VERSION_MINOR} PARENT_SCOPE) - set (PYTHON_VERSION_PATCH ${_PYTHON_VERSION_PATCH} PARENT_SCOPE) - message("My version found " ${PYTHON_VERSION_STRING}) - ## find conda executable - if (WIN32) - set (CONDA_EXECUTABLE ${env}/Script/conda PARENT_SCOPE) - elseif(UNIX) - set (CONDA_EXECUTABLE ${env}/bin/conda PARENT_SCOPE) - endif() -endfunction() - - - -set(Python_ADDITIONAL_VERSIONS 3.5) - -find_package(PythonInterp) -if (PYTHONINTERP_FOUND) - - message("Found interpret " ${PYTHON_EXECUTABLE}) - message("Python Library " ${PYTHON_LIBRARY}) - message("Python Include Dir " ${PYTHON_INCLUDE_DIR}) - message("Python Include Path " ${PYTHON_INCLUDE_PATH}) - - foreach(pv ${PYTHON_VERSION_STRING}) - message("Found interpret " ${pv}) - endforeach() -endif() - - - -find_package(PythonLibs) -if (PYTHONLIB_FOUND) - message("Found PythonLibs PYTHON_LIBRARIES " ${PYTHON_LIBRARIES}) - message("Found PythonLibs PYTHON_INCLUDE_PATH " ${PYTHON_INCLUDE_PATH}) - message("Found PythonLibs PYTHON_INCLUDE_DIRS " ${PYTHON_INCLUDE_DIRS}) - message("Found PythonLibs PYTHONLIBS_VERSION_STRING " ${PYTHONLIBS_VERSION_STRING} ) -else() - message("No PythonLibs Found") -endif() - - - - -function(findPythonPackagesPath) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print (get_python_lib())" - RESULT_VARIABLE PYTHON_CVPY_PROCESS - OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE) - #message("STD_PACKAGES " ${PYTHON_STD_PACKAGES_PATH}) - if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages") - set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/site-packages") - endif() - - SET(PYTHON_PACKAGES_PATH "${PYTHON_STD_PACKAGES_PATH}" PARENT_SCOPE) - -endfunction() - - diff --git a/build/build-install.sh b/build/build-install.sh deleted file mode 100755 index def66a4..0000000 --- a/build/build-install.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -export CCPI_BUILD_ARGS="--numpy 1.12 --python 3.6" -bash <(curl -L https://raw.githubusercontent.com/vais-ral/CCPi-VirtualMachine/master/scripts/jenkins-build.sh) -conda install -y ccpi-regulariser --use-local --force \ No newline at end of file diff --git a/build/jenkins-build.sh b/build/jenkins-build.sh deleted file mode 100755 index 5b6c9ce..0000000 --- a/build/jenkins-build.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -bash <(curl -L https://raw.githubusercontent.com/vais-ral/CCPi-VirtualMachine/master/scripts/jenkins-build.sh) diff --git a/build/run.sh b/build/run.sh deleted file mode 100755 index ef96e7d..0000000 --- a/build/run.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -echo "Building CCPi-regularisation Toolkit using CMake" -rm -r ../build_proj -# Requires Cython, install it first: -# pip install cython -mkdir ../build_proj -cd ../build_proj/ -#make clean -# install Python modules without CUDA -#cmake ../ -DBUILD_PYTHON_WRAPPER=ON -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -# install Python modules with CUDA -cmake ../ -DBUILD_PYTHON_WRAPPER=ON -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -# install Matlab modules without CUDA -# cmake ../ -DBUILD_PYTHON_WRAPPER=OFF -DMatlab_ROOT_DIR=/home/algol/SOFT/MATLAB9/ -DBUILD_MATLAB_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -# install Matlab modules with CUDA -# cmake ../ -DBUILD_PYTHON_WRAPPER=OFF -DMatlab_ROOT_DIR=/dls_sw/apps/matlab/r2014a/ -DBUILD_MATLAB_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -# cmake ../ -DBUILD_PYTHON_WRAPPER=OFF -DMatlab_ROOT_DIR=/home/algol/SOFT/MATLAB9/ -DBUILD_MATLAB_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install -make install -############### Python(linux)############### -cp install/lib/libcilreg.so install/python/ccpi/filters -cd install/python -export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib -spyder --new-instance -############### Matlab(linux)############### -# export LD_PRELOAD=/home/algol/anaconda3/lib/libstdc++.so.6 # if there is libstdc error in matlab -# PATH="/path/to/mex/:$PATH" LD_LIBRARY_PATH="/path/to/library:$LD_LIBRARY_PATH" matlab -# PATH="/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/build_proj/install/matlab/:$PATH" LD_LIBRARY_PATH="/home/kjy41806/Documents/SOFT/CCPi-Regularisation-Toolkit/build_proj/install/lib:$LD_LIBRARY_PATH" matlab -#PATH="/home/algol/Documents/DEV/CCPi-Regularisation-Toolkit/build_proj/install/matlab/:$PATH" LD_LIBRARY_PATH="/home/algol/Documents/DEV/CCPi-Regularisation-Toolkit/build_proj/install/lib:$LD_LIBRARY_PATH" /home/algol/SOFT/MATLAB9/bin/matlab diff --git a/recipe/bld.bat b/recipe/bld.bat index cd2244f..ab89783 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -1,15 +1,15 @@ mkdir "%SRC_DIR%\test" ROBOCOPY /E "%RECIPE_DIR%\..\test" "%SRC_DIR%\test" -if exist "%RECIPE_DIR%\..\build_proj" ( - rd /s /q "%RECIPE_DIR%\..\build_proj" +if exist "%SRC_DIR%\build_proj" ( + rd /s /q "%SRC_DIR%\build_proj" ) :: -G "Visual Studio 16 2019" specifies the the generator :: -T v142 specifies the toolset :: -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" to the cmake command to specify the CUDA toolkit version -cmake -S "%SRC_DIR%" -B "%RECIPE_DIR%\..\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%RECIPE_DIR%\..\install" -cmake --build "%RECIPE_DIR%\..\build_proj" --target install --config RelWithDebInfo +cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" +cmake --build "%SRC_DIR%\build_proj" --target install --config RelWithDebInfo %PYTHON% -m pip install "%SRC_DIR%\src\Python" if errorlevel 1 exit 1 diff --git a/recipe/build.sh b/recipe/build.sh index 0fedbe2..c64a2ce 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -1,6 +1,9 @@ set -xe cp -rv "$RECIPE_DIR/../test" "$SRC_DIR/" +if test -d "$SRC_DIR/build_proj"; then + rm -rf "$SRC_DIR/build_proj" +fi -cmake -S "$SRC_DIR" -B "$RECIPE_DIR/../build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX="$RECIPE_DIR/../install" -cmake --build "$RECIPE_DIR/../build_proj" --target install +cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" +cmake --build "$SRC_DIR/build_proj" --target install $PYTHON -m pip install "$SRC_DIR/src/Python" From 0a4b570cc98144d4555209928034ef9660a1e12b Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 9 Oct 2025 15:49:53 +0100 Subject: [PATCH 03/23] fix cuda build --- .gitignore | 1 + recipe/bld.bat | 2 +- recipe/build.sh | 2 +- recipe/conda_build_config.yaml | 2 ++ recipe/meta.yaml | 19 +++++++++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5b4def3..43a5761 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build_proj/ /install/ +/dist/ __pycache__/ /src/Python/build/ /src/Python/*.egg*/ diff --git a/recipe/bld.bat b/recipe/bld.bat index ab89783..db8b66a 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -8,7 +8,7 @@ if exist "%SRC_DIR%\build_proj" ( :: -T v142 specifies the toolset :: -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" to the cmake command to specify the CUDA toolkit version -cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" +cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" cmake --build "%SRC_DIR%\build_proj" --target install --config RelWithDebInfo %PYTHON% -m pip install "%SRC_DIR%\src\Python" diff --git a/recipe/build.sh b/recipe/build.sh index c64a2ce..5cf5b9b 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -4,6 +4,6 @@ if test -d "$SRC_DIR/build_proj"; then rm -rf "$SRC_DIR/build_proj" fi -cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" +cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" cmake --build "$SRC_DIR/build_proj" --target install $PYTHON -m pip install "$SRC_DIR/src/Python" diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index 9ad4bc7..dba3534 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -3,3 +3,5 @@ python: - 3.11 - 3.12 - 3.13 +cuda_compiler_version: + - 11.8 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index c80c102..cad62a4 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -8,6 +8,16 @@ package: build: preserve_egg_dir: False number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} + ignore_run_exports_from: + {% if cuda_compiler_version != '0' %} + - {{ compiler('cuda') }} + {% endif %} + script_env: + {% if cuda_compiler_version != '0' %} + - BUILD_CUDA=ON + {% else %} + - BUILD_CUDA=OFF + {% endif %} source: path: .. @@ -22,14 +32,23 @@ requirements: - cmake - ninja - {{ compiler('cxx') }} + {% if cuda_compiler_version != '0' %} + - {{ compiler('cuda') }} + {% endif %} host: - python x.x - setuptools - pip + {% if cuda_compiler_version != '0' %} + - cuda-version {{ cuda_compiler_version }} + {% endif %} run: - numpy + {% if cuda_compiler_version != '0' %} + - {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }} + {% endif %} about: home: https://TomographicImaging.github.io/CIL From 1ca75413208d319bc1103ac63aba886a2a764390 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 9 Oct 2025 22:34:31 +0100 Subject: [PATCH 04/23] try fix cuda again --- recipe/bld.bat | 2 +- recipe/build.sh | 2 +- recipe/conda_build_config.yaml | 1 + recipe/meta.yaml | 45 +++++++++++++++++++--------------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/recipe/bld.bat b/recipe/bld.bat index db8b66a..8ebeb87 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -10,6 +10,6 @@ if exist "%SRC_DIR%\build_proj" ( cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" cmake --build "%SRC_DIR%\build_proj" --target install --config RelWithDebInfo -%PYTHON% -m pip install "%SRC_DIR%\src\Python" +%PYTHON% -m pip install -vv "%SRC_DIR%\src\Python" if errorlevel 1 exit 1 diff --git a/recipe/build.sh b/recipe/build.sh index 5cf5b9b..e2cfb37 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -6,4 +6,4 @@ fi cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" cmake --build "$SRC_DIR/build_proj" --target install -$PYTHON -m pip install "$SRC_DIR/src/Python" +$PYTHON -m pip install -vv "$SRC_DIR/src/Python" diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index dba3534..f3fa8f4 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -4,4 +4,5 @@ python: - 3.12 - 3.13 cuda_compiler_version: + - None - 11.8 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index cad62a4..d0ea37f 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,23 +1,31 @@ # https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#loading-data-from-other-files # TODO: use scikit-build-core & setuptools_scm instead {% set project = load_file_data('../src/Python/pyproject.toml', from_recipe_dir=True).get('project', {}) %} +{% set build_number = environ.get('GIT_DESCRIBE_NUMBER', 0) | int %} +{% if cuda_compiler_version != "None" %} +{% set build_number = build_number + 200 %} +{% endif %} + package: name: {{ project.get('name') }} version: {{ project.get('version') }} build: preserve_egg_dir: False - number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} + number: {{ build_number }} + run_exports: + - {{ pin_subpackage(project.get('name'), max_pin='x.x') }} + - {{ project.get('name') }} =*=cuda* # [cuda_compiler_version != "None"] + - {{ project.get('name') }} =*=cpu* # [cuda_compiler_version == "None"] + ignore_run_exports: + - cudatoolkit # [(cuda_compiler_version or "None").startswith("11")] ignore_run_exports_from: - {% if cuda_compiler_version != '0' %} - - {{ compiler('cuda') }} - {% endif %} + - {{ compiler('cuda') }} # [cuda_compiler_version != "None"] script_env: - {% if cuda_compiler_version != '0' %} - - BUILD_CUDA=ON - {% else %} - - BUILD_CUDA=OFF - {% endif %} + - BUILD_CUDA=ON # [cuda_compiler_version != "None"] + - BUILD_CUDA=OFF # [cuda_compiler_version == "None"] + string: cuda{{ cuda_compiler_version | replace('.', '') }}_h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version != "None"] + string: cpu_h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda_compiler_version == "None"] source: path: .. @@ -31,24 +39,21 @@ requirements: build: - cmake - ninja + - python # [build_platform != target_platform] - {{ compiler('cxx') }} - {% if cuda_compiler_version != '0' %} - - {{ compiler('cuda') }} - {% endif %} - + - {{ compiler('cuda') }} # [cuda_compiler_version != "None"] host: - python x.x + - libgomp # [linux] + - llvm-openmp # [osx] - setuptools - pip - {% if cuda_compiler_version != '0' %} - - cuda-version {{ cuda_compiler_version }} - {% endif %} - + - cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"] run: + - {{ pin_compatible('python', min_pin='x.x') }} - numpy - {% if cuda_compiler_version != '0' %} - - {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }} - {% endif %} + - __cuda # [cuda_compiler_version != "None"] + - {{ pin_compatible('cuda-version', min_pin='x') }} # [cuda_compiler_version != "None"] about: home: https://TomographicImaging.github.io/CIL From 4379298e4b5d128f999623f2180d593ae2e2ac42 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 18:19:06 +0100 Subject: [PATCH 05/23] cmake: modernise cuda, add NCCL --- recipe/meta.yaml | 1 + src/Core/CMakeLists.txt | 78 +++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index d0ea37f..0ee50ae 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -48,6 +48,7 @@ requirements: - llvm-openmp # [osx] - setuptools - pip + - cuda-cccl # [cuda_compiler_version != "None"] - cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"] run: - {{ pin_compatible('python', min_pin='x.x') }} diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index b694766..953f794 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -61,40 +61,50 @@ endif() # GPU Regularisers if (BUILD_CUDA) - find_package(CUDA) - if (CUDA_FOUND) - if (UNIX) - set(CUDA_NVCC_FLAGS "-Xcompiler -fPIC -shared -D_FORCE_INLINES") - endif() - message(STATUS "CUDA_NVCC_FLAGS: ${CUDA_NVCC_FLAGS}") - CUDA_ADD_LIBRARY(cilregcuda SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_ROF_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_FGP_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_PD_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_SB_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/LLT_ROF_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TGV_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/dTV_FGP_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/NonlDiff_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/Diffus_4thO_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/PatchSelect_GPU_core.cu - ) - message(STATUS "Installing in ${CMAKE_INSTALL_PREFIX}") - if (UNIX) - install(TARGETS cilregcuda - LIBRARY DESTINATION . - CONFIGURATIONS ${CMAKE_BUILD_TYPE} - ) - elseif(WIN32) - install(TARGETS cilregcuda - RUNTIME DESTINATION bin - ARCHIVE DESTINATION . - CONFIGURATIONS ${CMAKE_BUILD_TYPE} - ) - endif() - else() - message(WARNING "CUDA NOT FOUND") - endif() + find_package(CUDAToolkit REQUIRED) + enable_language(CUDA) + + # CCCL (for thrust), vis. https://github.com/NVIDIA/cccl/tree/main/examples/basic#downloading-cpm + set(CPM_DOWNLOAD_VERSION 0.34.0) + if(CPM_SOURCE_CACHE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") + endif() + if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION}) + endif() + include(${CPM_DOWNLOAD_LOCATION}) + CPMAddPackage(NAME CCCL GITHUB_REPOSITORY nvidia/cccl GIT_TAG main) + + if (UNIX) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fPIC -shared -D_FORCE_INLINES") + endif() + message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}") + add_library(cilregcuda SHARED + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_ROF_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_FGP_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_PD_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_SB_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/LLT_ROF_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TGV_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/dTV_FGP_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/NonlDiff_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/Diffus_4thO_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/PatchSelect_GPU_core.cu + ) + target_link_libraries(cilregcuda PUBLIC CUDA::cudart PRIVATE CCCL::CCCL) + message(STATUS "Installing in ${CMAKE_INSTALL_PREFIX}") + install(TARGETS cilregcuda + LIBRARY DESTINATION . + RUNTIME DESTINATION bin + ARCHIVE DESTINATION . + CONFIGURATIONS ${CMAKE_BUILD_TYPE}) endif() if (${BUILD_MATLAB_WRAPPER}) From 4b9734d3f1bb5e53229ab615d1e7c5e80fcf10f7 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 18:20:07 +0100 Subject: [PATCH 06/23] fix conda build again --- recipe/bld.bat | 2 +- recipe/build.sh | 2 +- recipe/meta.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipe/bld.bat b/recipe/bld.bat index 8ebeb87..99cff4c 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -8,7 +8,7 @@ if exist "%SRC_DIR%\build_proj" ( :: -T v142 specifies the toolset :: -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" to the cmake command to specify the CUDA toolkit version -cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G "Visual Studio 16 2019" -T "v142" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" +cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G Ninja -DBUILD_PYTHON_WRAPPERS=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" %CMAKE_ARGS% cmake --build "%SRC_DIR%\build_proj" --target install --config RelWithDebInfo %PYTHON% -m pip install -vv "%SRC_DIR%\src\Python" diff --git a/recipe/build.sh b/recipe/build.sh index e2cfb37..62ad1c7 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -4,6 +4,6 @@ if test -d "$SRC_DIR/build_proj"; then rm -rf "$SRC_DIR/build_proj" fi -cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" +cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -G Ninja -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" ${CMAKE_ARGS} cmake --build "$SRC_DIR/build_proj" --target install $PYTHON -m pip install -vv "$SRC_DIR/src/Python" diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 0ee50ae..62f9d0f 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -54,7 +54,7 @@ requirements: - {{ pin_compatible('python', min_pin='x.x') }} - numpy - __cuda # [cuda_compiler_version != "None"] - - {{ pin_compatible('cuda-version', min_pin='x') }} # [cuda_compiler_version != "None"] + - {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }} # [cuda_compiler_version != "None"] about: home: https://TomographicImaging.github.io/CIL From 4e93d9fe80b7035ef6a5000e295f06b8ac10daf4 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 18:50:48 +0100 Subject: [PATCH 07/23] inexplicable fix --- recipe/conda_build_config.yaml | 2 +- recipe/meta.yaml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index f3fa8f4..bd6b93c 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -5,4 +5,4 @@ python: - 3.13 cuda_compiler_version: - None - - 11.8 + - 12.9 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 62f9d0f..3d0c40e 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -19,8 +19,8 @@ build: - {{ project.get('name') }} =*=cpu* # [cuda_compiler_version == "None"] ignore_run_exports: - cudatoolkit # [(cuda_compiler_version or "None").startswith("11")] - ignore_run_exports_from: - - {{ compiler('cuda') }} # [cuda_compiler_version != "None"] + #ignore_run_exports_from: + # - {{ compiler('cuda') }} # [cuda_compiler_version != "None"] script_env: - BUILD_CUDA=ON # [cuda_compiler_version != "None"] - BUILD_CUDA=OFF # [cuda_compiler_version == "None"] @@ -41,7 +41,8 @@ requirements: - ninja - python # [build_platform != target_platform] - {{ compiler('cxx') }} - - {{ compiler('cuda') }} # [cuda_compiler_version != "None"] + #- {{ compiler('cuda') }} # [cuda_compiler_version != "None"] + - cuda-compiler ~={{ cuda_compiler_version }} # [cuda_compiler_version != "None"] host: - python x.x - libgomp # [linux] From 0145555c2c0500c6e1c30969e47ea332aad9ab1b Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 18:55:55 +0100 Subject: [PATCH 08/23] drop numpy pin --- .github/workflows/build.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5f65a7..50ffa56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,6 @@ jobs: strategy: matrix: python-version: [3.12] - numpy-version: [1.26] steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -34,7 +33,7 @@ jobs: which cmake || conda install -yq cmake cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install - pip install ./src/Python numpy==${{ numpy-version }} + pip install ./src/Python - name: test run: | conda activate "${{ steps.reqs.outputs.envname }}" @@ -52,12 +51,7 @@ jobs: strategy: matrix: python-version: ['3.10', 3.12] - numpy-version: [2.*] os: [ubuntu-latest, windows-latest] - include: - - python-version: '3.10' - numpy-version: 1.23 - os: ubuntu-latest steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -68,7 +62,7 @@ jobs: run: | cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install - pip install ./src/Python numpy==${{ numpy-version }} + pip install ./src/Python - name: test run: PYTHONPATH=./src/Python python -m unittest discover -v -s ./test conda: From 7624486ce3b1e993bf6334da580d57aa68e28175 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 19:00:50 +0100 Subject: [PATCH 09/23] CI: minor pyversion tweak --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50ffa56..8026e34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: [self-hosted, python, cuda] strategy: matrix: - python-version: [3.12] + python-version: [3.12] # penultimate supported steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -50,7 +50,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ['3.10', 3.12] + python-version: ['3.10', 3.13] # min & max supported os: [ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v4 @@ -70,7 +70,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', 3.11, 3.12, 3.13] # penultimate supported + python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} From 0e999f2e2f923ea222a6d68f2390d500779f1ed5 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 19:08:38 +0100 Subject: [PATCH 10/23] conda py3.13 --- .github/workflows/build.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8026e34..5b90a0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml + python-version: ['3.10', 3.11, 3.12, 3.13] # parallelise conda_build_config.yaml steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -81,8 +81,13 @@ jobs: channels: conda-forge - name: conda build & test run: | - conda install boa - conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist + if test ${{ matrix.python-version }} = 3.13; then + conda install conda-build + conda build . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist + else + conda install boa + conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist + fi - name: Upload artifact of the conda package uses: actions/upload-artifact@v4 with: From 816767ef5d1e9cd274faa34b558b3aa53041899c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 19:23:22 +0100 Subject: [PATCH 11/23] CI: conda test CPU --- .github/workflows/build.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b90a0f..2e01579 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,14 +82,16 @@ jobs: - name: conda build & test run: | if test ${{ matrix.python-version }} = 3.13; then - conda install conda-build - conda build . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist + BUILD_DEP=conda-build + BUILD_CMD="conda build" else - conda install boa - conda mambabuild . -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist + BUILD_DEP=boa + BUILD_CMD="conda mambabuild -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist" fi - - name: Upload artifact of the conda package - uses: actions/upload-artifact@v4 + conda install $BUILD_DEP + $BUILD_CMD --no-test . + $BUILD_CMD --test dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 + - uses: actions/upload-artifact@v4 with: name: ccpi-regulariser-package path: dist/linux-64/ccpi-regulariser* From 6465ac1fb74c3187349550abc03fee39126d2882 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 10 Oct 2025 19:42:02 +0100 Subject: [PATCH 12/23] CI: fix conda package name --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e01579..83a615b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -93,7 +93,7 @@ jobs: $BUILD_CMD --test dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 - uses: actions/upload-artifact@v4 with: - name: ccpi-regulariser-package + name: ccpi-regulariser_py${{ matrix.python-version }} path: dist/linux-64/ccpi-regulariser* pass: needs: [test-cuda, test, conda] From e9e312416046df496306f191da16713efe1e6084 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 13 Oct 2025 17:35:50 +0100 Subject: [PATCH 13/23] cmake: cudart static link --- src/Core/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 953f794..ae27ef2 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -98,7 +98,8 @@ if (BUILD_CUDA) ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/Diffus_4thO_GPU_core.cu ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/PatchSelect_GPU_core.cu ) - target_link_libraries(cilregcuda PUBLIC CUDA::cudart PRIVATE CCCL::CCCL) + target_link_libraries(cilregcuda PRIVATE CCCL::CCCL CUDA::cudart_static) + set_target_properties(cilregcuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) message(STATUS "Installing in ${CMAKE_INSTALL_PREFIX}") install(TARGETS cilregcuda LIBRARY DESTINATION . From ce623f3d6bfca843507fcd1429913df5a87fd7f2 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 13 Oct 2025 18:01:31 +0100 Subject: [PATCH 14/23] tests: minor debug/fix --- test/test_3d_cpu_vs_gpu.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/test_3d_cpu_vs_gpu.py b/test/test_3d_cpu_vs_gpu.py index 30ba582..04e03ab 100644 --- a/test/test_3d_cpu_vs_gpu.py +++ b/test/test_3d_cpu_vs_gpu.py @@ -164,12 +164,8 @@ def test_FGP_TV_CPU_vs_GPU(self): print("--------Compare the results--------") tolerance = 1e-05 - diff_im = np.zeros(np.shape(fgp_cpu)) diff_im = abs(fgp_cpu - fgp_gpu) - diff_im[diff_im > tolerance] = 1 - - self.assertLessEqual(diff_im.sum(), 1) - + np.testing.assert_array_less(diff_im, tolerance) if __name__ == "__main__": unittest.main() From c4a21c79e39c7202a498a4d4298d04f18acb19b3 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 13 Oct 2025 18:02:32 +0100 Subject: [PATCH 15/23] cmake: cuda arch fallback all --- CMakeLists.txt | 2 +- src/Core/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a26d735..5bf7d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.23) project(RGL) #https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index ae27ef2..19e4070 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -63,6 +63,9 @@ endif() if (BUILD_CUDA) find_package(CUDAToolkit REQUIRED) enable_language(CUDA) + if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) + set(CMAKE_CUDA_ARCHITECTURES "all") + endif() # CCCL (for thrust), vis. https://github.com/NVIDIA/cccl/tree/main/examples/basic#downloading-cpm set(CPM_DOWNLOAD_VERSION 0.34.0) From 0a5979099de297f3d3c8ebfb00ec713c6836e004 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 14 Oct 2025 12:31:58 +0100 Subject: [PATCH 16/23] misc tidy --- .github/workflows/build.yml | 10 ++++++---- CMakeLists.txt | 2 +- recipe/bld.bat | 2 +- recipe/build.sh | 2 +- src/Core/CMakeLists.txt | 5 ++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83a615b..31e31a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: run: | conda activate "${{ steps.reqs.outputs.envname }}" which cmake || conda install -yq cmake - cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_INSTALL_PREFIX=./install + cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install pip install ./src/Python - name: test @@ -58,9 +58,10 @@ jobs: - uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} + conda-remove-defaults: "true" - name: build run: | - cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_MATLAB_WRAPPER=OFF -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_INSTALL_PREFIX=./install + cmake -S . -B ./build_proj -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=OFF -DCMAKE_INSTALL_PREFIX=./install cmake --build ./build_proj --target install pip install ./src/Python - name: test @@ -79,6 +80,7 @@ jobs: python-version: ${{ matrix.python-version }} mamba-version: "*" channels: conda-forge + conda-remove-defaults: "true" - name: conda build & test run: | if test ${{ matrix.python-version }} = 3.13; then @@ -88,8 +90,8 @@ jobs: BUILD_DEP=boa BUILD_CMD="conda mambabuild -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist" fi - conda install $BUILD_DEP - $BUILD_CMD --no-test . + conda install conda-verify $BUILD_DEP + $BUILD_CMD --no-test recipe $BUILD_CMD --test dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 - uses: actions/upload-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bf7d32..b32e739 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.23) +cmake_minimum_required(VERSION 3.23...4.1) project(RGL) #https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py diff --git a/recipe/bld.bat b/recipe/bld.bat index 99cff4c..83751b0 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -8,7 +8,7 @@ if exist "%SRC_DIR%\build_proj" ( :: -T v142 specifies the toolset :: -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" to the cmake command to specify the CUDA toolkit version -cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G Ninja -DBUILD_PYTHON_WRAPPERS=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" %CMAKE_ARGS% +cmake -S "%SRC_DIR%" -B "%SRC_DIR%\build_proj" -G Ninja -DBUILD_PYTHON_WRAPPERS=ON -DBUILD_CUDA=%BUILD_CUDA% -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX="%SRC_DIR%\install" %CMAKE_ARGS% cmake --build "%SRC_DIR%\build_proj" --target install --config RelWithDebInfo %PYTHON% -m pip install -vv "%SRC_DIR%\src\Python" diff --git a/recipe/build.sh b/recipe/build.sh index 62ad1c7..59d53dc 100755 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -4,6 +4,6 @@ if test -d "$SRC_DIR/build_proj"; then rm -rf "$SRC_DIR/build_proj" fi -cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -G Ninja -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DLIBRARY_INC="$CONDA_PREFIX" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" ${CMAKE_ARGS} +cmake -S "$SRC_DIR" -B "$SRC_DIR/build_proj" -G Ninja -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=${BUILD_CUDA:-OFF} -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX="$SRC_DIR/install" ${CMAKE_ARGS} cmake --build "$SRC_DIR/build_proj" --target install $PYTHON -m pip install -vv "$SRC_DIR/src/Python" diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 19e4070..1f7830b 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -40,9 +40,8 @@ add_library(cilreg SHARED ) target_link_libraries(cilreg ${OpenMP_EXE_LINKER_FLAGS} ${EXTRA_LIBRARIES}) include_directories(cilreg PUBLIC - ${LIBRARY_INC}/include - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_CPU/ ) + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_CPU/) message(STATUS "Installing in ${CMAKE_INSTALL_PREFIX}") if (UNIX) From 946f77598907abfc4837e8251de80efe86cd3e03 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 14 Oct 2025 12:32:54 +0100 Subject: [PATCH 17/23] CI: build windows, release on tag --- .github/workflows/build.yml | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31e31a1..d59306d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,13 +68,16 @@ jobs: run: PYTHONPATH=./src/Python python -m unittest discover -v -s ./test conda: defaults: {run: {shell: 'bash -el {0}'}} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }}-latest strategy: matrix: python-version: ['3.10', 3.11, 3.12, 3.13] # parallelise conda_build_config.yaml + os: [ubuntu, windows] steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} + - if: matrix.os == 'windows' + uses: ilammy/msvc-dev-cmd@v1 - uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} @@ -95,8 +98,35 @@ jobs: $BUILD_CMD --test dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 - uses: actions/upload-artifact@v4 with: - name: ccpi-regulariser_py${{ matrix.python-version }} - path: dist/linux-64/ccpi-regulariser* + name: ccpi-regulariser_py${{ matrix.python-version }}-${{ matrix.os }} + path: dist/*/ccpi-regulariser-*.tar.bz2 + conda-upload: + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') + defaults: {run: {shell: 'bash -el {0}', working-directory: dist}} + runs-on: ubuntu-latest + needs: [test-cuda, test, conda] + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + mamba-version: "*" + channels: conda-forge + conda-remove-defaults: "true" + - uses: actions/download-artifact@v4 + with: {pattern: ccpi-regulariser_py*-*, path: dist, merge-multiple: true} + - run: conda install anaconda-client + - name: anaconda upload -c ccpi + run: > + anaconda -v -t ${{ secrets.CCPI_CONDA_TOKEN }} upload --force + --label ${{ startsWith(github.ref, 'refs/tags') && 'main' || 'dev' }} */ccpi-regulariser-*.tar.bz2 + - if: startsWith(github.ref, 'refs/tags') + name: conda upload -c tomography.stfc.ac.uk/conda + run: | + echo '${{ secrets.STFC_SSH_KEY }}' > ./key + chmod 600 ./key + rsync -e 'ssh -o StrictHostKeyChecking=no -i ./key' -R */cil-*.tar.bz2 '${{ secrets.STFC_SSH_HOST }}:${{ secrets.STFC_SSH_CONDA_DIR }}' + ssh -o StrictHostKeyChecking=no -i ./key ${{ secrets.STFC_SSH_HOST }} \ + 'bash -lic "conda index --bz2 --zst --run-exports --channeldata --rss -n ccpi ${{ secrets.STFC_SSH_CONDA_DIR }}"' pass: needs: [test-cuda, test, conda] runs-on: ubuntu-latest From d4e30e48a0897fb41aea1433e7c9ecc589134de5 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 14 Oct 2025 13:06:07 +0100 Subject: [PATCH 18/23] fix thrust compilation --- src/Core/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 1f7830b..e49d63c 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -101,7 +101,9 @@ if (BUILD_CUDA) ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/PatchSelect_GPU_core.cu ) target_link_libraries(cilregcuda PRIVATE CCCL::CCCL CUDA::cudart_static) - set_target_properties(cilregcuda PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + set_target_properties(cilregcuda PROPERTIES + CUDA_SEPARABLE_COMPILATION ON + CXX_STANDARD 17) message(STATUS "Installing in ${CMAKE_INSTALL_PREFIX}") install(TARGETS cilregcuda LIBRARY DESTINATION . From 852bafc9c521c268b4fd8a8c2be2307757af42c5 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Tue, 14 Oct 2025 13:09:05 +0100 Subject: [PATCH 19/23] CI: drop conda-py3.13-win --- .github/workflows/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d59306d..3e40a63 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,8 +71,10 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: matrix: - python-version: ['3.10', 3.11, 3.12, 3.13] # parallelise conda_build_config.yaml + python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml os: [ubuntu, windows] + include: + - {python-version: 3.13, os: ubuntu} steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} From 2900e0d4f4dce7bb1e965128711b905ecbd42372 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 16 Oct 2025 14:07:35 +0100 Subject: [PATCH 20/23] conda: unpin python --- .github/workflows/build.yml | 54 ++++++++++++++++++++++++---------- recipe/conda_build_config.yaml | 5 ---- recipe/meta.yaml | 4 +-- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e40a63..368e75d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,47 +66,69 @@ jobs: pip install ./src/Python - name: test run: PYTHONPATH=./src/Python python -m unittest discover -v -s ./test - conda: + conda-build: defaults: {run: {shell: 'bash -el {0}'}} runs-on: ${{ matrix.os }}-latest strategy: matrix: - python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml os: [ubuntu, windows] - include: - - {python-version: 3.13, os: ubuntu} steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} - if: matrix.os == 'windows' uses: ilammy/msvc-dev-cmd@v1 + - uses: conda-incubator/setup-miniconda@v3 + with: + python-version: 3.12 + mamba-version: "*" + channels: conda-forge + conda-remove-defaults: "true" + - run: conda install boa conda-verify + - name: conda build + run: > + conda mambabuild -c conda-forge --override-channels --output-folder dist recipe --no-test + - uses: actions/upload-artifact@v4 + with: + name: ccpi-regulariser-${{ matrix.os }} + path: dist/*/ccpi-regulariser-*.tar.bz2 + conda-test: + defaults: {run: {shell: 'bash -el {0}'}} + runs-on: ${{ matrix.os }}-latest + needs: [conda-build] + strategy: + matrix: + python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml + os: [ubuntu, windows] + include: + - {python-version: 3.13, os: ubuntu} + steps: + - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python-version }} mamba-version: "*" channels: conda-forge conda-remove-defaults: "true" - - name: conda build & test + - uses: actions/download-artifact@v4 + with: + name: ccpi-regulariser-${{ matrix.os }} + path: dist + - name: conda test run: | if test ${{ matrix.python-version }} = 3.13; then BUILD_DEP=conda-build BUILD_CMD="conda build" else BUILD_DEP=boa - BUILD_CMD="conda mambabuild -c conda-forge -c ccpi --python=${{ matrix.python-version }} --output-folder dist" + BUILD_CMD="conda mambabuild" fi - conda install conda-verify $BUILD_DEP - $BUILD_CMD --no-test recipe - $BUILD_CMD --test dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 - - uses: actions/upload-artifact@v4 - with: - name: ccpi-regulariser_py${{ matrix.python-version }}-${{ matrix.os }} - path: dist/*/ccpi-regulariser-*.tar.bz2 + conda install $BUILD_DEP + $BUILD_CMD -c conda-forge --override-channels dist/*/ccpi-regulariser-*-cpu_h*.tar.bz2 --test --python=${{ matrix.python-version }} conda-upload: if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') defaults: {run: {shell: 'bash -el {0}', working-directory: dist}} runs-on: ubuntu-latest - needs: [test-cuda, test, conda] + needs: conda-test steps: - uses: actions/checkout@v4 - uses: conda-incubator/setup-miniconda@v3 @@ -115,7 +137,7 @@ jobs: channels: conda-forge conda-remove-defaults: "true" - uses: actions/download-artifact@v4 - with: {pattern: ccpi-regulariser_py*-*, path: dist, merge-multiple: true} + with: {pattern: ccpi-regulariser-*, path: dist, merge-multiple: true} - run: conda install anaconda-client - name: anaconda upload -c ccpi run: > @@ -130,6 +152,6 @@ jobs: ssh -o StrictHostKeyChecking=no -i ./key ${{ secrets.STFC_SSH_HOST }} \ 'bash -lic "conda index --bz2 --zst --run-exports --channeldata --rss -n ccpi ${{ secrets.STFC_SSH_CONDA_DIR }}"' pass: - needs: [test-cuda, test, conda] + needs: [test-cuda, test, conda-test] runs-on: ubuntu-latest steps: [{run: echo success}] diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index bd6b93c..176d25d 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -1,8 +1,3 @@ -python: - - 3.10 - - 3.11 - - 3.12 - - 3.13 cuda_compiler_version: - None - 12.9 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 3d0c40e..d1c2818 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -44,7 +44,7 @@ requirements: #- {{ compiler('cuda') }} # [cuda_compiler_version != "None"] - cuda-compiler ~={{ cuda_compiler_version }} # [cuda_compiler_version != "None"] host: - - python x.x + - python >=3.10 - libgomp # [linux] - llvm-openmp # [osx] - setuptools @@ -52,7 +52,7 @@ requirements: - cuda-cccl # [cuda_compiler_version != "None"] - cuda-version {{ cuda_compiler_version }} # [cuda_compiler_version != "None"] run: - - {{ pin_compatible('python', min_pin='x.x') }} + - python >=3.10 - numpy - __cuda # [cuda_compiler_version != "None"] - {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }} # [cuda_compiler_version != "None"] From f236a9650fbc1b17f7a83147fcccc4d8d0976f63 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 16 Oct 2025 15:59:17 +0100 Subject: [PATCH 21/23] PEP420 implicit namespace --- src/Python/ccpi/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Python/ccpi/__init__.py diff --git a/src/Python/ccpi/__init__.py b/src/Python/ccpi/__init__.py deleted file mode 100644 index e69de29..0000000 From 268b9f35ebb3acb79752e01541c30c5cb3b69fd6 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 16 Oct 2025 15:59:35 +0100 Subject: [PATCH 22/23] update docs --- Installation.md | 25 +++++++------------------ Readme.md | 7 +++---- recipe/meta.yaml | 2 +- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/Installation.md b/Installation.md index 5f4712d..e017cfa 100644 --- a/Installation.md +++ b/Installation.md @@ -2,16 +2,7 @@ ## Installation -In order to compile C/C++ sources and additional wrappers from source code for numpy 1.24 and python 3.10, the recommended way is: - -```sh -git clone https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit -cd CCPi-Regularisation-Toolkit -export CCPI_BUILD_ARGS="--numpy 1.24 --python 3.10" -build/jenkins-build.sh -``` - -this will install `conda build` environment and compiles C/C++ and Python wrappers and performs basic tests for environment with python 3.10 and numpy 1.24. +The recommended method is via `conda` (see [Python binaries](#python-binaries) below). ### CMake @@ -47,18 +38,16 @@ pip install ./src/Python #### Python binaries -Python binaries are distributed via the [ccpi](https://anaconda.org/ccpi/ccpi-regulariser) conda channel. +Python binaries are distributed via the [`ccpi`](https://anaconda.org/ccpi/ccpi-regulariser) `conda` channel. -```sh -conda install ccpi-regulariser -c ccpi -c conda-forge -``` +- `conda install -c ccpi -c conda-forge ccpi-regulariser=*=cpu*` (CPU-only) +- `conda install -c ccpi -c conda-forge ccpi-regulariser=*=cuda*` (CUDA) #### Python (conda-build) ```sh -conda build recipe/ --numpy 1.23 --python 3.10 -conda install ccpi-regulariser --use-local --force-reinstall # doesn't work? -conda install -c file://${CONDA_PREFIX}/conda-bld/ ccpi-regulariser --force-reinstall # try this one +conda build recipe/ --output-folder dist +conda install ccpi-regulariser=*=cuda* -c dist -c conda-forge cd demos/ python demo_cpu_regularisers.py # to run CPU demo python demo_gpu_regularisers.py # to run GPU demo @@ -85,7 +74,7 @@ If Python is not found by CMake you can provide the additional flag to CMake `-D Tests can also be run in-place after the build: ```sh -PYTHONPATH=./src/Python python -m unittest discover ./test +PYTHONPATH=./src/Python python -m unittest discover -v -s ./test ``` ### MultiGPU capability (to use in Python with mpi4py) diff --git a/Readme.md b/Readme.md index a5a4af3..89fb8a1 100644 --- a/Readme.md +++ b/Readme.md @@ -10,7 +10,7 @@ Iterative image reconstruction (IIR) methods frequently require regularisation t ## Prerequisites -- Python (3.7+) and/or [MATLAB](https://www.mathworks.com/products/matlab) +- Python (3.10+) and/or [MATLAB](https://www.mathworks.com/products/matlab) - C compilers - `nvcc` (CUDA SDK) compilers - [CuPy](https://docs.cupy.dev) for the GPU-enabled methods @@ -42,9 +42,8 @@ The package comes as a [CMake](https://cmake.org) project and additional wrapper To install precompiled binaries, you need `conda` and install from the `ccpi` channel using : -```sh -conda install ccpi-regulariser -c ccpi -c conda-forge -``` +- `conda install -c ccpi -c conda-forge ccpi-regulariser=*=cpu*` (CPU-only) +- `conda install -c ccpi -c conda-forge ccpi-regulariser=*=cuda*` (CUDA) ### Python (GPU-CuPy) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index d1c2818..5d69f62 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -58,6 +58,6 @@ requirements: - {{ pin_compatible('cuda-version', min_pin='x', max_pin='x') }} # [cuda_compiler_version != "None"] about: - home: https://TomographicImaging.github.io/CIL + home: https://github.com/TomographicImaging/CCPi-Regularisation-Toolkit license: Apache-2.0 summary: 'The set of CPU/GPU optimised regularisation modules for iterative image reconstruction and other image processing tasks' From 4d7d16ead38cb5ae8e39e5831514285befb1fdd4 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 17 Oct 2025 11:26:32 +0100 Subject: [PATCH 23/23] CI: drop windows (hanging) --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 368e75d..9931adb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: runs-on: ${{ matrix.os }}-latest strategy: matrix: - os: [ubuntu, windows] + os: [ubuntu] # TODO: windows steps: - uses: actions/checkout@v4 with: {fetch-depth: 0, submodules: recursive} @@ -98,7 +98,7 @@ jobs: strategy: matrix: python-version: ['3.10', 3.11, 3.12] # parallelise conda_build_config.yaml - os: [ubuntu, windows] + os: [ubuntu] # TODO: windows include: - {python-version: 3.13, os: ubuntu} steps: