RAPIDS AI
Published in

RAPIDS AI

PyTorch + Rapids RMM: Maximize the Memory Efficiency of your Workflows

You can make beautiful things with an efficient torch.

Motivation

How To Use It

>>> torch.cuda.memory.change_current_allocator(rmm.rmm_torch_allocator)
>>> import rmm, pprint
>>> import cudf
>>> rmm.reinitialize(pool_allocator = True,
... initial_pool_size = 10e9,
... maximum_pool_size= 11e9
... )
>>>
>>> mr = rmm.mr.get_current_device_resource()
>>> stats_pool_memory_resource = rmm.mr.StatisticsResourceAdaptor(mr)
>>> rmm.mr.set_current_device_resource(stats_pool_memory_resource)
>>> s = cudf.Series([1, 2])
>>> pprint.pprint(stats_pool_memory_resource.allocation_counts)
{'current_bytes': 16,
'current_count': 1,
'peak_bytes': 16,
'peak_count': 1,
'total_bytes': 16,
'total_count': 1}
>>> import torch
>>> torch.cuda.memory.change_current_allocator(rmm.rmm_torch_allocator)
>>> w = torch.tensor([1, 2, 3]).cuda()  # 24 bytes
>>> pprint.pprint(stats_pool_memory_resource.allocation_counts)
{'current_bytes': 40,
'current_count': 2,
'peak_bytes': 40,
'peak_count': 2,
'total_bytes': 40,
'total_count': 2}
>>> del s
>>> stats_pool_memory_resource.allocation_counts
{'current_bytes': 24,
'current_count': 1,
'peak_bytes': 40,
'peak_count': 2,
'total_bytes': 40,
'total_count': 2}

Conclusion

--

--

RAPIDS is a suite of software libraries for executing end-to-end data science & analytics pipelines entirely on GPUs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store