Skip to main content
 首页 » 编程设计

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

2025年01月19日9jackei

我正在使用 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在 tensorflow 1.3 中。 fix已移植到 1.4(当然还有更高版本)。您有 tensorflow 1.5.0,但没有 tensorflow-gpu - 1.3.0。当您从 keras 运行 multi_gpu_model 时,它显然正在使用 tensorflow-gpu ops。

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