Which TensorFlow and CUDA version combinations are compatible?

415,130

Solution 1

TL;DR) See this table: https://www.tensorflow.org/install/source#gpu

Generally:

Check the CUDA version:

cat /usr/local/cuda/version.txt

and cuDNN version:

grep CUDNN_MAJOR -A 2 /usr/local/cuda/include/cudnn.h

and install a combination as given below in the images or here.

The following images and the link provide an overview of the officially supported/tested combinations of CUDA and TensorFlow on Linux, macOS and Windows:

Minor configurations:

Since the given specifications below in some cases might be too broad, here is one specific configuration that works:

  • tensorflow-gpu==1.12.0
  • cuda==9.0
  • cuDNN==7.1.4

The corresponding cudnn can be downloaded here.

Tested build configurations

Please refer to https://www.tensorflow.org/install/source#gpu for a up-to-date compatibility chart (for official TF wheels).

(figures updated May 20, 2020)

Linux GPU

enter image description here

Linux CPU

enter image description here

macOS GPU

enter image description here

macOS CPU

enter image description here

Windows GPU

enter image description here

Windows CPU

enter image description here

Updated as of Dec 5 2020: For the updated information please refer Link for Linux and Link for Windows.

Solution 2

The compatibility table given in the tensorflow site does not contain specific minor versions for cuda and cuDNN. However, if the specific versions are not met, there will be an error when you try to use tensorflow.

For tensorflow-gpu==1.12.0 and cuda==9.0, the compatible cuDNN version is 7.1.4, which can be downloaded from here after registration.

You can check your cuda version using
nvcc --version

cuDNN version using
cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2

tensorflow-gpu version using
pip freeze | grep tensorflow-gpu

UPDATE: Since tensorflow 2.0, has been released, I will share the compatible cuda and cuDNN versions for it as well (for Ubuntu 18.04).

  • tensorflow-gpu = 2.0.0
  • cuda = 10.0
  • cuDNN = 7.6.0

Solution 3

if you are coding in jupyter notebook, and want to check which cuda version tf is using, run the follow command directly into jupyter cell:

!conda list cudatoolkit

!conda list cudnn

and to check if the gpu is visible to tf:

tf.test.is_gpu_available(
    cuda_only=False, min_cuda_compute_capability=None
)

Solution 4

You can use this configuration for cuda 10.0 (10.1 does not work as of 3/18), this runs for me:

  • tensorflow>=1.12.0
  • tensorflow_gpu>=1.4

Install version tensorflow gpu:

pip install tensorflow-gpu==1.4.0

Solution 5

Thanks for the first answer.

Something about backward compatibility.

I can successfully install tensorflow-2.4.0 with cuda-11.1 and cudnn 8.0.5.

enter image description here

Share:
415,130

Related videos on Youtube

whiletrue
Author by

whiletrue

CS MSc, Machine Learning PhD student. Follow me on Instagram.

Updated on April 03, 2022

Comments

  • whiletrue
    whiletrue about 2 years

    I have noticed that some newer TensorFlow versions are incompatible with older CUDA and cuDNN versions. Does an overview of the compatible versions or even a list of officially tested combinations exist? I can't find it in the TensorFlow documentation.

    • whiletrue
      whiletrue almost 6 years
      The question was addressing compatibility and (officially) tested combinations which, in my view, are not provided in the instructions for installation. Also, I cannot find the section you're referring to. These observations result in my overall view that the requested information is hard to find and therefore justifies providing easy access to the link posted in the answer.
    • P-Gn
      P-Gn almost 6 years
      You will find that the CUDA and cuDNN versions on the page you mention match the one of the installation instructions.
    • P-Gn
      P-Gn almost 6 years
      To find the installation instructions, go to the page I linked above then follow the link for your OS.
    • whiletrue
      whiletrue almost 6 years
      The section you're referring to just gives me the compatible version for CUDA and cuDNN --ONCE-- I have found out about my desired TensorFlow version. In the common case (for example in .edu lab environments) where CUDA and cuDNN are already installed but TF not, the necessity for an overview becomes apparent. My claim is that it's quite hidden and hard to find (I wasn't apple to find it via googling).
    • P-Gn
      P-Gn almost 6 years
      Oh I see what you mean -- trying to see which tensorflow version fits a particular CUDA/cuDNN combination. You could browse TF's release notes but the table you link to is indeed a good summary.
    • Ketki Shroff
      Ketki Shroff about 5 years
      Working : tensorflow 1.13.1, CUDA 10, CUDNN 7.4.2, python 3.6 (does not work well with 3.7.. 3.7 has many bugs) For Windows 10
    • Jongwook Choi
      Jongwook Choi almost 4 years
      This is probably all you need for the CUDNN/CUDA version compatibility information for prebuilt packages: tensorflow.org/install/source#gpu
    • Cadoiz
      Cadoiz almost 4 years
      For the last current releases, this could be useful: tensorflow.org/install/gpu - possibly use e.g. the wayback machine to go back in time?
  • whiletrue
    whiletrue almost 6 years
    I did notice though that TensorFlow versions < 1.0 have been excluded from the overview. Does somebody have an idea where to find the same list for older versions?
  • mrgloom
    mrgloom over 5 years
    Looks like they don't specify minor versions for cuda and cudnn,
  • Vikrame
    Vikrame over 5 years
    Your answer was very useful. Like you said the documentation was not very clear to call out the minor versions. I followed your configuration and it worked !
  • whiletrue
    whiletrue over 5 years
    We could maintain a list of minor configurations here. Feel free to edit the post and add working configurations that you have tested.
  • pafi
    pafi over 5 years
    UPDATE: Now tensorflow-gpu==1.12.0 requires cuDNN version 7.2.1 or higher on Windows.
  • mjaniec
    mjaniec over 5 years
    UPDATE: tested TF-GPU 1.12, Windows 10, CUDA 9.0, CuDNN 7.3.1, Python 3.6.6
  • jottbe
    jottbe almost 5 years
    It seems the link on "The corresponding cudnn can be downloaded here." is outdated.
  • Trylks
    Trylks over 4 years
    Don't update the figures, link to the documentation. The link changes less often than the tables
  • Tensorflow Support
    Tensorflow Support over 4 years
    @Fábio: Updated your answer with the Latest Links as per your request.
  • ivan866
    ivan866 almost 4 years
    10.0 is CUDA SDK version; 7.5 is Compute Capability of the GPU itself
  • ivan866
    ivan866 almost 4 years
    I believe provided images with libs combinations are simply a list of one possible combination for each given TF version, which was compiled for downloading by the repo holders. Others are possible and compatible, perhaps.
  • ivan866
    ivan866 almost 4 years
    Is it possible to train a TF1.4 model on a CUDA10 gpu card?
  • ivan866
    ivan866 almost 4 years
    I believe utilising nvidia-docker software layer can deal with the problem of incompatible cuda-tf combinations. Describing how you found out which libs need to be rerouted with symlinks will also be good.
  • ivan866
    ivan866 almost 4 years
    So, that effectively means that newer gpu cards do NOT support older software stacks, meaning the backwards compatibility is broken indeed? #NVIDIA
  • Valentin Goldité
    Valentin Goldité about 2 years
    Hello, can you tell me where did you find this chart please? When I click on the link provided in the messages above the chart stops at Tensorflow 2.6...
  • one
    one about 2 years