Tensorflow-GPU(Win10)超完整版安装

一、Anaconda的安装

ANACONDA官网

这个部分需要注意的就是添加环境变量,不然后期使用VSCode测试的时候会出现IMPORT ERROR

Tensorflow-GPU(Win10)超完整版安装

Tensorflow-GPU(Win10)超完整版安装

上面四个文件路径在Anaconda安装路径下

二、安装CUDA、cuDNN和tensorflow_gpu之前的准备工作

这一节需要特别注意各种软件之间的版本适配(以我自己的电脑为例),所以准备工作就显得尤为重要!

[En]

This section needs to pay particular attention to the version adaptation between the various software (take my own computer as an example), so the preparation work is particularly important!

(1)看我们电脑显卡的版本

Tensorflow-GPU(Win10)超完整版安装

显卡版本号:419.72

(2)查看对应的CUDA版本

官网查询

Tensorflow-GPU(Win10)超完整版安装

选择CUDA时,选择低于显卡版本以下对应的CUDA版本。因此对于我的显卡(419)我选择CUDA10.0版本

(3)查看对应的cuDNN和tensorflow_gpu版本

官网查询 官网查询

Tensorflow-GPU(Win10)超完整版安装

因此,我选择的版本是:

[En]

Therefore, the versions I choose are:

tensorflow_gpu-2.0.0

Python3.7

cuDNN7.4

CUDN10.0

三、下载软件

(1)下载CUDN10.0:下载链接:CUDA官网

Tensorflow-GPU(Win10)超完整版安装

(2)下载cuDNN7.4:下载链接: cuDNN下载

官网需要注册,步骤很简单,不多说。

[En]

The official website needs to register, the step is very simple, do not say much.

四、安装软件

(1)CUDA安装

1.1双击安装,点OK(解压的文件后面会自己消失)

Tensorflow-GPU(Win10)超完整版安装

1.2选择自定义安装,然后下一步

Tensorflow-GPU(Win10)超完整版安装

Tensorflow-GPU(Win10)超完整版安装

CUDA目录下VS取消

1.3默认安装位置即可

Tensorflow-GPU(Win10)超完整版安装

测试是否安装成功:cmd打开命令行,输入nvcc -V(注意大小写),如果显示版本信息则说明安装成功。

Tensorflow-GPU(Win10)超完整版安装

(2)cuDNN安装

2.1直接解压

Tensorflow-GPU(Win10)超完整版安装

2.2将三个文件夹里面的文件分别复制到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0同样文件夹下

文本内容直接复制到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0即可

Tensorflow-GPU(Win10)超完整版安装

(3)安装tensorflow_gpu

3.1创建虚拟环境(cmd命令行输入,这里的tensorflow_gpu是虚拟环境的名称)

conda create -n tensorflow_gpu python=3.7

激活环境

activate tensorflow_gpu

或使用

Tensorflow-GPU(Win10)超完整版安装

3.2换源(下面的所有操作都在创建的虚拟环境中)

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3.3我们真正使用的时候我们其实主要用的就是CUDATOOLKIT 这个工具(版本号跟我们之前选择的CUDA版本号一致)

conda install cudatoolkit=10.0

3.4安装cudnn

conda install cudnn=7.4

3.5安装tensorflow_gpu(pip 需要更新的可以更新一下)

pip install tensorflow-gpu==2.0.0

出现Successful即安装成功

3.6测试是否安装成功

在虚拟环境中输入python

Tensorflow-GPU(Win10)超完整版安装
import tensorflow as tf
tf.test.is_gpu_available()

出现True即成功

Tensorflow-GPU(Win10)超完整版安装

五、VS Code中使用

(1)选择解释器

Tensorflow-GPU(Win10)超完整版安装

(2)测试代码

import tensorflow as tf
print(tf.test.is_gpu_available())

(3)运行,出现Ture即可

Tensorflow-GPU(Win10)超完整版安装

当系统禁止运行脚本时:

[En]

When the system forbids running scripts:

以管理员身份打开Windows Powershell

在终端执行:get-ExecutionPolicy,显示Restricted

执行:set-ExecutionPolicy RemoteSigned

再执行:get-ExecutionPolicy,显示RemoteSigned

Tensorflow-GPU(Win10)超完整版安装

最后,非常感谢你看到这一点,希望这篇文章能对你有所帮助。

[En]

Finally, thank you very much for seeing this, and I hope this post can help you.

Original: https://blog.csdn.net/qq_42749307/article/details/124252659
Author: 格里有业
Title: Tensorflow-GPU(Win10)超完整版安装

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/497242/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球