-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and document GPU buffer handling (#2751)
* Update GPU handling This updates how we handle GPU buffers. See the new docs page for a simple example. The basic idea, as discussed in ..., is to use host buffers for all metadata objects and device buffers for data. Zarr has two types of buffers: plain buffers (used for a stream of bytes) and ndbuffers (used for bytes that represent ndarrays). To make it easier for users, I've added a new config option `zarr.config.enable_gpu()` that can be used to update those both. If we need additional customizations in the future, we can add them here. * fixed doc * Fixup * changelog * doctest, skip * removed not gpu * assert that the type matches * Added changelog notes --------- Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
- Loading branch information
1 parent
47003d7
commit 24ef221
Showing
12 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed bug with Zarr using device memory, instead of host memory, for storing metadata when using GPUs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added new user guide on :ref:`user-guide-gpu`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added :meth:`zarr.config.enable_gpu` to update Zarr's configuration to use GPUs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.. _user-guide-gpu: | ||
|
||
Using GPUs with Zarr | ||
==================== | ||
|
||
Zarr can use GPUs to accelerate your workload by running | ||
:meth:`zarr.config.enable_gpu`. | ||
|
||
.. note:: | ||
|
||
`zarr-python` currently supports reading the ndarray data into device (GPU) | ||
memory as the final stage of the codec pipeline. Data will still be read into | ||
or copied to host (CPU) memory for encoding and decoding. | ||
|
||
In the future, codecs will be available compressing and decompressing data on | ||
the GPU, avoiding the need to move data between the host and device for | ||
compression and decompression. | ||
|
||
Reading data into device memory | ||
------------------------------- | ||
|
||
:meth:`zarr.config.enable_gpu` configures Zarr to use GPU memory for the data | ||
buffers used internally by Zarr. | ||
|
||
.. code-block:: python | ||
>>> import zarr | ||
>>> import cupy as cp # doctest: +SKIP | ||
>>> zarr.config.enable_gpu() # doctest: +SKIP | ||
>>> store = zarr.storage.MemoryStore() # doctest: +SKIP | ||
>>> z = zarr.create_array( # doctest: +SKIP | ||
... store=store, shape=(100, 100), chunks=(10, 10), dtype="float32", | ||
... ) | ||
>>> type(z[:10, :10]) # doctest: +SKIP | ||
cupy.ndarray | ||
Note that the output type is a ``cupy.ndarray`` rather than a NumPy array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ Advanced Topics | |
performance | ||
consolidated_metadata | ||
extending | ||
gpu | ||
|
||
|
||
.. Coming soon | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters