F ./tensorflow/core/util/cuda_launch_config.h:127]检查失败:work_element_count> 0(0对0)

时间:2018-04-07 08:32:34

标签: python tensorflow keras

我的电脑得到两个gpus,它'这是正常的,如果我不在上下文中添加此代码。

model = keras.utils.training_utils.multi_gpu_model(base_model, gpus=2)

但它只会使用一个来计算,我不明白它的含义' work_element_count> 0&#39 ;.是不是我之前没有清除过cuda?

我尝试了一些方法,减少了batch_size,在下面添加了这样的代码:

with tf.device('/cpu:0'):
   model = keras.utils.training_utils.multi_gpu_model(base_model, gpus=2)

错误消息' work_element_count> 0'发生在tensorflow基本源代码文件' python3.6 / site-packages / tensorflow / include / tensorflow / core / util / cuda_launch_config.h '

// Calculate the Cuda launch config we should use for a kernel launch.
// This is assuming the kernel is quite simple and will largely be
// memory-limited.
// REQUIRES: work_element_count > 0.
inline CudaLaunchConfig GetCudaLaunchConfig(int work_element_count,
                                            const Eigen::GpuDevice& d) {
  CHECK_GT(work_element_count, 0);
  CudaLaunchConfig config;
  const int virtual_thread_count = work_element_count;
  const int physical_thread_count = std::min(
      d.getNumCudaMultiProcessors() * d.maxCudaThreadsPerMultiProcessor(),
      virtual_thread_count);
  const int thread_per_block = std::min(1024, d.maxCudaThreadsPerBlock());
  const int block_count =
      std::min(DivUp(physical_thread_count, thread_per_block),
               d.getNumCudaMultiProcessors());

  config.virtual_thread_count = virtual_thread_count;
  config.thread_per_block = thread_per_block;
  config.block_count = block_count;
  return config;
}

但它们似乎没有效果,任何帮助都将非常感激!

0 个答案:

没有答案