Nvidia Cudatoolkit 与 Conda Cudatoolkit

2022-01-10 00:00:00 python tensorflow conda anaconda

问题描述

到目前为止,我一直在使用 Tensorflow-GPU,通过 pip 以及 Nvidia 网站上的 Cuda 相关软件和 Nvidia 软件/驱动程序安装它强>.最近发现使用conda install tensorflow-gpu也安装了cudatoolkit和cudnn.

Till date, I have been using Tensorflow-GPU by installing it using pip and the Cuda related software and Nvidia softwares/drivers from Nvidia's website. Recently, I found that using conda install tensorflow-gpu also installs cudatoolkit and cudnn.

那么,这些(conda 提供的)与我从 Nvidia 网站下载的有什么不同?

So, how are these(the ones provided by conda) different from the ones that I downloaded from Nvidia's website?

在我的第一个(以前的)环境中,conda list 显示我只安装了 TensorFlow(来自 PyPi),没有安装 cudnn/cudatoolkit,但一切正常.

In my first (previous) environment, conda list showed that I have installed only TensorFlow(from PyPi) and no cudnn/cudatoolkit, but still everything worked.

另外,在我运行 conda install tensorflow-gpu 的新环境中,conda list 显示 tensorflow-gpu 已安装以及 Anaconda 的 cudatoolkit 和 cudnn.在这种环境下,一切正常.

Also, in a new environment in which I ran conda install tensorflow-gpu, conda list showed me tensorflow-gpu has been installed along with cudatoolkit and cudnn by Anaconda. And in this environment also, everything worked fine.

这是否意味着,如果我使用 pip 安装 TensorFlow,则仅需要从 Nvidia 网站下载和安装 Cuda?

So does this mean, that downloading and installing Cuda from Nvidia's website is only necessary if I use pip to install TensorFlow?


解决方案

如果使用 anaconda 安装 tensorflow-gpu,是的,它会在与 tensorflow-gpu 相同的 conda 环境中为您安装 cuda 和 cudnn.您只需要自己安装最新的 nvidia 驱动程序(以便它适用于最新的 CUDA 级别和您使用的所有旧 CUDA 级别.)

If using anaconda to install tensorflow-gpu, yes it will install cuda and cudnn for you in same conda environment as tensorflow-gpu. All you need to install yourself is the latest nvidia-driver (so that it works with the latest CUDA level and all older CUDA levels you use.)

这比 pip install tensorflow-gpu 方法有很多优点:

This has many advantages over the pip install tensorflow-gpu method:

  1. Anaconda 将始终安装 TensorFlow 代码编译后使用的 CUDA 和 CuDNN 版本.
  2. 您可以拥有多个具有不同级别 TensorFlow、CUDA 和 CuDNN 的 conda 环境,只需使用 conda activate 在它们之间切换.
  3. 您不必在系统级别手动安装 CUDA 和 cuDNN.

与 pip install tensorflow-gpu 相比的缺点是,在 Anaconda 能够更新 conda 配方并发布其最新 TensorFlow 版本的构建之前几周,最新版本的 tensorflow 被添加到 pypi.

The disadvantage when compared to pip install tensorflow-gpu, is the latest version of tensorflow is added to pypi weeks before Anaconda is able to update the conda recipe and publish their builds of the latest TensorFlow version.

相关文章