MCPcopy Create free account
hub / github.com/dmlc/xgboost / setup_async_pool

Function setup_async_pool

demo/guide-python/distributed_extmem_basic.py:145–172  ·  view source on GitHub ↗

Setup CUDA async pool. As an alternative, the RMM plugin can be used as well. This is the same as using the `CudaAsyncMemoryResource` from RMM, but without the RMM dependency. .. versionadded:: 3.2.0

()

Source from the content-addressed store, hash-verified

143
144
145def setup_async_pool() -> None:
146 """Setup CUDA async pool. As an alternative, the RMM plugin can be used as well.
147 This is the same as using the `CudaAsyncMemoryResource` from RMM, but without the
148 RMM dependency.
149
150 .. versionadded:: 3.2.0
151
152 """
153 import cuda.bindings.runtime as cudart
154 from cuda.bindings import driver
155 from cupy.cuda import MemoryAsyncPool
156
157 status, dft_pool = cudart.cudaDeviceGetDefaultMemPool(0)
158 _checkcu(status)
159
160 total = device_mem_total()
161
162 v = driver.cuuint64_t(int(total * 0.9))
163 (status,) = cudart.cudaMemPoolSetAttribute(
164 dft_pool,
165 cudart.cudaMemPoolAttr.cudaMemPoolAttrReleaseThreshold,
166 v,
167 )
168 _checkcu(status)
169 # Set the allocator for cupy as well.
170 import cupy as cp
171
172 cp.cuda.set_allocator(MemoryAsyncPool().malloc)
173
174
175R = TypeVar("R")

Callers 1

initializerFunction · 0.70

Calls 2

_checkcuFunction · 0.70
device_mem_totalFunction · 0.70

Tested by

no test coverage detected