Skip to content

Commit

Permalink
Add property memory_free, aliases memory_available
Browse files Browse the repository at this point in the history
  • Loading branch information
wookayin committed Nov 2, 2017
1 parent f4d35e3 commit a479e6d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gpustat.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,20 @@ def memory_used(self):
return int(self.entry['memory.used'])

@property
def memory_available(self):
def memory_free(self):
"""
Returns the available memory (in MB) as an integer.
Returns the free (available) memory (in MB) as an integer.
"""
v = self.memory_total - self.memory_used
return max(v, 0)

@property
def memory_available(self):
"""
Returns the available memory (in MB) as an integer. Alias of memory_free.
"""
return self.memory_free

@property
def temperature(self):
"""
Expand Down Expand Up @@ -469,9 +476,9 @@ def main():

parser_color = parser.add_mutually_exclusive_group()
parser_color.add_argument('--force-color', '--color', action='store_true',
help='Force to output with colors')
help='Force to output with colors')
parser_color.add_argument('--no-color', action='store_true',
help='Suppress colored output')
help='Suppress colored output')

parser.add_argument('-c', '--show-cmd', action='store_true',
help='Display cmd name of running process')
Expand Down

0 comments on commit a479e6d

Please sign in to comment.