【问题标题】:Tensorflow: device CUDA:0 not supported by XLA service while setting up XLA_GPU_JIT device number 0Tensorflow:设置 XLA_GPU_JIT 设备编号 0 时,XLA 服务不支持设备 CUDA:0
【发布时间】:2019-12-20 08:30:00
【问题描述】:

我在使用带有 Tensorflow 后端的 keras 时得到了这个:

tensorflow.python.framework.errors_impl.InvalidArgumentError:XLA 服务不支持设备 CUDA:0 同时设置 XLA_GPU_JIT 设备号 0

相关代码:

tfconfig = tf.ConfigProto()
tfconfig.graph_options.optimizer_options.global_jit_level = tf.OptimizerOptions.ON_1
tfconfig.gpu_options.allow_growth = True
K.tensorflow_backend.set_session(tf.Session(config=tfconfig))

张量流版本:1.14.0

【问题讨论】:

    标签: tensorflow keras tensorflow-xla


    【解决方案1】:

    郭董事长的代码:

    os.environ["CUDA_VISIBLE_DEVICES"] = "1" 
    

    解决了我的 jupyter notebook 内核崩溃的问题:

    tf.keras.models.load_model(path/to/my/model)
    

    致命消息是:

    2020-01-26 11:31:58.727326: F tensorflow/stream_executor/lib/statusor.cc:34] 尝试获取 值而不是处理错误内部:初始化失败 CUDA 设备序号 0 的 StreamExecutor:内部:调用失败 cuDevicePrimaryCtxRetain: CUDA_ERROR_UNKNOWN: 未知错误

    我的TF的版本是:2.2.0-dev20200123。此系统上有 2 个 GPU。

    【讨论】:

    • 我遇到了同样的问题,您的解决方案解决了它。非常感谢!
    【解决方案2】:

    这可能是由于您的 TF 默认(即第一个)GPU 内存不足。如果您有多个 GPU,请将您的 Python 程序转移到其他 GPU 上运行。在TF中(假设使用TF-2.0-rc1),设置如下:

    # Specify which GPU(s) to use
    os.environ["CUDA_VISIBLE_DEVICES"] = "1"  # Or 2, 3, etc. other than 0
    
    # On CPU/GPU placement
    config = tf.compat.v1.ConfigProto(allow_soft_placement=True, log_device_placement=True)
    config.gpu_options.allow_growth = True
    tf.compat.v1.Session(config=config)
    
    # Note that ConfigProto disappeared in TF-2.0
    

    然而,假设你的环境只有一个 GPU,那么也许你别无选择,只能让你的伙伴停止他的程序,然后请他喝杯咖啡。

    【讨论】:

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