From 7e8c337a6805f7c97ec94dcd628fb525b58d10f2 Mon Sep 17 00:00:00 2001 From: Yancey Date: Fri, 11 Aug 2017 16:15:42 +0800 Subject: [PATCH] Fix save large parameters failed (#3397) Fix save large parameters crashed --- python/paddle/v2/parameters.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/paddle/v2/parameters.py b/python/paddle/v2/parameters.py index 8d8012e5d..b8af5abae 100644 --- a/python/paddle/v2/parameters.py +++ b/python/paddle/v2/parameters.py @@ -281,7 +281,13 @@ class Parameters(object): size = reduce(lambda a, b: a * b, param.shape) f.write(struct.pack("IIQ", 0, 4, size)) param = param.astype(np.float32) - f.write(param.tostring()) + s = param.tostring() + wrote_size = 0 + buf = buffer(s, wrote_size, 65535) + while buf: # f.write crashes with big data blog. + f.write(buf) + wrote_size += 65535 + buf = buffer(s, wrote_size, 65535) def deserialize(self, name, f): """ -- GitLab