Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2490352

Browse files
authored
Fix cuInit test on Windows (#117095)
resolved: #117055
1 parent 3a44bb7 commit 2490352

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/test_cuda.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3405,7 +3405,8 @@ def check_output(script: str) -> str:
34053405
# Check that `cuInit` was not called during the import
34063406
# By using ctypes and calling cuDeviceCountGet() and expect CUDA_ERROR_NOT_INITIALIZED == 3
34073407
# See https://github.com/pytorch/pytorch/issues/116276 for more details
3408-
cuda_driver_api_call = "ctypes.CDLL('libcuda.so.1').cuDeviceGetCount(ctypes.byref(x))"
3408+
libcuda_name = "libcuda.so.1" if not IS_WINDOWS else "nvcuda.dll"
3409+
cuda_driver_api_call = f"ctypes.CDLL('{libcuda_name}').cuDeviceGetCount(ctypes.byref(x))"
34093410
rc = check_output(f"import torch; import ctypes;x=ctypes.c_int(-1);print({cuda_driver_api_call})")
34103411
self.assertEqual(rc, "3")
34113412

0 commit comments

Comments
 (0)