目录

通过conda安装CUDA、cudnn方法

不通过conda安装CUDA、cudnn方法

安装前言:

安装VS2015

CUDA和Cudnn

安装Anaconda3

测试:

附录:


通过conda安装CUDA、cudnn方法

Anaconda + TensorFlow 2.0 GPU安装

在 Anaconda 中安装 TensorFlow-gpu 2.0(无需下载 CUDA)

不通过conda安装CUDA、cudnn方法

安装前言:

安装之前,你要知道你要用的tensorflow版本的安装环境,如果你不知道就用本文默认的配置,见官网:
https://tensorflow.google.cn/install/source_windows

* TensorFlow 1.2.1 or earlier requires cuDNN 5.1. ('cudnn64_5.dll')
  * TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

MSVC+CUDA+cuDNN+python的版本都要正确

CPU版

tensorflow与keras版本的匹配(你可能用到keras),参考Docker的成套配置:

安装VS2015

MSVC是VS附带的软件包:Microsoft Visual C++ 2015 Redistributable和Microsoft 生成工具 2015,tensorflow官网上说可以不用下载VS可以直接单独下载它,但是你最好还是安装一个VisualStudio2015,VS会附带这两个东西。我尝试了很多次只安装Microsoft Visual C++ 2015 Redistributable和Microsoft 生成工具 2015,结果CUDA装不上

VS2015免费版的下载可以去这个微信公众号找:软件安装管家

tensorflow官网里有单独的MSVC2015的下载地址,我这里也把它给出吧:

安装 Visual C++ 生成工具 2015。此软件包随附在 Visual Studio 2015 中,但可以单独安装:

  1. 转到 Visual Studio 下载页面,
  2. 选择“可再发行组件和生成工具”,
  3. 下载并安装:
    • Microsoft Visual C++ 2015 Redistributable 更新 3
    • Microsoft 生成工具 2015 更新 3

这里可以看到:

选择x64的,x64是给64位的系统用的,x86是给32位系统用的。

CUDA和Cudnn

视频教程:

https://www.bilibili.com/video/av70734671/

博客教程

关于CUDA的安装可以参考这个网址里的CUDA安装方法:

https://zhuanlan.zhihu.com/p/37086409

关于cuDNN的安装你可以参考这个网址的安装方法:

https://blog.csdn.net/angzhangzhang123/article/details/79637346

windows下同一个显卡配置多个CUDA工具包以及它们之间的切换

https://blog.csdn.net/qq_27825451/article/details/89135592

ERROR:

Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found

solution:当在anaconda prompt可以用tensorflow2.0,但pycharm不可以用,重启pycharm就可以了。注意tensorflow、python、cuda、cudnn的版本都要匹配

安装Anaconda3

至于python我是在看安装CUDA的那篇知乎文章时下载了一个anaconda3,它的默认python版本是3.5

下载tensorflow的时候,也就是anaconda prompt下输入这个命令时:
pip install tensorflow-gpu==1.10.0
它会很慢,或者是卡住了,点击鼠标右键推进它继续或是一个ctrl+c让它结束,重新来。
这个安装tensorflow的步骤是一个难点,它会从官网上下载资源,而且网络不好,时常中断,你只能不断地重复输入这个命令,
或是更换一个更好的镜像源,要坚持下去。

更换国内镜像源:https://topmanopensource.iteye.com/blog/2004853

测试:

运行此tensorflow_self_check.py文件可以测试你的CUDA、Cudnn与tensorflow是否安装成功:

# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""A script for testing that TensorFlow is installed correctly on Windows.
The script will attempt to verify your TensorFlow installation, and print
suggestions for how to fix your installation.
"""import ctypes
import imp
import sysdef main():try:import tensorflow as tfprint("TensorFlow successfully installed.")if tf.test.is_built_with_cuda():print("The installed version of TensorFlow includes GPU support.")else:print("The installed version of TensorFlow does not include GPU support.")sys.exit(0)except ImportError:print("ERROR: Failed to import the TensorFlow module.")candidate_explanation = Falsepython_version = sys.version_info.major, sys.version_info.minorprint("\n- Python version is %d.%d." % python_version)if not (python_version == (3, 5) or python_version == (3, 6)):candidate_explanation = Trueprint("- The official distribution of TensorFlow for Windows requires ""Python version 3.5 or 3.6.")try:_, pathname, _ = imp.find_module("tensorflow")print("\n- TensorFlow is installed at: %s" % pathname)except ImportError:candidate_explanation = Falseprint("""
- No module named TensorFlow is installed in this Python environment. You mayinstall it using the command `pip install tensorflow`.""")try:msvcp140 = ctypes.WinDLL("msvcp140.dll")except OSError:candidate_explanation = Trueprint("""
- Could not load 'msvcp140.dll'. TensorFlow requires that this DLL beinstalled in a directory that is named in your %PATH% environmentvariable. You may install this DLL by downloading Microsoft VisualC++ 2015 Redistributable Update 3 from this URL:https://www.microsoft.com/en-us/download/details.aspx?id=53587""")try:cudart64_80 = ctypes.WinDLL("cudart64_80.dll")except OSError:candidate_explanation = Trueprint("""
- Could not load 'cudart64_80.dll'. The GPU version of TensorFlowrequires that this DLL be installed in a directory that is named inyour %PATH% environment variable. Download and install CUDA 8.0 fromthis URL: https://developer.nvidia.com/cuda-toolkit""")try:nvcuda = ctypes.WinDLL("nvcuda.dll")except OSError:candidate_explanation = Trueprint("""
- Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires thatthis DLL be installed in a directory that is named in your %PATH%environment variable. Typically it is installed in 'C:\Windows\System32'.If it is not present, ensure that you have a CUDA-capable GPU with thecorrect driver installed.""")cudnn5_found = Falsetry:cudnn5 = ctypes.WinDLL("cudnn64_5.dll")cudnn5_found = Trueexcept OSError:candidate_explanation = Trueprint("""
- Could not load 'cudnn64_5.dll'. The GPU version of TensorFlowrequires that this DLL be installed in a directory that is named inyour %PATH% environment variable. Note that installing cuDNN is aseparate step from installing CUDA, and it is often found in adifferent directory from the CUDA DLLs. You may install thenecessary DLL by downloading cuDNN 5.1 from this URL:https://developer.nvidia.com/cudnn""")cudnn6_found = Falsetry:cudnn = ctypes.WinDLL("cudnn64_6.dll")cudnn6_found = Trueexcept OSError:candidate_explanation = Trueif not cudnn5_found or not cudnn6_found:print()if not cudnn5_found and not cudnn6_found:print("- Could not find cuDNN.")elif not cudnn5_found:print("- Could not find cuDNN 5.1.")else:print("- Could not find cuDNN 6.")print("""The GPU version of TensorFlow requires that the correct cuDNN DLL be installedin a directory that is named in your %PATH% environment variable. Note thatinstalling cuDNN is a separate step from installing CUDA, and it is oftenfound in a different directory from the CUDA DLLs. The correct version ofcuDNN depends on your version of TensorFlow:* TensorFlow 1.2.1 or earlier requires cuDNN 5.1. ('cudnn64_5.dll')* TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')You may install the necessary DLL by downloading cuDNN from this URL:https://developer.nvidia.com/cudnn""")if not candidate_explanation:print("""
- All required DLLs appear to be present. Please open an issue on theTensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues""")sys.exit(-1)if __name__ == "__main__":main()

然后可以打开Anaconda Prompt:

然后输入:activate tensorflow  激活tensoflow环境。再输入:python   进入python编程环境

测试tensorflow是否是在用GPU,如果是,结果会有GPU:0的输出,把下面这些代码粘贴进Anaconda Prompt

import tensorflow as tf
# Creates a graph.
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Runs the op.
print(sess.run(c))

然后打开Anconda Navigatior

进入tensorflow环境:

安装spyder,我这里已经安装了,它显示的是launch。

然后你就可以用spyder这个IDE使用tensorflow框架了。

当你安装了无数次tensorflow后却不尽人愿,那你就卸载了Anaconda重新来吧。

附录:

1.查看已经安装的CUDA版本
cmd下输入:nvcc -V

2.
#查看tensorflow版本
import tensorflow as tf
tf.__version__
#查询tensorflow安装路径为:
tf.__path__

3.怎么卸载tensorflow
卸载命令时‘pip uninstall tensorflow’。但要先确定我们所在的是哪个环境,
如果所在基础python3.6环境,使用这个命令是没有用处的,倒是你输入‘pip u
ninstall python’可以把基础python3.6环境卸载掉。怎样卸载tensorflow呢?
我们需要先激活有tensorflow的环境,命令为‘activate tensorflow’,然后再
输入命令‘pip uninstall tensorflow’就可以了,卸载python2.7环境也是同理,输入‘pip uninstall python27’。? ? ? ? ? 
--------------------- 
作者:aiguiru 
来源:CSDN 
原文:https://blog.csdn.net/ifisher999/article/details/81085805 
版权声明:本文为博主原创文章,转载请附上博文链接!

4.查看anaconda的所有环境:
命令行下:
conda info --envs

5.

#看tensorflow安装在CPU还是GPU上
import os
from tensorflow.python.client import device_lib
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "99"
if __name__ == "__main__":
    print(device_lib.list_local_devices())

#看tensorflow安装在CPU还是GPU上
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) 
print (sess.run(c))
sess.close()

6.怎么用pip卸载应用
先命令行下:pip list来查看安装了什么包
https://jingyan.baidu.com/article/ea24bc39d8497eda62b3313a.html
pip uninstall 要卸载的包名
比如:pip uninstall tensorflow

加上一个参数-y,启动安静模式,即不提示是否卸载。
pip uninstall tensorflow -y

7.win10怎么查看nvidia显卡GPU的利用率在哪查看
https://jingyan.baidu.com/article/9158e000022d74a254122819.html

命令如下:cd C:\Program Files\NVIDIA Corporation\NVSMI

之后输入命令:nvidia-smi -l

-l这个参数表示每几秒刷新一次,这里的type:C+G表示使用计算及图形过程,C代表计算过程,G代表图形过程

Memory-Usage表示显存使用大小,Volatile Uncorr表示GPU使用率

******完结撒花******

Win10通过Anaconda安装GPU版tensorflow相关推荐

  1. Win10安装GPU版tensorflow和keras

    Win10安装GPU版tensorflow和keras 1.python安装 在此选用python3.7安装见详细教程https://blog.csdn.net/weixin_43545253/art ...

  2. (转)在Windows上安装GPU版Tensorflow

    转载自在Windows上安装GPU版Tensorflow. 1. 下载安装Anaconda 简单说就是下载 64位 python 3.5 版本的Anaconda https://www.continu ...

  3. GTX1060安装gpu版tensorflow经验分享

    配适版本 作为一个深度学习小白,刚刚开始接触深度学习,没想到安装tensorflow竟然成为了第一支拦路虎-用CPU的版本完成作业后想着既然显卡还凑活不如用GPU版本的试试,没想到安装实在麻烦,网上的 ...

  4. 基于Anaconda安装GPU版PyTorch深度学习开发环境

    基于Anaconda安装GPU版PyTorch深度学习开发环境 1 安装Anaconda 2 安装GPU计算驱动 2.1 检查是否有合适的GPU 2.2 下载CUDA和cuDNN 2.3 安装CUDA ...

  5. conda安装gpu版tensorflow和局部cuda插件,不用配置全局cuda了

    conda安装gpu版tensorflow和局部cuda插件,不用配置全局cuda了 把后面的命令改为你要安装的版本号 conda install -c conda-forge tensorflow- ...

  6. Win10通过anaconda安装GPU、CPU版tensorflow

    目录 1. 安装anaconda 2. 安装Tensorflow 2.1 打开Anaconda Prompt 2.2 使用清华镜像源 2.3 用Anaconda创建一个python环境 2.4 在An ...

  7. win10安装GPU版tensorflow

    一 环境 系统:win10专业版 显卡:GTX1050Ti 二 安装Anaconda Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包 ...

  8. TensorFlow安装 通过Anaconda Prompt Win10 64位安装 cpu版 tensorflow

    执行命令pip install  tensorflow, 执行上图得到的安装命令,安装开始 安装结束后打开Anaconda中的Jupyter Notebook,并新建 输入import tensorf ...

  9. win10 安装 GPU版TensorFlow

    WIN10安装CUDA9+CUDNN+TENSORFLOW1.9.0 安装环境:笔记本电脑win10专业版操作系统 + 1050显卡 1.安装CUDA9 地址:https://developer.nv ...

最新文章

  1. C#中Hashtable表的应用
  2. Java枚举的小用法
  3. Web Template Studio 发布!在 VS Code 中轻松创建 Web 应用
  4. word List 34
  5. hdfs shell
  6. 关于 动态分流系统 ABTestingGateway 的想法
  7. [面试] 算法(二)—— 第一个出现一次的字符(第一个出现 k 次、出现最多次)
  8. 关于RUP的一点见解,针对于近期的面向对象方法课程
  9. Label Matrix v8 怎样做二次开发
  10. 【稀饭】react native 实战系列教程之项目初始化
  11. 内卷机器下的自我救赎
  12. 基金投资入门1:基金基础知识介绍
  13. 嘉应学院计算机专业毕业好找工作吗,嘉应学院毕业证两字之差致学生求职碰壁...
  14. 论文解析 | 不确定性校准的化学反应预测模型
  15. Keystone认证服务详细操作流程
  16. A股实时行情接口资源分享
  17. 1209: 【入门】数字走向II
  18. Windows安全配置技术(转)
  19. firefox os android,若能同时使用Android应用,那么你可以接受Firefox OS手机了吗?
  20. 数字音频处理--延时与混响音效 Matlab

热门文章

  1. 诺基亚两年裁员11044人,中国幅度最大达3500人
  2. 如何查看IE浏览器保存的密码
  3. 苹果手机充电时发生爆炸
  4. Android File System安卓文件系统(安卓存储分区,/data /storage /sdcard)
  5. 如何应对学习知识、技能不用就会忘(节选自《穷查理宝典》第十一讲:人类误判心理学之不用就忘倾向)
  6. Ray 分布式简单教程(2)
  7. 深化测试用例的覆盖率
  8. BAT有增有减amp;nbsp;互联网2015校园…
  9. Latex 中目录生成超链接
  10. 怎么用python制作随机点名软件_如何用python编写一个简易的随机点名软件?