11

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

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

相关代码:

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

4

2 回答 2

4

郭董事长代码:

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。

于 2020-01-26T12:12:07.950 回答
1

这可能是由于您的 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,那么您可能别无选择,只能让您的伙伴停止他的程序,然后请他喝杯咖啡。

于 2019-09-23T07:46:18.993 回答