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
()
| 184 | |
| 185 | |
| 186 | def 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 | |
| 215 | def setup_rmm() -> None: |
no test coverage detected