Anaconda搭建Tensorflow-GPU和Keras的深度学习开发环境

目录

具体步骤

创建虚拟环境

切换进入虚拟环境:

安装 cudatoolkit

安装 cudnn

虚拟环境更新 pip(根据tensorflow版本需求更新)

安装tensorflow-gpu

安装Keras

Tensorflow-GPU和Keras经过测试的构建配置


引言

在Windows上安装了 Anaconda3 ,可通过搭建虚拟环境,快速安装Tensorflow-GPU和Keras的深度学习开发环境。
具体可参考官方文档

虚拟环境搭建

以下面的配置为笔者安装测试的虚拟环境,读者可根据自己的实际需求更改配置版本。
安装之前,一定要查看文末的tensorflow_gpu版本与python、cuda、cudnn的对应关系

安装包版本
cudatoolkit9.2
cudnn7.6.5
tensorflow-gpu1.12
keras2.2.4

具体步骤

创建虚拟环境

conda create -n TensorFlow_gpu_1.12 python=3.6
#TensorFlow_gpu_1.12为虚拟环境名
conda info --envs
# 查看已创建环境,包括base

切换进入虚拟环境:

conda activate TensorFlow_gpu_1.12
#TensorFlow_gpu_1.12与创建的虚拟环境名保持一致

安装 cudatoolkit

使用 conda 安装版本和包之间的等号为 = ;pip 安装版本和包之间的等号为 ==

conda install cudatoolkit=9.2

安装 cudnn

conda install cudnn=7.6.5

虚拟环境更新 pip(根据tensorflow版本需求更新)

python -m pip install --upgrade pip

建议在安装Keras安装之前需要安装numpy、matplotlib、scipy等工具包,可直接pip或者conda 下载或者卸载安装相关的python模块包,建议只用一种安装方式,负责会出现版本不匹配问题。

    pip install numpy      # 安装 numpy 包
    pip install matplotlib # 安装 matplotlib 包
    pip install scipy      # 安装 scipy 包
    pip install salib      # 安装 salib 包

    pip uninstall numpy      # 卸载 numpy 包
    pip uninstall matplotlib # 卸载 matplotlib 包
    pip uninstall scipy      # 卸载 scipy 包
    pip uninstall salib      # 卸载 salib 包

安装tensorflow-gpu

pip install tensorflow_gpu==1.12

安装Keras

pip install Keras==2.2.4

 最后,通过在Pycharm中更改Python Interpreter,即可使用创建的虚拟环境。

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

Tensorflow-gpu与CUDA、cuDNN的对应版本🔗

版本Python 版本编译器构建工具cuDNNCUDA
tensorflow_gpu-2.6.03.6-3.9MSVC 2019Bazel 3.7.28.111.2
tensorflow_gpu-2.5.03.6-3.9MSVC 2019Bazel 3.7.28.111.2
tensorflow_gpu-2.4.03.6-3.8MSVC 2019Bazel 3.1.08.011.0
tensorflow_gpu-2.3.03.5-3.8MSVC 2019Bazel 3.1.07.610.1
tensorflow_gpu-2.2.03.5-3.8MSVC 2019Bazel 2.0.07.610.1
tensorflow_gpu-2.1.03.5-3.7MSVC 2019Bazel 0.27.1-0.29.17.610.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.07.29.0
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值