MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / get_cudnn_version

Function get_cudnn_version

fastdeploy/collect_env.py:219–253  ·  view source on GitHub ↗

Return a list of libcudnn.so; it's hard to tell which one is being used.

(run_lambda)

Source from the content-addressed store, hash-verified

217
218
219def get_cudnn_version(run_lambda):
220 """Return a list of libcudnn.so; it's hard to tell which one is being used."""
221 if get_platform() == "win32":
222 system_root = os.environ.get("SYSTEMROOT", "C:\\Windows")
223 cuda_path = os.environ.get("CUDA_PATH", "%CUDA_PATH%")
224 where_cmd = os.path.join(system_root, "System32", "where")
225 cudnn_cmd = '{} /R "{}\\bin" cudnn*.dll'.format(where_cmd, cuda_path)
226 elif get_platform() == "darwin":
227 # CUDA libraries and drivers can be found in /usr/local/cuda/. See
228 # https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#install
229 # https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installmac
230 # Use CUDNN_LIBRARY when cudnn library is installed elsewhere.
231 cudnn_cmd = "ls /usr/local/cuda/lib/libcudnn*"
232 else:
233 cudnn_cmd = 'ldconfig -p | grep libcudnn | rev | cut -d" " -f1 | rev'
234 rc, out, _ = run_lambda(cudnn_cmd)
235 # find will return 1 if there are permission errors or if not found
236 if len(out) == 0 or (rc != 1 and rc != 0):
237 l = os.environ.get("CUDNN_LIBRARY")
238 if l is not None and os.path.isfile(l):
239 return os.path.realpath(l)
240 return None
241 files_set = set()
242 for fn in out.split("\n"):
243 fn = os.path.realpath(fn) # eliminate symbolic links
244 if os.path.isfile(fn):
245 files_set.add(fn)
246 if not files_set:
247 return None
248 # Alphabetize the result because the order is non-deterministic otherwise
249 files = sorted(files_set)
250 if len(files) == 1:
251 return files[0]
252 result = "\n".join(files)
253 return "Probably one of the following:\n{}".format(result)
254
255
256def get_nvidia_smi():

Callers 1

get_env_infoFunction · 0.85

Calls 6

get_platformFunction · 0.85
joinMethod · 0.80
splitMethod · 0.80
getMethod · 0.45
formatMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected