问题:

Cannot assign a device for operation 'MatMul': Operation was explicitly assigned to /device:GPU:1 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0 ]. Make sure the device specification refers to a valid device.

解决方法:

方法一. 卸载tensorflow,安装tensorflow-gpu

pip uninstall tensorflow

pip install tensorflow-gpu

如果还是出问题请尝试:

方法二. 将乘法操作移到gpu以外执行

示例:

# old
with tf.Session() as sess:
matrix1 = tf.constant([[3., 3.]])
print("matrix1:",matrix1)
matrix2 = tf.constant([[2.],[2.]])
print("matrix2:",matrix2)
with tf.device("/gpu:1"):
# 将乘法运算移到外面执行
product = tf.matmul(matrix1, matrix2)
result = sess.run(product)
print("result:",result) # new
with tf.Session() as sess:
matrix1 = tf.constant([[3., 3.]])
print("matrix1:",matrix1)
matrix2 = tf.constant([[2.],[2.]])
print("matrix2:",matrix2)
product = tf.matmul(matrix1, matrix2)
with tf.device("/gpu:1"):
result = sess.run(product)
print("result:",result)

正确结果:

C:\Users\bin>python d:/PycharmProjects/TFLearn/Unit1/.py
-- ::03.490996: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\\tensorflow\core\platform\cpu_feature_guard.cc:] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
-- ::04.077880: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\\tensorflow\core\common_runtime\gpu\gpu_device.cc:] Found device with properties:
name: GeForce GT 740M major: minor: memoryClockRate(GHz): 1.0325
pciBusID: ::00.0
totalMemory: .00GiB freeMemory: .07MiB
-- ::04.078060: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\\tensorflow\core\common_runtime\gpu\gpu_device.cc:] Creating TensorFlow device (/device:GPU:) -> (device: , name: GeForce GT 740M, pci bus id: ::00.0, compute capability: 3.5)
matrix1: Tensor("Const:0", shape=(, ), dtype=float32)
matrix2: Tensor("Const_1:0", shape=(, ), dtype=float32)
result: [[ .]]

问题:

Could not find 'cudnn64_6.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Note that installing cuDNN is a separate step from installing CUDA, and this DLL is often found in a different directory from the CUDA DLLs. You may install the necessary DLL by downloading cuDNN 6 from this URL: https://developer.nvidia.com/cudnn

解决方法:

1. 安装cudn:

https://developer.nvidia.com/rdp/cudnn-download

https://developer.nvidia.com/cuda-zone

nvidia官网经常更新,请下载对应的版本,cudn和cudnn dll 版本号不一样,比如tensorflow-gpu 1.4对应cndn8,同时需要下载cudnn64_6.dll for cudn8。

2. 下载cudnn64_6,解压到指定cudn目录 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

pan.baidu.com/s/1o8mc4Y  windows

pan.baidu.com/s/1hs23Hr  linux

Tensorflow问题汇总的更多相关文章

  1. TensorFlow资料汇总

    升级mac自带的python 使用virtualenv进行python环境隔离 tf.nn.conv2d.卷积函数 max_pool 池化函数 TF.VARIABLE.TF.GET_VARIABLE. ...

  2. 关于TensorFlow若干问题的汇总

    1.TensorFlow中padding的两种类型SAME和VALID 简而言之:padding='SAME'表示采用在两端填充0进行补全的方式,左右填充0的个数可能并不同. padding='VAL ...

  3. tensorflow 资源汇总-docker 运行 tensorflow-gpu on nvidia support

    tensorflow 容器运行过程中使用到的命令记录: 使用image启动容器命令: docker run --name=: tensorflow/tensorflow:latest-gpu-py3- ...

  4. 用TensorFlow搭建一个万能的神经网络框架(持续更新)

    我一直觉得TensorFlow的深度神经网络代码非常困难且繁琐,对TensorFlow搭建模型也十分困惑,所以我近期阅读了大量的神经网络代码,终于找到了搭建神经网络的规律,各位要是觉得我的文章对你有帮 ...

  5. 『TensorFlow』专题汇总

    TensorFlow:官方文档 TensorFlow:项目地址 本篇列出文章对于全零新手不太合适,可以尝试TensorFlow入门系列博客,搭配其他资料进行学习. Keras使用tf.Session训 ...

  6. TensorFlow从入门到实战资料汇总 2017-02-02 06:08 | 数据派

    TensorFlow从入门到实战资料汇总 2017-02-02 06:08 | 数据派 来源:DataCastle数据城堡 TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学 ...

  7. 史上最全TensorFlow学习资源汇总

    来源 | 悦动智能(公众号ID:aibbtcom) 本篇文章将为大家总结TensorFlow纯干货学习资源,非常适合新手学习,建议大家收藏. ▌一 .TensorFlow教程资源 1)适合初学者的Te ...

  8. TensorFlow 常用函数汇总

    本文介绍了tensorflow的常用函数,源自网上整理. TensorFlow 将图形定义转换成分布式执行的操作, 以充分利用可用的计算资源(如 CPU 或 GPU.一般你不需要显式指定使用 CPU ...

  9. 『TensorFlow』0.x_&_1.x版本框架改动汇总

    基本数值运算 除法和模运算符(/,//,%)现在匹配 Python(flooring)语义.这也适用于 [tf.div] 和 [tf.mod].要获取基于强制整数截断的行为,可以使用 [tf.trun ...

随机推荐

  1. java对象内存占用

    一.前言想知道java对象在内存中的占用情况吗?感谢这位大神的无私分享. http://yueyemaitian.iteye.com/blog/2033046 二.原文的扩充1. 增加了代理jar包的 ...

  2. .net自定义控件Control、WebControl、CompositeControl

    一.呈现方法 1.Control主要有以下4个方法用于呈现 //该方法为入口方法 public virtual void RenderControl (HtmlTextWriter writer) { ...

  3. 【转】java io 流 设计模式

    知识点:什么是装饰模式: http://wenku.baidu.com/view/ad4eac9f51e79b896802263b.html(原理讲的很清楚) http://wenku.baidu.c ...

  4. Java服务端单元测试指南

    https://juejin.im/entry/5acad0806fb9a028cd456236

  5. echarts 与 百度地图bmap结合系列: 如何设置地图缩放级别和监听缩放事件

    简单的demo: // ehcarts 的实例对象 this.myChart = echarts.init(el) // ehcarts加载完成事件 this.myChart.on('finished ...

  6. VB高效导入Excel2003和Excel2007文件到MSHFlexGrid控件显示

    1.VB高效导入Excel2003和Excel2007文件到MSHFlexGrid控件显示 2.以前也有Excel导入通用功能,但速度有些慢一会把两种实现方式都提供出为参考对比. 一.原通用导入exc ...

  7. [转]cubemap soft shadow

    https://community.arm.com/graphics/b/blog/posts/dynamic-soft-shadows-based-on-local-cubemap

  8. SQL Server 2008开启sa账户以及如何用JDBC进行连接

    做实验需要用Java与SQL Server连接,因为使用的 SQL 2008 Express Edition 是基于 Visual Studio2010 安装包安装时一起安装的,所以为了方便数据库的操 ...

  9. 分享:Oracle 系统变量函数用法说明

    在Oracle数据库中,Oracle系统变量函数是经常会使用到的函数,分享下Oracle系统变量函数的用法. Oracle函数多种多样,系统变量函数就是其中之一,介绍三种最常见的系统变量函数. Ora ...

  10. Java 技术新手入门

    对于想学习Java的朋友 请参考IBM旗下站点:http://www.ibm.com/developerworks/cn/java/newto/index.html 我看了下对于新手有很好的指导,并且 ...