An extension of the PersistentDataset using direct memory access(DMA) data path between GPU memory and storage, thus avoiding a bounce buffer through the CPU. This direct path can increase system bandwidth while decreasing latency and utilization load on the CPU and GPU. A tutorial
| 1546 | |
| 1547 | |
| 1548 | class GDSDataset(PersistentDataset): |
| 1549 | """ |
| 1550 | An extension of the PersistentDataset using direct memory access(DMA) data path between |
| 1551 | GPU memory and storage, thus avoiding a bounce buffer through the CPU. This direct path can increase system |
| 1552 | bandwidth while decreasing latency and utilization load on the CPU and GPU. |
| 1553 | |
| 1554 | A tutorial is available: https://github.com/Project-MONAI/tutorials/blob/main/modules/GDS_dataset.ipynb. |
| 1555 | |
| 1556 | See also: https://github.com/rapidsai/kvikio |
| 1557 | """ |
| 1558 | |
| 1559 | def __init__( |
| 1560 | self, |
| 1561 | data: Sequence, |
| 1562 | transform: Sequence[Callable] | Callable, |
| 1563 | cache_dir: Path | str | None, |
| 1564 | device: int, |
| 1565 | hash_func: Callable[..., bytes] = pickle_hashing, |
| 1566 | hash_transform: Callable[..., bytes] | None = None, |
| 1567 | reset_ops_id: bool = True, |
| 1568 | **kwargs: Any, |
| 1569 | ) -> None: |
| 1570 | """ |
| 1571 | Args: |
| 1572 | data: input data file paths to load and transform to generate dataset for model. |
| 1573 | `GDSDataset` expects input data to be a list of serializable |
| 1574 | and hashes them as cache keys using `hash_func`. |
| 1575 | transform: transforms to execute operations on input data. |
| 1576 | cache_dir: If specified, this is the location for gpu direct storage |
| 1577 | of pre-computed transformed data tensors. The cache_dir is computed once, and |
| 1578 | persists on disk until explicitly removed. Different runs, programs, experiments |
| 1579 | may share a common cache dir provided that the transforms pre-processing is consistent. |
| 1580 | If `cache_dir` doesn't exist, will automatically create it. |
| 1581 | If `cache_dir` is `None`, there is effectively no caching. |
| 1582 | device: target device to put the output Tensor data. Note that only int can be used to |
| 1583 | specify the gpu to be used. |
| 1584 | hash_func: a callable to compute hash from data items to be cached. |
| 1585 | defaults to `monai.data.utils.pickle_hashing`. |
| 1586 | hash_transform: a callable to compute hash from the transform information when caching. |
| 1587 | This may reduce errors due to transforms changing during experiments. Default to None (no hash). |
| 1588 | Other options are `pickle_hashing` and `json_hashing` functions from `monai.data.utils`. |
| 1589 | reset_ops_id: whether to set `TraceKeys.ID` to ``Tracekys.NONE``, defaults to ``True``. |
| 1590 | When this is enabled, the traced transform instance IDs will be removed from the cached MetaTensors. |
| 1591 | This is useful for skipping the transform instance checks when inverting applied operations |
| 1592 | using the cached content and with re-created transform instances. |
| 1593 | |
| 1594 | """ |
| 1595 | super().__init__( |
| 1596 | data=data, |
| 1597 | transform=transform, |
| 1598 | cache_dir=cache_dir, |
| 1599 | hash_func=hash_func, |
| 1600 | hash_transform=hash_transform, |
| 1601 | reset_ops_id=reset_ops_id, |
| 1602 | **kwargs, |
| 1603 | ) |
| 1604 | self.device = device |
| 1605 | self._meta_cache: dict[Any, dict[Any, Any]] = {} |
no outgoing calls
searching dependent graphs…