24

There is a tensorflow-gpu version installed on Windows using Anaconda, how to check the CUDA and CUDNN version of it? Thanks.

talonmies
  • 70,661
  • 34
  • 192
  • 269
user297850
  • 7,705
  • 17
  • 54
  • 76

4 Answers4

46

Use the following command to check CUDA installation by Conda:

conda list cudatoolkit

And the following command to check CUDNN version installed by conda:

conda list cudnn

If you want to install/update CUDA and CUDNN through CONDA, please use the following commands:

conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn

Alternatively you can use following commands to check CUDA installation:

nvidia-smi

OR

nvcc --version
SidK
  • 1,174
  • 1
  • 9
  • 9
  • 12
    nvidia-smi does not give you the installed version, just the supported one, which is of no use for the question, – questionto42 Jul 30 '20 at 18:55
  • 5
    nvcc --version is not working in anaconda prompt if you have the cuda toolkit installed with conda. – questionto42 Jul 30 '20 at 18:56
  • Mind that in conda, you should not manually install cudatoolkit and cudnn if you want to install it for pytorch or tensorflow. Use the conda installers of either of them which cover dependencies automatically. – questionto42 Jul 30 '20 at 19:05
21

You could also run conda list from the anaconda command line:

conda list cudnn

# packages in environment at C:\Anaconda2:
#
# Name                    Version                   Build  Channel
cudnn                     6.0                           0
John H
  • 326
  • 2
  • 6
10

Although not a public documented API, you can currently access it like this:

from tensorflow.python.platform import build_info as tf_build_info
print(tf_build_info.cuda_version_number)
# 9.0 in v1.10.0
print(tf_build_info.cudnn_version_number)
# 7 in v1.10.0
jdehesa
  • 58,456
  • 7
  • 77
  • 121
  • 1
    @iyop45 Thanks for the feedback, you're right, recent TensorFlow versions do not include that information in `build_info` anymore. I have [opened an issue about it](https://github.com/tensorflow/tensorflow/issues/26395), it seems to be a consequence of deprecating CMake for Windows builds in favor of Bazel. – jdehesa Mar 06 '19 at 12:15
  • @iyop45 This has just been fixed on [this commit](https://github.com/tensorflow/tensorflow/commit/9a43dfeac58477c37cb356e3759b053d2bbd0247). Not sure which release will first feature the fix though. – jdehesa Mar 15 '19 at 15:23
6

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__)
'2.4.1'
>>> 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'])
11.0
>>> print(build.build_info['cudnn_version'])
8

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; print(tf_build_info.cuda_version_number) like in jdehesa's answer.

mrtpk
  • 1,398
  • 4
  • 18
  • 38