我使用keras预训练的InceptionResNetV2提取图像特征。 但是,即使我只预测单个文件,也总是在预测图像时导致CUDA_ERROR_OUT_OF_MEMORY。
环境为CUDA 10.0,cudnn 7.4,tensorflow 1.13,RTX2070。GPU内存为8GB。
以下是代码:
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))
...
IR2 = InceptionResNetV2(weights='imagenet', include_top=False)
...
features = IR2.predict_on_batch(np.array([test_image]))
#test_image only contains one image
错误消息是:
E tensorflow/stream_executor/cuda/cuda_driver.cc:806] failed to allocate 3.53G (3794432768 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory
W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.39GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
W tensorflow/core/common_runtime/bfc_allocator.cc:211] Allocator (GPU_0_bfc) ran out of memory trying to allocate 3.39GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.