Repository navigation
CUDA: Add optional Driver API argument logging - #6798
Merged
Merged
Conversation
Setting the config variable `CUDA_LOG_API_ARGS` enables logging of Driver API function arguments in the CUDA logs. This commit also documents this variable along with the CUDA_LOG_LEVEL config variable. Without the API argument logging, logs look like (for example): ``` $ NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)" == CUDA [237] INFO -- init == CUDA [238] DEBUG -- call driver api: cuInit == CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent == CUDA [275] DEBUG -- call driver api: cuCtxGetCurrent == CUDA [275] DEBUG -- call driver api: cuDeviceGetCount == CUDA [275] DEBUG -- call driver api: cuDeviceGet == CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability == CUDA [275] DEBUG -- call driver api: cuDeviceGetName == CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid == CUDA [275] DEBUG -- call driver api: cuDeviceGet == CUDA [275] DEBUG -- call driver api: cuDeviceComputeCapability == CUDA [275] DEBUG -- call driver api: cuDeviceGetName == CUDA [275] DEBUG -- call driver api: cuDeviceGetUuid == CUDA [276] DEBUG -- call driver api: cuDevicePrimaryCtxRetain == CUDA [370] DEBUG -- call driver api: cuCtxPushCurrent_v2 == CUDA [370] DEBUG -- call driver api: cuMemGetInfo_v2 == CUDA [371] DEBUG -- call driver api: cuMemAlloc_v2 == CUDA [371] INFO -- add pending dealloc: cuMemFree_v2 8 bytes ``` With API argument logging, this becomes: ``` $ NUMBA_CUDA_LOG_API_ARGS=1 NUMBA_CUDA_LOG_LEVEL=DEBUG python -c "from numba import cuda; cuda.device_array(1)" == CUDA [242] INFO -- init == CUDA [242] DEBUG -- call driver api: cuInit(0) == CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>) == CUDA [276] DEBUG -- call driver api: cuCtxGetCurrent(<cparam 'P' (0x7ff5954c9310)>) == CUDA [276] DEBUG -- call driver api: cuDeviceGetCount(<cparam 'P' (0x7ff5954c9310)>) == CUDA [276] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 0) == CUDA [276] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953faa90)>, <cparam 'P' (0x7ff5953fa990)>, 0) == CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 0) == CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953fad90)>, 0) == CUDA [277] DEBUG -- call driver api: cuDeviceGet(<cparam 'P' (0x7ff5954c9310)>, 1) == CUDA [277] DEBUG -- call driver api: cuDeviceComputeCapability(<cparam 'P' (0x7ff5953fad10)>, <cparam 'P' (0x7ff5953fad90)>, 1) == CUDA [277] DEBUG -- call driver api: cuDeviceGetName(<numba.cuda.cudadrv.driver.c_char_Array_128 object at 0x7ff5953fabc0>, 128, 1) == CUDA [277] DEBUG -- call driver api: cuDeviceGetUuid(<cparam 'P' (0x7ff5953faa90)>, 1) == CUDA [277] DEBUG -- call driver api: cuDevicePrimaryCtxRetain(<cparam 'P' (0x7ff5954c9310)>, 0) == CUDA [367] DEBUG -- call driver api: cuCtxPushCurrent_v2(c_void_p(94307166233376)) == CUDA [367] DEBUG -- call driver api: cuMemGetInfo_v2(<cparam 'P' (0x7ff5953fa990)>, <cparam 'P' (0x7ff5953faa90)>) == CUDA [367] DEBUG -- call driver api: cuMemAlloc_v2(<cparam 'P' (0x7ff5953d3310)>, 8) == CUDA [367] INFO -- add pending dealloc: cuMemFree_v2 8 bytes ```
stuartarchibald
approved these changes
Mar 8, 2021
stuartarchibald
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the patch!
Contributor
|
Note: I tested this manually to confirm both the presented debug changes. |
Contributor
|
Buildfarm ID: |
Contributor
Passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Background: I often find myself making a temporary change like this locally, but I think being able to turn this on and off generally would be useful, and I'm also fed up of applying / reverting a change like this to my local repo :-) )
Setting the config variable
CUDA_LOG_API_ARGSenables logging of Driver API function arguments in the CUDA logs.This commit also documents this variable along with the
CUDA_LOG_LEVELconfig variable.Without the API argument logging, logs look like (for example):
With API argument logging, this becomes: