Skip to content

cuda.parallel: cmake build script to avoid using find_program - #4382

Merged
oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:avoid-find-program-to-find-cython
Apr 10, 2025
Merged

oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:avoid-find-program-to-find-cython

Conversation

@oleksandr-pavlyk

@oleksandr-pavlyk oleksandr-pavlyk commented Apr 9, 2025 •

Copy link
Copy Markdown
Contributor

Description

closes gh-4381

Get rid of CYTHON_EXECUTABLE variable and use of find_program to set it. Use "${Python3_EXECUTABLE}" -m cython instead.

N.B.: An attempt to use Python3::Interpreter -m cython did not work.

CMakeLists.txt that uses Python3::Interpreter
cmake_minimum_required(VERSION 3.27)
project(
    Test
    DESCRIPTION "Test"
)

find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)

execute_process(
    COMMAND Python3::Interpreter -m cython --version
    OUTPUT_VARIABLE CYTHON_version_output
    ERROR_VARIABLE CYTHON_version_error
    RESULT_VARIABLE CYTHON_version_result
    OUTPUT_STRIP_TRAILING_WHITESPACE
    ERROR_STRIP_TRAILING_WHITESPACE
)

message(STATUS "Output: ${CYTHON_version_output}")
message(STATUS "Error:  ${CYTHON_version_error}")
message(STATUS "RESULT: ${CYTHON_version_result}")

Using it:

$ cmake -B build .
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: /tmp/cuda_parallel_venv/bin/python3.10 (found version "3.10.12") found components: Interpreter Development.Module
-- Output: 
-- Error:  
-- RESULT: no such file or directory
-- Configuring done (0.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/coder/cccl/python/cuda_parallel/tmp/build

Changing Python3 to Python also did not work, so my solution was to use "${Python3_EXECUTABLE}" instead of Python3::Interpreter.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@oleksandr-pavlyk
oleksandr-pavlyk requested a review from a team as a code owner April 9, 2025 13:30
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Apr 9, 2025
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Apr 9, 2025
@oleksandr-pavlyk
oleksandr-pavlyk requested a review from wmaxey April 9, 2025 13:31
@github-actions

github-actions Bot commented Apr 9, 2025

Copy link
Copy Markdown
Contributor
ðŸŸĐ CI finished in 1h 30m: Pass: 100%/1 | Total: 1h 30m | Avg: 1h 30m | Max: 1h 30m
  • ðŸŸĐ python: Pass: 100%/1 | Total: 1h 30m | Avg: 1h 30m | Max: 1h 30m

    ðŸŸĐ cpu
      ðŸŸĐ amd64              Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ ctk
      ðŸŸĐ 12.8               Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ cudacxx
      ðŸŸĐ nvcc12.8           Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ cudacxx_family
      ðŸŸĐ nvcc               Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ cxx
      ðŸŸĐ GCC13              Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ cxx_family
      ðŸŸĐ GCC                Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ gpu
      ðŸŸĐ rtx2080            Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    ðŸŸĐ jobs
      ðŸŸĐ Test               Pass: 100%/1   | Total:  1h 30m | Avg:  1h 30m | Max:  1h 30m
    

👃 Inspect Changes

Modifications in project?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
stdpar
+/- python
CCCL C Parallel Library
Catch2Helper

Modifications in project or dependencies?

Project
CCCL Infrastructure
libcu++
CUB
Thrust
CUDA Experimental
stdpar
+/- python
CCCL C Parallel Library
Catch2Helper

🏃‍ Runner counts (total jobs: 1)

# Runner
1 linux-amd64-gpu-rtx2080-latest-1

@oleksandr-pavlyk

Copy link
Copy Markdown
Contributor Author

@kkraus14 FYI, the issue I was running into with using Python3::Interpreter is documented in the pull request description.

@kkraus14

kkraus14 commented Apr 9, 2025

Copy link
Copy Markdown
Collaborator

I think we should be using something like add_custom_command or add_custom_target instead of execute_process if we want to use the Python3::Interpreter target. execute_process runs at configure time as opposed to build time.

@oleksandr-pavlyk

Copy link
Copy Markdown
Contributor Author

The execute_process was intended to run during config time. It only finds the Cython version to output during configuration step. The version not not used at build time, only printed out. It serves to ensure that Cython script is in working order. This step is optional and can be removed altogether.

The cythonization is done using add_custom_command which runs are built time.

Comment thread python/cuda_parallel/CMakeLists.txt Resolved
@oleksandr-pavlyk
oleksandr-pavlyk merged commit 29aaf3b into NVIDIA:main Apr 10, 2025
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Apr 10, 2025
@oleksandr-pavlyk
oleksandr-pavlyk deleted the avoid-find-program-to-find-cython branch April 10, 2025 14:53
davebayer pushed a commit to davebayer/cccl that referenced this pull request Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Change cuda.parallel build script to avoid find_program to find cython executable

3 participants