[core][misc] update libcudart finding (#7620)
Co-authored-by: cjackal <44624812+cjackal@users.noreply.github.com>
This commit is contained in:
parent
5bf45db7df
commit
d95cc0a55c
@ -49,8 +49,13 @@ def find_loaded_library(lib_name) -> Optional[str]:
|
||||
if not found:
|
||||
# the library is not loaded in the current process
|
||||
return None
|
||||
# if lib_name is libcudart, we need to match a line with:
|
||||
# address /path/to/libcudart-hash.so.11.0
|
||||
start = line.index("/")
|
||||
path = line[start:].strip()
|
||||
filename = path.split("/")[-1]
|
||||
assert filename.rpartition(".so")[0].startswith(lib_name), \
|
||||
f"Unexpected filename: {filename} for library {lib_name}"
|
||||
return path
|
||||
|
||||
|
||||
@ -98,9 +103,9 @@ class CudaRTLibrary:
|
||||
|
||||
def __init__(self, so_file: Optional[str] = None):
|
||||
if so_file is None:
|
||||
so_file = find_loaded_library("libcudart.so")
|
||||
so_file = find_loaded_library("libcudart")
|
||||
assert so_file is not None, \
|
||||
"libcudart.so is not loaded in the current process"
|
||||
"libcudart is not loaded in the current process"
|
||||
if so_file not in CudaRTLibrary.path_to_library_cache:
|
||||
lib = ctypes.CDLL(so_file)
|
||||
CudaRTLibrary.path_to_library_cache[so_file] = lib
|
||||
|
||||
Loading…
Reference in New Issue
Block a user