【问题标题】:Tensorflow 1.14: InvalidArgumentError: device CUDA:0 not supported by XLA service while setting up XLA_GPU_JIT device number 0Tensorflow 1.14:InvalidArgumentError:设备 CUDA:0 在设置 XLA_GPU_JIT 设备号 0 时不受 XLA 服务支持
【发布时间】:2021-09-11 23:50:51
【问题描述】:

我正在使用带有 2 个 GPU 的 Tensorflow 1.14,但它们都被另一位同事占用了 20 天。有没有办法在 CPU 上运行我的代码?我试过了

config123 = tf.ConfigProto(device_count = {'GPU': 0})
with tf.Session(config=config123) as sess:

os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

但他们仍然给出标题中提到的错误。任何帮助将不胜感激!

【问题讨论】:

  • os.environ['CUDA_VISIBLE_DEVICES'] = '' 在 CUDA 1.11 的 Tensorflow 1.14 上工作

标签: python tensorflow


【解决方案1】:

如果您希望特定操作在您选择的设备上运行,而不是自动为您选择的设备,您可以使用 tf.device 创建设备上下文,该上下文中的所有操作都将在相同的指定设备。

tf.debugging.set_log_device_placement(True)

# Place tensors on the CPU
with tf.device('/CPU:0'):
  a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
  b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])

  c = tf.matmul(a, b)

【讨论】:

    猜你喜欢
    • 2019-12-20
    • 2020-03-02
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 1970-01-01
    相关资源
    最近更新 更多