Skip to content

Commit

Permalink
Merge branch 'ershi/doc_devices' into 'master'
Browse files Browse the repository at this point in the history
Document Device total_memory and free_memory

See merge request omniverse/warp!380
  • Loading branch information
shi-eric committed Mar 14, 2024
2 parents c834c50 + d674259 commit dc47895
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions warp/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,10 @@ def has_stream(self):

@property
def total_memory(self):
"""The total amount of device memory available in bytes.
This function is currently only implemented for CUDA devices. 0 will be returned if called on a CPU device.
"""
if self.is_cuda:
total_mem = ctypes.c_size_t()
self.runtime.core.cuda_device_get_memory_info(self.ordinal, None, ctypes.byref(total_mem))
Expand All @@ -2177,6 +2181,10 @@ def total_memory(self):

@property
def free_memory(self):
"""The amount of memory on the device that is free according to the OS in bytes.
This function is currently only implemented for CUDA devices. 0 will be returned if called on a CPU device.
"""
if self.is_cuda:
free_mem = ctypes.c_size_t()
self.runtime.core.cuda_device_get_memory_info(self.ordinal, ctypes.byref(free_mem), None)
Expand Down

0 comments on commit dc47895

Please sign in to comment.