Tensorflow问题汇总
问题:
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问题汇总的更多相关文章
- TensorFlow资料汇总
升级mac自带的python 使用virtualenv进行python环境隔离 tf.nn.conv2d.卷积函数 max_pool 池化函数 TF.VARIABLE.TF.GET_VARIABLE. ...
- 关于TensorFlow若干问题的汇总
1.TensorFlow中padding的两种类型SAME和VALID 简而言之:padding='SAME'表示采用在两端填充0进行补全的方式,左右填充0的个数可能并不同. padding='VAL ...
- tensorflow 资源汇总-docker 运行 tensorflow-gpu on nvidia support
tensorflow 容器运行过程中使用到的命令记录: 使用image启动容器命令: docker run --name=: tensorflow/tensorflow:latest-gpu-py3- ...
- 用TensorFlow搭建一个万能的神经网络框架(持续更新)
我一直觉得TensorFlow的深度神经网络代码非常困难且繁琐,对TensorFlow搭建模型也十分困惑,所以我近期阅读了大量的神经网络代码,终于找到了搭建神经网络的规律,各位要是觉得我的文章对你有帮 ...
- 『TensorFlow』专题汇总
TensorFlow:官方文档 TensorFlow:项目地址 本篇列出文章对于全零新手不太合适,可以尝试TensorFlow入门系列博客,搭配其他资料进行学习. Keras使用tf.Session训 ...
- TensorFlow从入门到实战资料汇总 2017-02-02 06:08 | 数据派
TensorFlow从入门到实战资料汇总 2017-02-02 06:08 | 数据派 来源:DataCastle数据城堡 TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学 ...
- 史上最全TensorFlow学习资源汇总
来源 | 悦动智能(公众号ID:aibbtcom) 本篇文章将为大家总结TensorFlow纯干货学习资源,非常适合新手学习,建议大家收藏. ▌一 .TensorFlow教程资源 1)适合初学者的Te ...
- TensorFlow 常用函数汇总
本文介绍了tensorflow的常用函数,源自网上整理. TensorFlow 将图形定义转换成分布式执行的操作, 以充分利用可用的计算资源(如 CPU 或 GPU.一般你不需要显式指定使用 CPU ...
- 『TensorFlow』0.x_&_1.x版本框架改动汇总
基本数值运算 除法和模运算符(/,//,%)现在匹配 Python(flooring)语义.这也适用于 [tf.div] 和 [tf.mod].要获取基于强制整数截断的行为,可以使用 [tf.trun ...
随机推荐
- golang ----map按key排序
实现map遍历有序 1. key有序 思路:对key排序,再遍历key输出value 代码如下:既可以从小到大排序,也可以从大到小排序 package main import ( "fmt& ...
- [转]单元测试利器 JUnit 4
引言 毋庸置疑,程序员要对自己编写的代码负责,您不仅要保证它能通过编译,正常地运行,而且要满足需求和设计预期的效果.单元测试正是验证代码行为是否满足预期的有效手段之一.但不可否认,做测试是件很枯燥无趣 ...
- GitHub创始人:我如何放弃30万美元年薪创业
GitHub创始人:我如何放弃30万美元年薪创业 本文摘自GitHub创始人Tom Preston Werner个人博客. 时间还在2007年,我一个人独坐旧金山的Zeke 体育酒吧内.其实我并不经常 ...
- php分享二十:mysql优化
1:垂直分割 示例一:在Users表中有一个字段是家庭地址,这个字段是可选字段,相比起,而且你在数据库操作的时候除了个人信息外,你并不需要经常读取或是改写这个字段.那么,为什么不把他放到另外一张表中呢 ...
- 不错位的java .class 反编译工具推荐
我们经常会反编译看一些class文件,但是反编译出来的文件里面会有很多杂乱的东西 一直以来都是用的idea来反编译的,只要把class文件往里面一拖就行了 这么用没问题,用来看看源码什么的都OK 但是 ...
- struts2(六) 文件上传和下载
前面对文件下载提过一点点,这里正好要讲文件上传,就放在一起在说一遍. --WH 一.单文件上传 在没学struts2之前,我们要写文件上传,非常麻烦,需要手动一步步去获取表单中的各种属性,然后在进行相 ...
- FPGA学习网站
1. OPENCORES.ORG这里提供非常多,非常好的PLD了内核,8051内核就可以在里面找到.进入后,选择project或者由 http//www.opencores.org/browse.c ...
- [nginx]编译安装及安全优化
nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...
- HTML5学习笔记(三):语义化和新增结构元素
在HTML5之前,使用机器来阅读一个网页是非常困难的,我们使用不同样式的div来标记不同的内容,所以实际上机器无法得知页面的哪个部分是正文,哪个部分是标题,那么在HTML5里,针对这个问题就引入了语义 ...
- 菜鸟学数据库(六)——方便快捷的开启、关闭Oracle服务
背景: 作为一个程序员,在日常的工作中,我们电脑经常需要同时运行很多程序,如:Eclipse.浏览器.即时通讯软件等,甚至经常需要打开几个Office文档或者pdf文档.这时候你的内存估计已经爆表了吧 ...