Created
October 20, 2024 23:53
-
-
Save apowers313/3f85e410705c1e65aa7a3e94e263f48a to your computer and use it in GitHub Desktop.
CUDA Python cuDeviceGetAttribute can't get attribute CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED
This file contains 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
from cuda import cuda | |
# Error checking helper | |
def checkCudaErrors(result): | |
def _cudaGetErrorEnum(error): | |
if isinstance(error, cuda.CUresult): | |
err, name = cuda.cuGetErrorName(error) | |
return name if err == cuda.CUresult.CUDA_SUCCESS else "<unknown>" | |
elif isinstance(error, nvrtc.nvrtcResult): | |
return nvrtc.nvrtcGetErrorString(error)[1] | |
else: | |
raise RuntimeError("Unknown error type: {}".format(error)) | |
if result[0].value: | |
raise RuntimeError( | |
"CUDA error code={}({})".format(result[0].value, _cudaGetErrorEnum(result[0])) | |
) | |
if len(result) == 1: | |
return None | |
elif len(result) == 2: | |
return result[1] | |
else: | |
return result[1:] | |
# Init CUDA | |
checkCudaErrors(cuda.cuInit(0)) | |
# Create device | |
nv_device = checkCudaErrors(cuda.cuDeviceGet(0)) | |
# get CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID (134) | |
val = checkCudaErrors( | |
cuda.cuDeviceGetAttribute(cuda.CUdevice_attribute.CU_DEVICE_ATTRIBUTE_HOST_NUMA_ID, nv_device) | |
) | |
print(f"host_numa_id", val) | |
# get CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED (135) | |
val = checkCudaErrors( | |
cuda.cuDeviceGetAttribute( | |
cuda.CUdevice_attribute.CU_DEVICE_ATTRIBUTE_D3D12_CIG_SUPPORTED, nv_device | |
) | |
) | |
print("d3d12_cig_supported", val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment