Check compatibility between given library and cudnn/cudart libraries.
(lib, cuda_ver, cudnn_ver)
| 900 | |
| 901 | |
| 902 | def is_cuda_compatible(lib, cuda_ver, cudnn_ver): |
| 903 | """Check compatibility between given library and cudnn/cudart libraries.""" |
| 904 | ldd_bin = which('ldd') or '/usr/bin/ldd' |
| 905 | ldd_out = run_shell([ldd_bin, lib], True) |
| 906 | ldd_out = ldd_out.split(os.linesep) |
| 907 | cudnn_pattern = re.compile('.*libcudnn.so\\.?(.*) =>.*$') |
| 908 | cuda_pattern = re.compile('.*libcudart.so\\.?(.*) =>.*$') |
| 909 | cudnn = None |
| 910 | cudart = None |
| 911 | cudnn_ok = True # assume no cudnn dependency by default |
| 912 | cuda_ok = True # assume no cuda dependency by default |
| 913 | for line in ldd_out: |
| 914 | if 'libcudnn.so' in line: |
| 915 | cudnn = cudnn_pattern.search(line) |
| 916 | cudnn_ok = False |
| 917 | elif 'libcudart.so' in line: |
| 918 | cudart = cuda_pattern.search(line) |
| 919 | cuda_ok = False |
| 920 | if cudnn and len(cudnn.group(1)): |
| 921 | cudnn = convert_version_to_int(cudnn.group(1)) |
| 922 | if cudart and len(cudart.group(1)): |
| 923 | cudart = convert_version_to_int(cudart.group(1)) |
| 924 | if cudnn is not None: |
| 925 | cudnn_ok = (cudnn == cudnn_ver) |
| 926 | if cudart is not None: |
| 927 | cuda_ok = (cudart == cuda_ver) |
| 928 | return cudnn_ok and cuda_ok |
| 929 | |
| 930 | |
| 931 | def set_tf_tensorrt_version(environ_cp): |
nothing calls this directly
no test coverage detected