【问题标题】:tensorflow Unable to find a suitable algorithm for doing forward convolutiontensorflow 找不到合适的算法来做前向卷积
【发布时间】:2016-04-30 15:03:13
【问题描述】:

TensorFlow website 上运行 PDE 示例时

#Import libraries for simulation
import tensorflow as tf
import numpy as np

sess = tf.InteractiveSession()

def make_kernel(a):
  """Transform a 2D array into a convolution kernel"""
  a = np.asarray(a)
  a = a.reshape(list(a.shape) + [1,1])
  return tf.constant(a, dtype=1)

def simple_conv(x, k):
  """A simplified 2D convolution operation"""
  x = tf.expand_dims(tf.expand_dims(x, 0), -1)
  y = tf.nn.depthwise_conv2d(x, k, [1, 1, 1, 1], padding='SAME')
  return y[0, :, :, 0]

def laplace(x):
  """Compute the 2D laplacian of an array"""
  laplace_k = make_kernel([[0.5, 1.0, 0.5],
                           [1.0, -6., 1.0],
                           [0.5, 1.0, 0.5]])
  return simple_conv(x, laplace_k)



# Initial Conditions -- some rain drops hit a pond
N = 500

# Set everything to zero
u_init = np.zeros([N, N], dtype=np.float32)
ut_init = np.zeros([N, N], dtype=np.float32)

# Some rain drops hit a pond at random points
for n in range(40):
  a,b = np.random.randint(0, N, 2)
  u_init[a,b] = np.random.uniform()


# Parameters:
# eps -- time resolution
# damping -- wave damping
eps = tf.placeholder(tf.float32, shape=())
damping = tf.placeholder(tf.float32, shape=())

# Create variables for simulation state
U  = tf.Variable(u_init)
Ut = tf.Variable(ut_init)

# Discretized PDE update rules
U_ = U + eps * Ut
Ut_ = Ut + eps * (laplace(U) - damping * Ut)

# Operation to update the state
step = tf.group(
  U.assign(U_),
  Ut.assign(Ut_))

# Initialize state to initial conditions
tf.initialize_all_variables().run()

# Run 1000 steps of PDE
nsteps = 1000
for i in range(nsteps):
  # Step simulation
  step.run({eps: 0.03, damping: 0.04})
  # Visualize every 50 steps
  if i % 50 == 0:
    print("iter = %d, max(U) = %f, min(U) = %f" % \
        (i, np.max(U.eval()), np.min(U.eval())))

sess.close()

在我本地机器上的 GPU 上,我在 step.run({eps: 0.03, damping: 0.04}) 的循环中收到以下错误

I tensorflow/core/common_runtime/gpu/gpu_device.cc:755] 创建 TensorFlow 设备 (/gpu:0) -> (设备:0,名称:GeForce GTX 750 Ti,pci 总线 ID:0000:01:00.0 )

F tensorflow/stream_executor/cuda/cuda_dnn.cc:675] 检查失败:status == CUDNN_STATUS_SUCCESS (3 vs. 0) 无法找到适合进行前向卷积的算法

中止(核心转储)

当我使用 CPU with tf.device('/cpu:0'): 运行代码时,它运行良好。此外,我还使用 GPU 运行了其他示例。

这是他们尚未实现的功能吗?还是我在某个地方犯了错误?

系统信息:

操作系统:Ubuntu 14.04 LTS

显卡:GeForce GTX 750 Ti

已安装的 CUDA 和 cuDNN 版本:CUDA 7.5、cuNN v5

我通过从 GitHub 拉取源来安装源代码。有关 GitHub 问题跟踪器的更多信息:https://github.com/tensorflow/tensorflow/issues/2174

【问题讨论】:

  • 请在您的问题正文中包含一个可运行的示例,而不是作为链接。见MCVE

标签: tensorflow


【解决方案1】:

(1)TensorFlow要求(请参考tensorflow手册)

TensorFlow Python API 支持 Python 2.7 和 Python 3.3+。

GPU 版本(仅限 Linux)最适用于 Cuda Toolkit 7.5 和 cuDNN v4。仅在从源安装时才支持其他版本(Cuda 工具包 >= 7.0 和 cuDNN 6.5(v2)、7.0(v3)、v5)。

(2) 凑合

因此 (2-1) 移除cuDNN5 (2-2) 安装cuDNN4并设置

(2-3-1) 卸载tensorflow (2-3-2) 安装(gpu) tensorflow

【讨论】:

    猜你喜欢
    • 2019-06-18
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    相关资源
    最近更新 更多