如何捕获tensorflow.python.framework.errors_impl.InternalError?

时间:2018-10-23 18:23:39

标签: python tensorflow exception-handling

我正在尝试在运行其他实验的共享主机上使用TensorFlow。有时我碰到tensorflow.python.framework.errors_impl.InternalError,但我尝试抓住了一个例外:

try:
    with tf.Session() as sess:
        ...
except tensorflow.python.framework.errors_impl.InternalError as e:
    ...

不幸的是,这种方法似乎效果不佳,因为随后我得到了:

tensorflow.python.framework.errors_impl.InternalError: failed initializing StreamExecutor for CUDA device ordinal 1: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_INVALID_VALUE: invalid argument
...
During handling of the above exception, another exception occurred:
...
NameError: name 'tensorflow' is not defined

如何捕捉InternalError并尝试在短时间内重新运行实验?

0 个答案:

没有答案