in minihack/scripts/collect_env.py [0:0]
def get_cudnn_version(run_lambda):
"""This will return a list of libcudnn.so
It's hard to tell which one is being used.
"""
if get_platform() == "win32":
cudnn_cmd = 'where /R "%CUDA_PATH%\\bin" cudnn*.dll'
elif get_platform() == "darwin":
# CUDA libraries and drivers can be found in /usr/local/cuda/. See
# https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#install # noqa
# https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installmac # noqa
# Use CUDNN_LIBRARY when cudnn library is installed elsewhere.
cudnn_cmd = "ls /usr/local/cuda/lib/libcudnn*"
else:
cudnn_cmd = 'ldconfig -p | grep libcudnn | rev | cut -d" " -f1 | rev'
rc, out, _ = run_lambda(cudnn_cmd)
# find will return 1 if there are permission errors or if not found
if len(out) == 0 or (rc != 1 and rc != 0):
cl = os.environ.get("CUDNN_LIBRARY")
if cl is not None and os.path.isfile(cl):
return os.path.realpath(cl)
return None
files = set()
for fn in out.split("\n"):
fn = os.path.realpath(fn) # eliminate symbolic links
if os.path.isfile(fn):
files.add(fn)
if not files:
return None
# Alphabetize the result because the order is non-deterministic otherwise
files = list(sorted(files))
if len(files) == 1:
return files[0]
result = "\n".join(files)
return "Probably one of the following:\n{}".format(result)