问题:

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. Android插件化与热修复(六)-微信Tinker原理分析

    Tinker热修复原理分析 热补丁技术是在用户不需要重新安装应用的情况下实现应用更新,可快速解决一些线上问题.热补丁省去了Android应用发布版本的成本,而且用户端的更新也是无感知的. Tinker ...

  2. matlab中xlsread函数的bug

    在使用[num txt data]=xlsread('filename')时.num存所有数值型数据,非数值型用NaN表示,txt存非数值型数据,数值型数据的位置为空. 如果filename中的第一行 ...

  3. Windows搭建测试RabbitMq遇到的问题

    报错: d:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.5\sbin>rabbitmq-plugins eble rabbitmq_ma ...

  4. js省市级联实现

    js省市级联实现. for [element] in [collection] 用于循环下标,常用于json for(index in arr){ console.info("下标:&quo ...

  5. iOS基础总结

    面试题预览: 1.KVO实现原理? 2.说说你理解的埋点? 3.消息转发机制原理? 4.说说你理解weak属性? 5.假如Controller太臃肿,如何优化? 6.项目中网络层如何做安全处理? 7. ...

  6. jquery 取子节点及当前节点属性值

    分享下jquery取子节点及当前节点属性值的方法. <li class="menulink"><a href="#" rel="ex ...

  7. R概率分布函数使用小结

    记要 今天在计算分类模型自行区间时,用到了R中正太分布的qnorm函数,这里做简单记要,作为备忘. R中自带了很多概率分布的函数,如正太分布,二次分布,卡放分布,t分布等,这些分布的函数都有一个共性, ...

  8. Mac OSX 快捷键&命令行

    一.Mac OSX 快捷键 ctrl+shift                                    快速放大dock的图标会暂时放大,而如果你开启了dock放大Command+Op ...

  9. zabbix 实现对服务器的负载监控

    # grep Include /etc/zabbix/zabbix_agentd.conf ### Option: Include # Include= Include=/etc/zabbix/zab ...

  10. CCardSlip

    该类已经把tableview封装好,可以把它当做一个精灵来用,这样做的好处是,当一个界面同时需要多个tableview的时候就可以很好的解决这个问题,而且模块也更清晰. //------------- ...