Cannot assign a device to node
来源:互联网 发布:美国 大数据公司 data 编辑:程序博客网 时间:2024/05/17 13:43
1. 在指定使用GPU时,如果直接指定 "/gpu:0"
tensorflow.python.framework.errors.InvalidArgumentError: Cannot assign a device to node 'GradientDescent/update_Variable_2/ScatterSub': Could not satisfy explicit device specification '' because the node was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/GPU:0' [[Node: GradientDescent/update_Variable_2/ScatterSub = ScatterSub[T=DT_FLOAT, Tindices=DT_INT64, use_locking=false](Variable_2, gradients/concat_1, GradientDescent/update_Variable_2/mul)]]Caused by op u'GradientDescent/update_Variable_2/ScatterSub', defined at:
原因是并不是图中的所有的操作都支持GPU运算:It seems a whole bunch of operations used in this example aren't supported on a GPU. A quick workaround is to restrict operations such that only matrix muls are ran on the GPU.
There's an example in the docs: http://tensorflow.org/api_docs/python/framework.md
See the section on tf.Graph.device(device_name_or_function)
简答的办法是指定只有矩阵乘法才在GPU上进行:def device_for_node(n): if n.type == "MatMul": return "/gpu:0" else: return "/cpu:0"with graph.as_default(): with graph.device(device_for_node): ...
2. 在没有执行 img = sess1.run(img) 前,img 是 tf.read_file 然后 tf.image.decode_jpeg 后得到的,但是这里都是添加到图中的操作,并没有真正被执行,此时 img 的类型是
3. 所有操作如果不指定图,则会使用默认图 tf.get_default_graph() ,上述代码中加载了两个模型,如果两个模型中出现里相同的name,就会出错。
上面的方式将第一个模型放在了图g中,session执行的是图g,而不是默认图,这样后面就可以不用显示指定图,直接使用默认图。如果没有使用图g, 那么在第二个模型时需要先将默认图重置以清空默认图中之前的添加的ops
阅读全文
0 0
- Cannot assign a device to node
- Cannot assign a TFont to a TFont
- Cannot assign a TFont to a TFont!!
- cannot assign a tfont to a tfont
- delphi7 Cannot assign a TFont to a TFont问题
- DLL:cannot assign a tfont to a tfont
- golang cannot assign to
- 主程序调用DLL窗体 cannot assign a TFont to a TFont 问题的彻底解决方案
- 主程序调用DLL窗体 cannot assign a TFont to a TFont 问题的彻底解决方案
- DLL中报'Cannot assign a TFont to a TFont'的问题
- 关于Dll中“cannot assign a tfont to a tfont ”问题
- 主程序调用DLL窗体cannot assign a class to a class问题的彻底解决方案
- 调用DLL窗体 cannot assign a TFont to a TFont 问题
- OPCAutomation_TLB.pas(1240): Cannot assign to a read-only property 问题解决
- cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 全文检索之sphinx源码分析--检索流程
- 【DP】一共有多少种走法
- 爬虫实战10—日志、守护线程以及验证码处理
- Qt Widgets
- org.hibernate.StaleStateException
- Cannot assign a device to node
- 51nod 1137 矩阵乘法
- magent编译报错error: event.h: No such file or directory
- Linux驱动中的platform总线分析
- 二分查找(模板)
- C中变量的声明与定义
- c++调用静态库和动态库
- 392. Is Subsequence (模拟)
- 关于背包问题的一点点笔记(随时补充)