From 86f00a3daec0064dd799b54c2178510aa73c3ebe Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Mon, 10 Jan 2022 14:04:08 -0500 Subject: [PATCH 1/3] Replace custom CUDA bindings previously provided by RMM with official CUDA Python bindings --- python/cudf/cudf/utils/gpu_utils.py | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/python/cudf/cudf/utils/gpu_utils.py b/python/cudf/cudf/utils/gpu_utils.py index dbdd68f2df8..76667c2cfef 100644 --- a/python/cudf/cudf/utils/gpu_utils.py +++ b/python/cudf/cudf/utils/gpu_utils.py @@ -15,10 +15,10 @@ def validate_setup(): import warnings + from cuda.cudart import cudaDeviceAttr, cudaError_t + from rmm._cuda.gpu import ( CUDARuntimeError, - cudaDeviceAttr, - cudaError, deviceGetName, driverGetVersion, getDeviceAttribute, @@ -30,30 +30,30 @@ def _try_get_old_or_new_symbols(): try: # CUDA 10.2+ symbols return [ - cudaError.cudaErrorDeviceUninitialized, - cudaError.cudaErrorTimeout, + cudaError_t.cudaErrorDeviceUninitialized, + cudaError_t.cudaErrorTimeout, ] except AttributeError: # CUDA 10.1 symbols - return [cudaError.cudaErrorDeviceUninitilialized] + return [cudaError_t.cudaErrorDeviceUninitilialized] notify_caller_errors = { - cudaError.cudaErrorInitializationError, - cudaError.cudaErrorInsufficientDriver, - cudaError.cudaErrorInvalidDeviceFunction, - cudaError.cudaErrorInvalidDevice, - cudaError.cudaErrorStartupFailure, - cudaError.cudaErrorInvalidKernelImage, - cudaError.cudaErrorAlreadyAcquired, - cudaError.cudaErrorOperatingSystem, - cudaError.cudaErrorNotPermitted, - cudaError.cudaErrorNotSupported, - cudaError.cudaErrorSystemNotReady, - cudaError.cudaErrorSystemDriverMismatch, - cudaError.cudaErrorCompatNotSupportedOnDevice, + cudaError_t.cudaErrorInitializationError, + cudaError_t.cudaErrorInsufficientDriver, + cudaError_t.cudaErrorInvalidDeviceFunction, + cudaError_t.cudaErrorInvalidDevice, + cudaError_t.cudaErrorStartupFailure, + cudaError_t.cudaErrorInvalidKernelImage, + cudaError_t.cudaErrorAlreadyAcquired, + cudaError_t.cudaErrorOperatingSystem, + cudaError_t.cudaErrorNotPermitted, + cudaError_t.cudaErrorNotSupported, + cudaError_t.cudaErrorSystemNotReady, + cudaError_t.cudaErrorSystemDriverMismatch, + cudaError_t.cudaErrorCompatNotSupportedOnDevice, *_try_get_old_or_new_symbols(), - cudaError.cudaErrorUnknown, - cudaError.cudaErrorApiFailureBase, + cudaError_t.cudaErrorUnknown, + cudaError_t.cudaErrorApiFailureBase, } try: From 24544356171d3e4f10321eebcaca55c7f355dce1 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Tue, 11 Jan 2022 09:57:22 -0500 Subject: [PATCH 2/3] Unused import --- python/cudf/cudf/utils/gpu_utils.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/python/cudf/cudf/utils/gpu_utils.py b/python/cudf/cudf/utils/gpu_utils.py index 76667c2cfef..afbd625cc2b 100644 --- a/python/cudf/cudf/utils/gpu_utils.py +++ b/python/cudf/cudf/utils/gpu_utils.py @@ -15,7 +15,7 @@ def validate_setup(): import warnings - from cuda.cudart import cudaDeviceAttr, cudaError_t + from cuda.cudart import cudaError_t from rmm._cuda.gpu import ( CUDARuntimeError, @@ -68,11 +68,7 @@ def _try_get_old_or_new_symbols(): # Cupy throws RunTimeException to get GPU count, # hence obtaining GPU count by in-house cpp api above - # 75 - Indicates to get "cudaDevAttrComputeCapabilityMajor" attribute - # 0 - Get GPU 0 - major_version = getDeviceAttribute( - cudaDeviceAttr.cudaDevAttrComputeCapabilityMajor, 0 - ) + major_version = getDeviceAttribute("ComputeCapabilityMajor", 0) if major_version >= 6: # You have a GPU with NVIDIA Pascal™ architecture or better @@ -86,9 +82,7 @@ def _try_get_old_or_new_symbols(): pass else: device_name = deviceGetName(0) - minor_version = getDeviceAttribute( - cudaDeviceAttr.cudaDevAttrComputeCapabilityMinor, 0 - ) + minor_version = getDeviceAttribute("ComputeCapabilityMinor", 0) warnings.warn( f"You will need a GPU with NVIDIA Pascal™ or " f"newer architecture" From 206535d5886e282655eddeacd79e61992ec1aa9f Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Wed, 12 Jan 2022 10:50:47 -0500 Subject: [PATCH 3/3] Add cuda-python as explicit dependency. --- conda/environments/cudf_dev_cuda11.5.yml | 1 + conda/recipes/cudf/meta.yaml | 2 +- python/cudf/cudf/utils/gpu_utils.py | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conda/environments/cudf_dev_cuda11.5.yml b/conda/environments/cudf_dev_cuda11.5.yml index cc8d50a1717..841aaaa53f1 100644 --- a/conda/environments/cudf_dev_cuda11.5.yml +++ b/conda/environments/cudf_dev_cuda11.5.yml @@ -33,6 +33,7 @@ dependencies: - ipython - pandoc=<2.0.0 - cudatoolkit=11.5 + - cuda-python >=11.5,<12.0 - pip - flake8=3.8.3 - black=19.10 diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index 2600ab358cc..1035655a190 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -52,7 +52,7 @@ requirements: - packaging - cachetools - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler - + - cuda-python >=11.5,<12.0 test: # [linux64] requires: # [linux64] - cudatoolkit {{ cuda_version }}.* # [linux64] diff --git a/python/cudf/cudf/utils/gpu_utils.py b/python/cudf/cudf/utils/gpu_utils.py index afbd625cc2b..8947760e052 100644 --- a/python/cudf/cudf/utils/gpu_utils.py +++ b/python/cudf/cudf/utils/gpu_utils.py @@ -15,7 +15,7 @@ def validate_setup(): import warnings - from cuda.cudart import cudaError_t + from cuda.cudart import cudaDeviceAttr, cudaError_t from rmm._cuda.gpu import ( CUDARuntimeError, @@ -68,7 +68,9 @@ def _try_get_old_or_new_symbols(): # Cupy throws RunTimeException to get GPU count, # hence obtaining GPU count by in-house cpp api above - major_version = getDeviceAttribute("ComputeCapabilityMajor", 0) + major_version = getDeviceAttribute( + cudaDeviceAttr.cudaDevAttrComputeCapabilityMajor, 0 + ) if major_version >= 6: # You have a GPU with NVIDIA Pascal™ architecture or better @@ -82,7 +84,9 @@ def _try_get_old_or_new_symbols(): pass else: device_name = deviceGetName(0) - minor_version = getDeviceAttribute("ComputeCapabilityMinor", 0) + minor_version = getDeviceAttribute( + cudaDeviceAttr.cudaDevAttrComputeCapabilityMinor, 0 + ) warnings.warn( f"You will need a GPU with NVIDIA Pascal™ or " f"newer architecture"