From: Francois Fleuret Date: Wed, 21 Jun 2017 06:53:08 +0000 (+0200) Subject: Added some memory-related diagnosis. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=41bce03783537fc0f714e123e5a439847e16f5ae;p=pysvrt.git Added some memory-related diagnosis. --- diff --git a/svrtset.py b/svrtset.py index 4022752..ead6083 100755 --- a/svrtset.py +++ b/svrtset.py @@ -111,6 +111,7 @@ class CompressedVignetteSet: acc = 0.0 acc_sq = 0.0 + usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss for b in range(0, self.nb_batches): target = torch.LongTensor(self.batch_size).bernoulli_(0.5) input = svrt.generate_vignettes(problem_number, target) @@ -134,6 +135,10 @@ class CompressedVignetteSet: print('Memory leak?!') raise + mem = (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss - usage) * 1024 + print('Using ' + str(mem / (1024 * 1024)) + 'Gb / ' + + str(mem / self.nb_samples) + ' bytes per sample') + self.mean = acc / self.nb_batches self.std = sqrt(acc_sq / self.nb_batches - self.mean * self.mean)