[FRONTEND] add informative erro msg to help find libcuda (#2019)

When I'm using Kaggle GPU (https://www.kaggle.com/), I find that
`ldconfig -p` does not show libcuda.so, but requires `ldconfig` (run
with sudo) to refresh the cache to find the libcuda.so.

Therefore, I added this informative message to help users find
libcuda.so.
This commit is contained in:
youkaichao
2023-08-18 07:32:00 +08:00
committed by GitHub
parent 387fc890a5
commit 871ec2ad37

View File

@@ -18,7 +18,7 @@ def is_hip():
@functools.lru_cache()
def libcuda_dirs():
libs = subprocess.check_output(["ldconfig", "-p"]).decode()
libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode()
# each line looks like the following:
# libcuda.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcuda.so.1
locs = [line.split()[-1] for line in libs.splitlines() if "libcuda.so" in line]
@@ -27,6 +27,9 @@ def libcuda_dirs():
if locs:
msg += 'Possible files are located at %s.' % str(locs)
msg += 'Please create a symlink of libcuda.so to any of the file.'
else:
msg += 'Please make sure GPU is setup and then run "/sbin/ldconfig"'
msg += ' (requires sudo) to refresh the linker cache.'
assert any(os.path.exists(os.path.join(path, 'libcuda.so')) for path in dirs), msg
return dirs