Keras multi_gpu_model error: "swig/python detected a memory leak of type 'int64_t *', no destructor found"

Keras multi_gpu_model error: "swig/python detected a memory leak of type 'int64_t *', no destructor found"

我正在使用 tensorflow 1.5.0、tensorflow-gpu 1.3.0、keras 2.0.9、keras-gpu 2.1.4

我使用以下代码创建了我的模型:

inputs = Input([1,44,44,44])
x = Conv3D(64, (3,3,3), activation='relu', data_format='channels_first')(inputs)
x = Conv3D(16, (3,3,3), activation='relu', data_format='channels_first')(x)
x = Conv3D(1, (3,3,3), activation='relu', data_format='channels_first')(x)
model = Model(inputs=inputs, outputs=x)

我想在我的机器上使用两个 GPU。 但是当我使用

from keras.utils import multi_gpu_model
parallel_model = multi_gpu_model(model, gpus=2)

我收到这个错误:

swig/python detected a memory leak of type 'int64_t *', no destructor found.
swig/python detected a memory leak of type 'int64_t *', no destructor found.
swig/python detected a memory leak of type 'int64_t *', no destructor found.

有什么建议吗?

这是一个 bug in tensorflow 1.3. The fix 已经移植到 1.4(当然还有更高版本)。您有 tensorflow 1.5.0,但没有 tensorflow-gpu - 1.3.0。当你从 keras 运行 multi_gpu_model 时,它显然正在使用 tensorflow-gpu 操作。

所以你应该更新tensorflow-gpu至少到1.4,最新版本会更好。