Home > Enterprise >  Pytorch vs. Tensorflow CUDA Versions
Pytorch vs. Tensorflow CUDA Versions

Time:01-25

I currently have Pytorch (version 1.13.1 cu116) setup. It detects the GPU and works fine with CUDA version 11.6. Below is my output from running nvidia-smi:

enter image description here

I am now trying to setup tensorflow with GPU support. However, it is not working with CUDA version 11.6 (doesn't detect my GPU when using tf.config.list_physical_devices) and upon further examination the latest versions of tensorflow only support up to CUDA 11.2.

If I try to install CUDA version 11.2 the installer quits out saying "You already have a newer version of the NVIDIA Frameview SDK installed", which is understandable considering my CUDA 11.6 installation for pytorch. My question is, if I uninstall CUDA 11.6 and install CUDA 11.2 for tensorflow, will this break my pytorch GPU support? Or is pytorch backwards compatible with previous CUDA versions? What is the best way to get both tensorflow and pytorch working with my GPU since they both support different CUDA versions?

Any assistance is greatly appreciated.

CodePudding user response:

PyTorch is generally backwards-compatible with previous CUDA versions, so uninstalling CUDA 11.6 and installing CUDA 11.2 should not break your PyTorch GPU support. However, you may need to reinstall PyTorch with the appropriate CUDA version specified in order for it to work properly.

To get both TensorFlow and PyTorch working with your GPU you could use multiple versions of CUDA and cuDNN (this library required by both TensorFlow and PyTorch to run on the GPU) in your system. You can install CUDA 11.2 and cuDNN 8.0.4 (the latest version that supports CUDA 11.2) for TensorFlow, and keep CUDA 11.6 and cuDNN 11.0 for PyTorch. Then you can use the appropriate version of CUDA and cuDNN for each library by specifying the correct environment variables or by creating separate conda/virtual environments for each library.

You could also use Docker and create a container for each library with the appropriate CUDA and cuDNN versions and use them separately.

  • Related