Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conda/recipes/pylibcudf/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ requirements:
- libcudf =${{ version }}
- rmm =${{ minor_version }}
- cuda-cudart-dev
- cuda-profiler-api

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment on why we need this since it's very nonobvious without the context of this PR and someone may try to remove it in the future?

Comment thread
bdice marked this conversation as resolved.
Outdated
- cuda-nvrtc
- if: linux and x86_64
then:
Expand Down
22 changes: 17 additions & 5 deletions python/pylibcudf/pylibcudf/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ from cython.operator import dereference

from cuda.bindings import runtime

from cuda.bindings.cydriver cimport (
CUDA_ERROR_NOT_INITIALIZED,
CUDA_SUCCESS,
CUcontext,
CUresult,
cuCtxGetCurrent,
)
from cuda.bindings.cyruntime cimport (
cudaError_t,
cudaFree,
Expand Down Expand Up @@ -68,11 +75,16 @@ cdef vector[reference_wrapper[const scalar]] _as_vector(list source):


cdef inline int _ensure_cuda_context() except -1:
cdef cudaError_t status
with nogil:
status = cudaFree(NULL)
if status != cudaSuccess:
raise RuntimeError(f"Failed to initialize CUDA context: {status}")
cdef CUcontext context = NULL
cdef CUresult status = cuCtxGetCurrent(&context)
cdef cudaError_t runtime_status
if status != CUDA_SUCCESS and status != CUDA_ERROR_NOT_INITIALIZED:
raise RuntimeError(f"Failed to get current CUDA context: {status}")
if status == CUDA_ERROR_NOT_INITIALIZED or context == NULL:
with nogil:
runtime_status = cudaFree(NULL)
if runtime_status != cudaSuccess:
raise RuntimeError(f"Failed to initialize CUDA context: {runtime_status}")
return 0


Expand Down
Loading