Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rmm

> 编程语言
Open source

RAPIDS Memory Manager

708 stars0 likes1 views
WebsiteGitHub

About

RAPIDS Memory Manager

NVIDIA RMM

NOTE: For the latest stable README.md ensure you are on the main branch.

Resources

  • RMM Reference Documentation: Python and C++ API references, tutorials, and topic guides.
  • Installation: Instructions for installing RMM.
  • GitHub Repository: Download the RMM source code.
  • Issue Tracker: Report issues or request features.

Overview

Achieving optimal performance in GPU-centric workflows frequently requires customizing how host and device memory are allocated. For example, using "pinned" host memory for asynchronous host device memory transfers, or using a device memory pool sub-allocator to reduce the cost of dynamic device memory allocation.

The goal of RMM is to provide:

  • A common interface that allows customizing memory allocation on device and host
  • A collection of implementations of the interface
  • A collection of data structures that use the interface for memory allocation

For information on the interface RMM provides and how to use RMM in your C++ code, see below.

For a walkthrough of the design of RMM, read Fast, Flexible Allocation for NVIDIA CUDA with RMM on the NVIDIA Developer Blog.

Installation

System Requirements

Please see the Installation Guide for NVIDIA CUDA-X libraries for data science for information about supported operating systems, GPU drivers, and CUDA versions.

pip

Stable releases of librmm and rmm are available on PyPI. Match the package suffix to the major CUDA version supported by your installed driver.

bash
# CUDA 13
pip install librmm-cu13
pip install rmm-cu13

# CUDA 12
pip install librmm-cu12
pip install rmm-cu12

Development versions are available as nightly releases:

bash
# CUDA 13
pip install --pre \
  --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple \
  librmm-cu13
pip install --pre \
  --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple \
  rmm-cu13

# CUDA 12
pip install --pre \
  --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple \
  librmm-cu12
pip install --pre \
  --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple \
  rmm-cu12

conda

Stable releases of librmm and rmm are available from the rapidsai channel. Development versions are available from the rapidsai-nightly channel.

bash
# Stable
conda install -c rapidsai -c conda-forge librmm
conda install -c rapidsai -c conda-forge rmm

# Nightly
conda install -c rapidsai-nightly -c conda-forge librmm
conda install -c rapidsai-nightly -c conda-forge rmm

Building from Source

Get RMM Dependencies

Compiler requirements:

  • gcc version 13.3+
  • nvcc version 12.9+
  • cmake version 4.0+

CUDA/GPU runtime requirements:

  • CUDA 12.2+. You can obtain CUDA from https://developer.nvidia.com/cuda-downloads

GPU Support:

  • RMM is tested and supported only on Volta architecture and newer (Compute Capability 7.0+).

Python requirements:

  • rapids-build-backend (available from PyPI or the rapidsai conda channel)
  • scikit-build-core
  • cuda-python
  • cython

For more details, see pyproject.toml

Script to build RMM from source

To install RMM from source, ensure the dependencies are met and follow the steps below:

  • Clone the repository:
bash
$ git clone https://github.com/rapidsai/rmm.git
$ cd rmm
  • Create the conda development environment rmm_dev:
bash
# create the conda environment (assuming in base `rmm` directory)
$ conda env create --name rmm_dev --file conda/environments/all_cuda-133_arch-$(uname -m).yaml
# activate the environment
$ conda activate rmm_dev
  • Build and install librmm using cmake & make. CMake depends on the nvcc executable being on your path or defined in CUDACXX environment variable.
bash
$ mkdir build                                       # make a build directory
$ cd build                                          # enter the build directory
$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/path     # configure cmake ... use $CONDA_PREFIX if you're using a conda environment
$ make -j                                           # compile the library librmm.so ... '-j' will start a parallel job using the number of physical cores available on your system
$ make install                                      # install the library librmm.so to '/install/path'
  • Building and installing librmm and rmm using build.sh. build.sh creates a build directory at the root of the git repository. build.sh depends on the nvcc executable being on your path or defined in the CUDACXX environment variable.
bash
$ ./build.sh -h                                     # Display help and exit
$ ./build.sh -n librmm                              # Build librmm without installing
$ ./build.sh -n rmm                                 # Build rmm without installing
$ ./build.sh -n librmm rmm                          # Build librmm and rmm without installing
$ ./build.sh librmm rmm                             # Build and install librmm and rmm
  • To run tests (Optional):
bash
$ cd build (if you are not already in the build directory)
$ make test
  • Build, install, and test the rmm python package, in the python folder:
bash
# In the root rmm directory
$ python -m pip wheel ./python/librmm
$ python -m pip install --find-links=. -e ./python/rmm
$ pytest -v

Done! You are ready to develop for the RMM project.

Caching third-party dependencies

RMM uses CPM.cmake to handle third-party dependencies like CCCL, GoogleTest, GoogleBenchmark. In general you won't have to worry about it. If CMake finds an appropriate version on your system, it uses it (you can help it along by setting CMAKE_PREFIX_PATH to point to the installed location). Otherwise those dependencies will be downloaded as part of the build.

If you frequently start new builds from scratch, consider setting the environment variable CPM_SOURCE_CACHE to an external download directory to avoid repeated downloads of the third-party dependencies.

ABI versioning

RMM symbols are placed in an inline namespace derived from the RMM major and minor version. The public API remains available through the rmm:: namespace, while static RMM libraries built for different ABI versions can coexist in one process. Process-global state is shared by RMM copies with the same ABI version and kept separate across different ABI versions.

Using RMM in a downstream CMake project

The installed RMM library provides a set of config files that makes it easy to integrate RMM into your own CMake project. Add the following to CMakeLists.txt:

cmake
find_package(rmm [VERSION])
# ...
target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm)

This links librmm, makes RMM headers available, and pulls in transitive dependencies. If RMM is not installed in a default location, use CMAKE_PREFIX_PATH or rmm_ROOT to point to its location.

Using CPM to manage RMM

RMM uses CPM.cmake to manage its dependencies, including CCCL, and you can use CPM for your project's dependency on RMM.

There is an issue with using CPM's single-argument compact syntax for RMM/CCCL as it transitively marks targets as SYSTEM dependencies. This causes the CCCL headers pulled in through CPM to be of lower priority to the preprocessor than the (potentially outdated) CCCL headers provided by the CUDA SDK. To avoid this issue, use CPM's multi-argument syntax instead:

cmake
CPMAddPackage(NAME rmm [VERSION]
              GITHUB_REPOSITORY rapidsai/rmm
              SYSTEM OFF
              SOURCE_SUBDIR cpp)
# ...
target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm)

Using RMM in C++

The first goal of RMM is to provide a common interface for device memory allocation. This allows both users and implementers of custom allocation logic to program to a single interface.

RMM's memory resources use CCCL's memory resource concepts. Resource APIs accept either concrete resource objects, non-owning resource refs such as rmm::device_async_resource_ref, or owning type-erased resources such as cuda::mr::any_resource.

Memory Resources

A device memory resource satisfies the CCCL resource concept and provides stream-ordered allocation and deallocation:

cpp
void* allocate(cuda::stream_ref stream,
               std::size_t bytes,
               std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT);
void deallocate(cuda::stream_ref stream,
                void* ptr,
                std::size_t bytes,
                std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT) noexcept;

RMM also uses rmm::device_async_resource_ref, an alias for cuda::mr::resource_ref, as a lightweight non-owning reference to a device resource. RMM uses cuda::mr::any_resource as an owning type-erased resource. RMM resources with non-trivial state are value types with shared ownership of their internal state, so copying a resource object is inexpensive and keeps the underlying state alive.

Stream-ordered Memory Allocation

RMM memory resources provide stream-ordered memory allocation. This allows optimizations such as re-using memory deallocated on the same stream without the overhead of synchronization.

A call to resource.allocate(stream_a, bytes) returns a pointer that is valid to use on stream_a. Using the memory on a different stream (say stream_b) is Undefined Behavior unless the two streams are first synchronized, for example by using cudaStreamSynchronize(stream_a) or by recording a CUDA event on stream_a and then calling cudaStreamWaitEvent(stream_b, event).

The stream specified to deallocate should be a stream on which it is valid to use the deallocated memory immediately for another allocation. Typically this is the stream on which the allocation was last used before the call to deallocate. The passed stream may be used internally by a memory resource for managing available memory with minimal synchronization, and it may also be synchronized at a later time, for example using a call to cudaStreamSynchronize().

For this reason, it is Undefined Behavior to destroy a CUDA stream that is passed to deallocate. If the stream on which the allocation was last used has been destroyed before calling deallocate or it is known that it will be destroyed, it is likely better to synchronize the stream (before destroying it) and then pass a different stream to deallocate (e.g. the default stream).

Note that device memory data structures such as rmm::device_buffer and rmm::device_uvector follow these stream-ordered memory allocation semantics and rules.

For further information about stream-ordered memory allocation semantics, read Using the NVIDIA CUDA Stream-Ordered Memory Allocator on the NVIDIA Developer Blog.

Available Device Resources

RMM provides several device memory resources to satisfy various user requirements. For more detailed information about these resources, see their respective documentation.

cuda_memory_resource

Allocates and frees device memory using cudaMalloc

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++cudamemory-allocationmemory-managementrapids

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言