How can I get the build information of an existing tensorflow binary within tensorflow?


I have installed tensorflow-gpu 1.12 via pip. I’d like to know which CUDA, cuDNN this binary was built against. Is there a way to find this information directly from the tensorflow package? e.g.

import tensorflow as tf

I’ve tried searching google, SO, and the tensorflow documentation but haven’t found anything useful.

I thought it might exist as numpy implements something similar:

import numpy as np


As of TensorFlow 2.4.1, We can use tensorflow.python.platform.build_info to get information on which CUDA, cuDNN the binary was built against.

>>> import tensorflow
>>> print(tensorflow.__version__)
>>> import tensorflow.python.platform.build_info as build
>>> print(build.build_info)
OrderedDict([('cpu_compiler', '/usr/bin/gcc-5'), ('cuda_compute_capabilities', ['sm_35', 'sm_50', 'sm_60', 'sm_70', 'sm_75', 'compute_80']), ('cuda_version', '11.0'), ('cudnn_version', '8'), ('is_cuda_build', True), ('is_rocm_build', False)])

The build.build_info is an OrderedDict. So to get CuDNN and CUDA versions:

>>> print(build.build_info['cuda_version'])
>>> print(build.build_info['cudnn_version'])

Note: As this is not a public API, things can change in future versions. In previous versions, we could do:

from tensorflow.python.platform import build_info as tf_build_info;

Answered By – tpk

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published