《版本问题!!!!》win10下选择CUDA版本和Cudnn版本,以及匹配tensorflow和Keras。

本文介绍了TensorFlow及相关组件的版本选择和安装方法。先查看显卡型号,下载安装对应驱动,确定cuda版本。版本选择遵循不选最新版、次新级版本兼容优先、结合语言环境等原则。还给出了Python、anaconda等版本建议,最后说明了安装步骤和检测方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

先查看自己的显卡型号,

然后去官网上找到自己的显卡驱动的版本号,并下载安装。

再对应下表确定cuda的版本。

NVIDIA官网CUDA版本和显卡驱动版本对应

CUDA ToolkitLinux x86_64 Driver VersionWindows x86_64 Driver Version
CUDA 11.1.1 Update 1>=455.32>=456.81
CUDA 11.1 GA>=455.23>=456.38
CUDA 11.0.3 Update 1>= 450.51.06>= 451.82
CUDA 11.0.2 GA>= 450.51.05>= 451.48
CUDA 11.0.1 RC>= 450.36.06>= 451.22
CUDA 10.2.89>= 440.33>= 441.22
CUDA 10.1 (10.1.105 general release, and updates)>= 418.39>= 418.96
CUDA 10.0.130>= 410.48>= 411.31
CUDA 9.2 (9.2.148 Update 1)>= 396.37>= 398.26
CUDA 9.2 (9.2.88)>= 396.26>= 397.44
CUDA 9.1 (9.1.85)>= 390.46>= 391.29
CUDA 9.0 (9.0.76)>= 384.81>= 385.54
CUDA 8.0 (8.0.61 GA2)>= 375.26>= 376.51
CUDA 8.0 (8.0.44)>= 367.48>= 369.30
CUDA 7.5 (7.5.16)>= 352.31>= 353.66
CUDA 7.0 (7.0.28)>= 346.46>= 347.62

TensorFlow官网上windows经过测试的构建配置对应版本

GPU

版本

P

ython 版本

编译器构建工具cuDNNCUDA
tensorflow_gpu-2.3.03.5-3.8MSVC 2019Bazel 3.1.07.410.1
tensorflow_gpu-2.2.03.5-3.8MSVC 2019Bazel 2.0.07.410.1
tensorflow_gpu-2.1.03.5-3.7MSVC 2019Bazel 0.27.1-0.29.17.410.1
tensorflow_gpu-2.0.03.5-3.7MSVC 2017Bazel 0.26.17.410
tensorflow_gpu-1.15.03.5-3.7MSVC 2017Bazel 0.26.17.410
tensorflow_gpu-1.14.03.5-3.7MSVC 2017Bazel 0.24.1-0.25.27.410
tensorflow_gpu-1.13.03.5-3.7MSVC 2015 update 3Bazel 0.19.0-0.21.07.410
tensorflow_gpu-1.12.03.5-3.6MSVC 2015 update 3Bazel 0.15.079
tensorflow_gpu-1.11.03.5-3.6MSVC 2015 update 3Bazel 0.15.079
tensorflow_gpu-1.10.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.9.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.8.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.7.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.6.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.5.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.4.03.5-3.6MSVC 2015 update 3Cmake v3.6.368
tensorflow_gpu-1.3.03.5-3.6MSVC 2015 update 3Cmake v3.6.368
tensorflow_gpu-1.2.03.5-3.6MSVC 2015 update 3Cmake v3.6.35.18
tensorflow_gpu-1.1.03.5MSVC 2015 update 3Cmake v3.6.35.18
tensorflow_gpu-1.0.03.5MSVC 2015 update 3Cmake v3.6.35.18

TensorFlow与Keras版本对应

FrameworkEnv name (--env parameter)DescriptionDocker ImagePackages and Nvidia Settings
TensorFlow 2.2tensorflow-2.2TensorFlow 2.2.0 + Keras 2.3.1 on Python 3.7.floydhub/tensorflowTensorFlow-2.2
TensorFlow 2.1tensorflow-2.1TensorFlow 2.1.0 + Keras 2.3.1 on Python 3.6.floydhub/tensorflowTensorFlow-2.1
TensorFlow 2.0tensorflow-2.0TensorFlow 2.0.0 + Keras 2.3.1 on Python 3.6.floydhub/tensorflowTensorFlow-2.0
TensorFlow 1.15tensorflow-1.15TensorFlow 1.15.0 + Keras 2.3.1 on Python 3.6.floydhub/tensorflowTensorFlow-1.15
TensorFlow 1.14tensorflow-1.14TensorFlow 1.14.0 + Keras 2.2.5 on Python 3.6.floydhub/tensorflowTensorFlow-1.14
TensorFlow 1.13tensorflow-1.13TensorFlow 1.13.0 + Keras 2.2.4 on Python 3.6.floydhub/tensorflowTensorFlow-1.13
TensorFlow 1.12tensorflow-1.12TensorFlow 1.12.0 + Keras 2.2.4 on Python 3.6.floydhub/tensorflowTensorFlow-1.12
tensorflow-1.12:py2TensorFlow 1.12.0 + Keras 2.2.4 on Python 2.floydhub/tensorflow
TensorFlow 1.11tensorflow-1.11TensorFlow 1.11.0 + Keras 2.2.4 on Python 3.6.floydhub/tensorflowTensorFlow-1.11
tensorflow-1.11:py2TensorFlow 1.11.0 + Keras 2.2.4 on Python 2.floydhub/tensorflow
TensorFlow 1.10tensorflow-1.10TensorFlow 1.10.0 + Keras 2.2.0 on Python 3.6.floydhub/tensorflowTensorFlow-1.10
tensorflow-1.10:py2TensorFlow 1.10.0 + Keras 2.2.0 on Python 2.floydhub/tensorflow
TensorFlow 1.9tensorflow-1.9TensorFlow 1.9.0 + Keras 2.2.0 on Python 3.6.floydhub/tensorflowTensorFlow-1.9
tensorflow-1.9:py2TensorFlow 1.9.0 + Keras 2.2.0 on Python 2.floydhub/tensorflow
TensorFlow 1.8tensorflow-1.8TensorFlow 1.8.0 + Keras 2.1.6 on Python 3.6.floydhub/tensorflowTensorFlow-1.8
tensorflow-1.8:py2TensorFlow 1.8.0 + Keras 2.1.6 on Python 2.floydhub/tensorflow
TensorFlow 1.7tensorflow-1.7TensorFlow 1.7.0 + Keras 2.1.6 on Python 3.6.floydhub/tensorflowTensorFlow-1.7
tensorflow-1.7:py2TensorFlow 1.7.0 + Keras 2.1.6 on Python 2.floydhub/tensorflow
TensorFlow 1.5tensorflow-1.5TensorFlow 1.5.0 + Keras 2.1.6 on Python 3.6.floydhub/tensorflowTensorFlow-1.5
tensorflow-1.5:py2TensorFlow 1.5.0 + Keras 2.1.6 on Python 2.floydhub/tensorflow
TensorFlow 1.4tensorflow-1.4TensorFlow 1.4.0 + Keras 2.0.8 on Python 3.6.floydhub/tensorflow
tensorflow-1.4:py2TensorFlow 1.4.0 + Keras 2.0.8 on Python 2.floydhub/tensorflow
TensorFlow 1.3tensorflow-1.3TensorFlow 1.3.0 + Keras 2.0.6 on Python 3.6.floydhub/tensorflow
tensorflow-1.3:py2TensorFlow 1.3.0 + Keras 2.0.6 on Python 2.floydhub/tensorflow
TensorFlow 1.2tensorflow-1.2TensorFlow 1.2.0 + Keras 2.0.6 on Python 3.5.floydhub/tensorflow
tensorflow-1.2:py2TensorFlow 1.2.0 + Keras 2.0.6 on Python 2.floydhub/tensorflow
TensorFlow 1.1tensorflowTensorFlow 1.1.0 + Keras 2.0.6 on Python 3.5.floydhub/tensorflow
tensorflow:py2TensorFlow 1.1.0 + Keras 2.0.6 on Python 2.floydhub/tensorflow
TensorFlow 1.0tensorflow-1.0TensorFlow 1.0.0 + Keras 2.0.6 on Python 3.5.floydhub/tensorflow
tensorflow-1.0:py2TensorFlow 1.0.0 + Keras 2.0.6 on Python 2.floydhub/tensorflow
TensorFlow 0.12tensorflow-0.12TensorFlow 0.12.1 + Keras 1.2.2 on Python 3.5.floydhub/tensorflow
tensorflow-0.12:py2TensorFlow 0.12.1 + Keras 1.2.2 on Python 2.floydhub/tensorflow

本文写作时间2020年12月1日,请参照最新表格选择。以上并不绝对,只是大厂做的匹配推荐。

选择版本:第一原则:别选最新版本。

我们尊重新鲜事物的产生,我们也非常喜欢新鲜事物,新的版本代表着新的功能和新的效果。但是新的并非最好。特别是涉及到版本兼容问题时。

经实际测试效果,如果装tensorflow 2以上的版本,会出现各种问题。原因如下:第一句翻译:TF2.0中很多API要么....要么...。所以呀,为了眼下的方便,不考虑以后的话。先装TF1.0版本吧。

Many APIs are either gone or moved in TF 2.0. Some of the major changes include removing tf.app, tf.flags, and tf.logging in favor of the now open-source absl-py, rehoming projects that lived in tf.contrib, and cleaning up the main tf.* namespace by moving lesser used functions into subpackages like tf.math.

第二原则:次新级版本兼容优先考虑。(不绝对)

根据:TF版本,观察Cuda的版本,我们发现10.1都对应TF2.0,所以,我们退一步,让一步,选择CUDA10.0。这样让我们接下来选择的空间更大。CUDA10.0让我们可进可退。后续转TF2.0也支持。

本人笔记本NVIDIA GeForce GTX 1070。选择CUDA10.0。对应显卡驱动版本CUDA Toolkit and Compatible Driver Versions>=411.31。只要大于这个版本都支持。这个可以放心选择。CuDnn按照表推荐7.4

CUDNN7.4限制tensorFlow对应的版本,也限制在了tensorFlow1.13以上的版本。可选项只有13,14,15三个版本。15在匹配Keras的时候,需要匹配最新keras,所以我们选择13或者14。稳妥点选择13

TensorFlow建议keras2.2.4。这下子所有版本齐了。

第三原则:语言环境与第二原则一起考虑。

考虑Python的版本,你要考虑你的其他使用场景,要让Python支持更多的场景。目前根据我的应用场景选择3.6稳妥些。因为我的需求中有些模块点明不支持3.5以下版本,有些模块又不支持太新3.7也不妥。完全是被动呀。不过你看表3.6支持的版本最多呀。欣慰至甚,欢欣甚慰。以此你也可以看出python3.6目前也是Python比较好的一个版本选择。

如果安装anaconda:请参照下图:

 选择anaconda 3.5.2合适。


先装显卡驱动,后装CUDA,然后复制替换CUDNN

安装完CUDA后需要配置环境变量

检测CMD下输入:nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130

安装Python3.6.5

然后安装Tensorflow。

pip install tensorflow_gpu==1.13.1 -i https://pypi.tuna.tsinghua.edu.cn/simple 

或者下面的命令适合你:

python3 -m pip install tensorflow_gpu==1.4.0
后面数字是你版本号。

再不行,从PyPI自己下载轮子。对应好python和系统的版本找版本下载(浏览器下载慢,直接用迅雷下)。直接pip install相应whl。

pip install .\tensorflow_gpu-1.13.1-cp36-cp36m-win_amd64.whl

import tensorflow as tf
tf.__version__

可以输出版本号即安装正确。

安装Keras。Over。

pip3 install keras==2.2.4 -i https://pypi.tuna.tsinghua.edu.cn/simple

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值