使用 Conda 安装 Tensorflow 1.15 + CUDA + cuDNN

Tensorflow 1.15 + CUDA + cuDNN installation using Conda

我正在尝试使用 Conda 安装 tensorflow-gpu 1.15,以便轻松安装 CUDA 和 cuDNN。问题是查看官网compatibility chart需要python3.6,CUDA 10.0和cuDNN 7.4.

通过 conda search cudnn 搜索 Conda 代表,它说没有 cuDNN 7.4。还有其他方法可以安装所需的软件包吗?或者 tensorflow 1.15 也可以与其他版本组合一起使用?

附带说明一下,python 3.6、tensorflow-gpu 1.15 和 CUDA 10 安装正确,但如果没有 cuDNN,我似乎无法正确使用 GPU。 我最近才开始使用 Conda,所以也许有一种我没有意识到的直接方法可以做到这一点。我的 Conda 版本是 4.9.1(miniconda 版本)。

---更新---

以防我在尝试时添加错误 conda create -n myenv -c conda-forge tensorflow-gpu=1.15:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: - 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                                                                                                        

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions

Package _tflow_select conflicts for:
_tflow_select==2.1.0=gpu
tensorflow==1.15.0 -> _tflow_select[version='2.1.0|2.3.0|2.2.0',build='gpu|mkl|eigen']
Note that strict channel priority may have removed packages required for satisfiability.

我不确定是否是这个问题,但我是按照以下方式安装的

conda create -n tensorflow1.15 python=3.5
conda activate tensorflow1.15
conda install cudatoolkit=10.0
conda install cudnn=7.3.1
pip3 install tensorflow-gpu==1.15

而且它似乎与 GPU 完美配合。我不知道 cuDNN 7.3.1 像 7.4 一样工作。最好的方法是用conda安装tensorflow,但是它给我一个尝试安装tensorflow-gpu=2.X.

的错误

也许有趣的是,您可以使用 conda search -c nvidia <packageName> 搜索 CUDA 和类似的官方安装程序。

我会让 conda 通过 conda 安装 tensorflow 来处理所有依赖项,而不是 pip。 tensorflow 的 GPU 版本可用,例如在热门 conda-forge 频道中:

conda create -n myenv -c conda-forge tensorflow-gpu=1.15

TensorFlow 1.15 的最佳设置是遵循此处的指南:https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/tensorflow-1.14/install.html#tf-install。推荐的CUDA版本是10.0,cudNN版本是7.6.5

注意要安装的protobuf版本,如果执行gpu版本是4.21.1,但是要改写命令:pip install --upgrade tensorflow-gpu==1.15“protobuf<4.0”。如果您使用 cpu 版本,建议在此处使用此版本:(https://github.com/protocolbuffers/protobuf/releases/tag/v3.4.0) 以避免 errors.Just 下载 protoc-3.4.0-win32.zip (windows)

希望对您有所帮助。