问题:

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. DrawItem

    原文链接: http://blog.csdn.net/jiftlixu/article/details/4893505 今天从CButton派生了一个类CUIButton,主要用于自绘,按照基本的流程 ...

  2. vc2010 属性值无效 灾难性故障 解决方法

    原文链接: http://blog.csdn.net/enterlly/article/details/8739281 说明: 我遇到这个问题是这样的,在为某个类添加消息时出现的.因为该类不在此工程的 ...

  3. asp.net与C# path.GetFullPath 获取上级目录

    string path = new directoryinfo("../").fullname;//当前应用程序路径的上级目录 获取当前目录可以使用appdomain.curren ...

  4. Linux中在防火墙中开启80端口的例子

    最近自己在学习Linux.搭建一个LNMP环境.在测试时一切都好.然后重启Linux后.再次访问网站无法打开.最终原因是在防火墙中没有加入 80 端口的规则.具体方法如下: 在CentOS下配置ipt ...

  5. 增量式pid和位置式PID参数整定过程对比

    //增量式PID float IncPIDCalc(PID_Typedef* PIDx,float SetValue,float MeaValue)//err»ý·Ö·ÖÀë³£Êý { PIDx-& ...

  6. 转 kafka架构简介

    kafka架构 转 http://www.cnblogs.com/chushiyaoyue/p/5612298.html 相关文章: https://www.jianshu.com/p/6233d53 ...

  7. Knockout: 使用knockout validation插件进行校验, 给未通过校验的输入框添加红色边框突出显示.

    之前整理了三篇帖子: Knockout: 使用CSS绑定和event的blur失去焦点事件, 给未通过校验的输入框添加红色边框突出显示. http://www.cnblogs.com/liuzhend ...

  8. C#两个DataTable拷贝问题:该行已经属于另一个表的解决方法

    一.DataTable.Rows.Add(DataRow.ItemArray); 二.DataTable.ImportRow(DataRow) 三.设置DataTable的tablename,然后.R ...

  9. 码字工作者的发文姿势—— 用MWeb+Markdown Here+七牛 轻松实现多平台发布

    码字工作者的发文姿势—— 用MWeb+Markdown Here+七牛 轻松实现多平台发布   1.对于写作你最头疼什么 对于大多数码字工作者来说,随时随地记录灵感,构思文章,集中书写,其实是一件令人 ...

  10. msf web_delivery模块攻击

    目标机:win7                    ip:192.168.31.136 攻击机:kai liunx                      ip:192.168.31.54 一. ...