本文介绍了没有注册任何OpKernel支持这些属性的Op'Conv2D'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个新功能可能有些愚蠢,但无法运行conv2d

new to this may be something dumb but cant get conv2d to run

windows 10

windows 10

anaconda 4.2.13

anaconda 4.2.13

python 3.5.2

python 3.5.2

C:\ windows \ system32> nvcc --versionnvcc:NVIDIA(R)Cuda编译器驱动程序版权所有(c)2005-2016 NVIDIA Corporation建立在Sat_Sep__3_19:05:48_CDT_2016Cuda编译工具,版本8.0,V8.0.44

C:\windows\system32>nvcc --versionnvcc: NVIDIA (R) Cuda compiler driverCopyright (c) 2005-2016 NVIDIA CorporationBuilt on Sat_Sep__3_19:05:48_CDT_2016Cuda compilation tools, release 8.0, V8.0.44

cudnn 5.1

cudnn 5.1

TensorFlow 0.12

TensorFlow 0.12

import numpy as np
import tensorflow as tf

graph1 = tf.Graph()
with graph1.as_default():
    f=tf.constant(   np.ones(10).reshape(1,1,-1,1)   )
    g=tf.constant(   np.ones(3).reshape(1,-1,1,1)   )
    conv1=tf.nn.conv2d( f,g, strides=[1,1,1,1] , padding="SAME",name="conv1")

with tf.Session(graph=graph1) as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(f))
    print(sess.run(g))
    print(sess.run(conv1))
    sess.close()

导致:

InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'Conv2D' with these attrs.  Registered devices: [CPU,GPU], Registered kernels:
  device='CPU'; T in [DT_HALF]
  device='CPU'; T in [DT_FLOAT]
  device='GPU'; T in [DT_HALF]
  device='GPU'; T in [DT_FLOAT]

    [[Node: conv = Conv2D[T=DT_DOUBLE, data_format="NHWC", padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](Const, Const_1)]]

推荐答案

您应将以下两行更改为

f=tf.constant(   np.ones(10).reshape(1,1,-1,1).astype(np.float32)   )
g=tf.constant(   np.ones(3).reshape(1,-1,1,1).astype(np.float32)   )

否则,这些节点采用默认的numpy类型float64,该类型没有Conv2D内核

Otherwise those nodes take on default numpy type of float64, which doesn't have Conv2D kernel

这篇关于没有注册任何OpKernel支持这些属性的Op'Conv2D'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 03:10