【问题标题】:InternalError: Failed copying input tensor from device:CPU:0 to device:GPU:0 in order to run _EagerConst: Dst tensor is not initializedInternalError:将输入张量从设备:CPU:0 复制到设备:GPU:0 以运行 _EagerConst 失败:Dst 张量未初始化
【发布时间】:2022-04-06 22:19:47
【问题描述】:
linux_user@server_machine:~/spatial/tuning_neighbors_7$ python3 *hyper*.py
Traceback (most recent call last):
  File "tuner_hyperband.py", line 209, in <module>
    load_data_k(
  File "tuner_hyperband.py", line 127, in load_data_k
    tz = tf.convert_to_tensor(data_z, np.float32)
  File "/home/linux_user/.local/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/linux_user/.local/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 106, in convert_to_eager_tensor
    return ops.EagerTensor(value, ctx.device_name, dtype)
tensorflow.python.framework.errors_impl.InternalError: Failed copying input tensor from /job:localhost/replica:0/task:0/device:CPU:0 to /job:localhost/replica:0/task:0/device:GPU:0 in order to run _EagerConst: Dst tensor is not initialized.
linux_user@server_machine:~/spatial/tuning_neighbors_7$

这个错误的主要原因是什么?

  • 是因为磁盘空间不足吗?

  • 是因为内存不足吗?

  • 是因为使用了 GPU 吗?

如何解决?

【问题讨论】:

标签: python tensorflow keras gpu


【解决方案1】:

这是因为 GPU RAM 内存已满(至少对我而言)。 这是完整的信息吗?因为在我的情况下它相当长(并且很明显这是一个内存问题)。见here

一些调试技巧:

  1. 您可以使用tf.config.experimental.get_memory_info('GPU:0')['current'] / 10**9 来查看直到某个点的内存使用情况。
  2. 在某些时候,tensorflow 应该在类似Created device /job:localhost/replica:0/task:0/device:GPU:0 with 9058 MB memory 的消息中告诉你你的可用内存
  3. 如果您使用的是转换为张量或用于fitevaluate 或等效函数的 numpy 数组,您可以使用npa.size * npa.itemsize / 10**9 来了解创建新张量所需的大小。

【讨论】:

    猜你喜欢
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    • 2023-02-16
    • 2020-05-01
    • 2016-07-06
    • 2021-06-19
    • 2020-09-09
    相关资源
    最近更新 更多