【发布时间】:2019-10-17 17:47:42
【问题描述】:
我在 GPU 上训练了一个模型,现在我正在尝试在 CPU 上对其进行评估(GPU 被用于不同的火车运行)。但是,当我尝试使用以下方式加载它时:
with tf.device('/cpu:0'):
model = tf.keras.models.load_model('models/resnet50_untrained.h5', compile=False)
我收到了CUDA_ERROR_OUT_OF_MEMORY:
2019-10-17 09:25:23.088408: W tensorflow/compiler/xla/service/platform_util.cc:256] unable to create StreamExecutor for CUDA:0: failed initializing StreamExecutor for CUDA device ordinal 0: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_OUT_OF_MEMORY: out of memory; total memory reported: 7981694976
2019-10-17 09:25:23.088505: F tensorflow/stream_executor/lib/statusor.cc:34] Attempting to fetch value instead of handling error Internal: no supported devices found for platform CUDA
(我也尝试设置compile=True,结果相同。)
似乎模型正在加载到另一个实例已使用的 GPU 中。如何强制 keras/tensorflow 将其加载到系统内存并在 CPU 上执行?
【问题讨论】:
标签: python tensorflow keras