Skip to content

Commit

Permalink
Correctly parse caffe's 0 memory usage message
Browse files Browse the repository at this point in the history
As pointed out in #13, DIGITS throws an exception if caffe reports that
the memory usage for a model is 0 bytes. This is a bug in caffe, but
DIGITS should be robust enough to handle it.
  • Loading branch information
lukeyeager committed Mar 20, 2015
1 parent 03f1cce commit c85b50d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions digits/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def sizeof_fmt(size, suffix='B'):
Arguments:
size -- size in bytes
"""
try:
size = int(size)
except ValueError:
return None
if size <= 0:
return '0 %s' % suffix

size_name = ('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
i = int(math.floor(math.log(size,1024)))
if i >= len(size_name):
Expand Down

0 comments on commit c85b50d

Please sign in to comment.