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

Function setup_async_pool

demo/guide-python/external_memory.py:186–212  ·  view source on GitHub ↗

Setup CUDA async pool. As an alternative, the RMM plugin can be used as well. See the `setup_rmm`. 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

184
185
186def setup_async_pool() -> None:
187 """Setup CUDA async pool. As an alternative, the RMM plugin can be used as well. See
188 the `setup_rmm`. This is the same as using the `CudaAsyncMemoryResource` from RMM,
189 but without the RMM dependency.
190
191 .. versionadded:: 3.2.0
192
193 """
194 import cuda.bindings.runtime as cudart
195 import cupy as cp # pylint: disable=import-outside-toplevel
196 from cuda.bindings import driver
197 from cupy.cuda import MemoryAsyncPool
198
199 status, dft_pool = cudart.cudaDeviceGetDefaultMemPool(0)
200 _checkcu(status)
201
202 total = device_mem_total()
203
204 v = driver.cuuint64_t(int(total * 0.9))
205 (status,) = cudart.cudaMemPoolSetAttribute(
206 dft_pool,
207 cudart.cudaMemPoolAttr.cudaMemPoolAttrReleaseThreshold,
208 v,
209 )
210 _checkcu(status)
211 # Set the allocator for cupy as well.
212 cp.cuda.set_allocator(MemoryAsyncPool().malloc)
213
214
215def setup_rmm() -> None:

Callers 1

external_memory.pyFile · 0.70

Calls 2

_checkcuFunction · 0.70
device_mem_totalFunction · 0.70

Tested by

no test coverage detected