From e0905ac9cc21e90ebce0a6d31e78c1e9f21c3a2b Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Fri, 19 Jan 2024 11:12:00 -0600 Subject: [PATCH] Add `pynvjitlink` as a dependency (#14763) This PR adds `pynvjitlink` as a hard dependency for cuDF. This should allow for MVC when launching numba kernels across minor versions of CUDA 12 up to the version of `nvjitlink` statically shipped with `pynvjitlink`. cc @bdice Authors: - https://github.com/brandon-b-miller - https://github.com/jakirkham - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/cudf/pull/14763 --- ci/build_wheel.sh | 2 +- .../all_cuda-120_arch-x86_64.yaml | 1 + conda/recipes/cudf/meta.yaml | 3 +- dependencies.yaml | 5 +++- python/cudf/cudf/utils/_numba.py | 29 +++++++------------ 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 9c674518810..c4b794e81f7 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -48,7 +48,7 @@ fi if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} sed -i "s/cupy-cuda11x/cupy-cuda12x/g" ${pyproject_file} - sed -i "/ptxcompiler/d" ${pyproject_file} + sed -i "s/ptxcompiler/pynvjitlink/g" ${pyproject_file} sed -i "/cubinlinker/d" ${pyproject_file} fi diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index de59bc1d43c..4cf1d5427f4 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -70,6 +70,7 @@ dependencies: - protobuf>=4.21,<5 - pyarrow==14.0.1.* - pydata-sphinx-theme!=0.14.2 +- pynvjitlink - pytest - pytest-benchmark - pytest-cases>=3.8.2 diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index bc91ee61f6f..4f39a9fe452 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-2024, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} @@ -98,6 +98,7 @@ requirements: # xref: https://github.com/rapidsai/cudf/issues/12822 - cuda-nvrtc - cuda-python >=12.0,<13.0a0 + - pynvjitlink {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - nvtx >=0.2.1 diff --git a/dependencies.yaml b/dependencies.yaml index 9cf808907ec..90a04b2f876 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -534,16 +534,19 @@ dependencies: - {matrix: null, packages: *run_cudf_packages_all_cu11} - output_types: conda matrices: + - matrix: {cuda: "12.*"} + packages: + - pynvjitlink - matrix: {cuda: "11.*"} packages: - cubinlinker - ptxcompiler - - {matrix: null, packages: null} - output_types: [requirements, pyproject] matrices: - matrix: {cuda: "12.*"} packages: - rmm-cu12==24.2.* + - pynvjitlink-cu12 - matrix: {cuda: "11.*"} packages: - rmm-cu11==24.2.* diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index 7781c14e559..6d00fd397df 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -3,23 +3,10 @@ import glob import os import sys -import warnings from functools import lru_cache from numba import config as numba_config -try: - from pynvjitlink.patch import ( - patch_numba_linker as patch_numba_linker_pynvjitlink, - ) -except ImportError: - - def patch_numba_linker_pynvjitlink(): - warnings.warn( - "CUDA Toolkit is newer than CUDA driver. " - "Numba features will not work in this configuration. " - ) - # Use an lru_cache with a single value to allow a delayed import of # strings_udf. This is the easiest way to break an otherwise circular import @@ -117,11 +104,13 @@ def _setup_numba(): version of the CUDA Toolkit used to build the PTX files shipped with the user cuDF package. """ - # ptxcompiler is a requirement for cuda 11.x packages but not - # cuda 12.x packages. However its version checking machinery - # is still necessary. If a user happens to have ptxcompiler - # in a cuda 12 environment, it's use for the purposes of - # checking the driver and runtime versions is harmless + + # Either ptxcompiler, or our vendored version (_ptxcompiler.py) + # is needed to determine the driver and runtime CUDA versions in + # the environment. In a CUDA 11.x environment, ptxcompiler is used + # to provide MVC directly, whereas for CUDA 12.x this is provided + # through pynvjitlink. The presence of either package does not + # perturb cuDF's operation in situations where they aren't used. try: from ptxcompiler.patch import NO_DRIVER, safe_get_versions except ModuleNotFoundError: @@ -145,7 +134,9 @@ def _setup_numba(): if driver_version < (12, 0): patch_numba_linker_cuda_11() else: - patch_numba_linker_pynvjitlink() + from pynvjitlink.patch import patch_numba_linker + + patch_numba_linker() def _get_cuda_version_from_ptx_file(path):