Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Document CUDA acceleration #68

Merged
merged 3 commits into from
Mar 4, 2024
Merged

DOC: Document CUDA acceleration #68

merged 3 commits into from
Mar 4, 2024

Conversation

thewtex
Copy link
Owner

@thewtex thewtex commented Feb 7, 2024

No description provided.

@thewtex
Copy link
Owner Author

thewtex commented Feb 7, 2024

Hi John @jakirkham et al!

Do you have any suggestions on the following dask/cupy/cucim/kvikio issues or do you know who would?

  1. We currently get the traceback:
  File "/home/matt/src/ngff-zarr/ngff_zarr/cli.py", line 62, in _multiscales_to_ngff_zarr                                                       
    to_ngff_zarr(output_store, multiscales, progress=rich_dask_progress)                                                                        
  File "/home/matt/src/ngff-zarr/ngff_zarr/to_ngff_zarr.py", line 253, in to_ngff_zarr                                                          
    dask.array.to_zarr(                                                 
  File "/home/matt/bin/micromamba/envs/ngff-zarr/lib/python3.10/site-packages/dask/array/core.py", line 3730, in to_zarr
    return arr.store(z, lock=False, compute=compute, return_stored=return_stored)
[...]
  File "/home/matt/bin/micromamba/envs/ngff-zarr/lib/python3.10/site-packages/zarr/core.py", line 2308, in _chunk_setitem_nosync
    cdata = self._process_for_setitem(ckey, chunk_selection, value, fields=fields)
  File "/home/matt/bin/micromamba/envs/ngff-zarr/lib/python3.10/site-packages/zarr/core.py", line 2374, in _process_for_setitem
    chunk[chunk_selection] = value                                                                                                              
  File "cupy/_core/core.pyx", line 1475, in cupy._core.core._ndarray_base.__array__
TypeError: Implicit conversion to a NumPy array is not allowed. Please use `.get()` to construct a NumPy array explicitly.

Is there an elegant way to address this?

  1. I took the install commands from the cucim docs. Is this current best practice and will there simplifications in the future?

  2. Can we easily also add kvikio support when reading / writing?

docs/methods.md Outdated
# Install dependencies for cucim (assuming that CUDA 11.x is used for CuPy)
pip install scipy scikit-image cupy-cuda11x
# or via conda / mamba / micromamba
conda create -n cucim -c rapidsai -c conda-forge cucim cudatoolkit=<CUDA version>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cudatoolkit= -> cuda-version=<CUDA VERSION>

per @jakirkham 's recommendation.

@thewtex thewtex changed the title WIP: DOC: Document CUDA acceleration DOC: Document CUDA acceleration Feb 26, 2024
@thewtex thewtex marked this pull request as ready for review February 26, 2024 05:34
@thewtex
Copy link
Owner Author

thewtex commented Feb 26, 2024

Thanks for the pointers, @jakirkham! Now working with cucim + blosc and cucim + kvikio 🎇

In the kvikio zarr notebook, it mentions:

Some algorithms, such as LZ4, can be used interchangeably on CPU and GPU but Zarr will always use the compressor used to write the Zarr file. We are working with the Zarr team to fix this shortcoming but for now, we will use a workaround where we patch the metadata manually.

Do you know if there is an issue, etc. to track progress on this?

Support generating multiscales with itkwasm-downsample-cucim. In this
case the array data is a cupy array.

If using a kvikio store, write the cupy array directly. If using blosc
and zarr-python, convert to a numpy array before writing.
@thewtex
Copy link
Owner Author

thewtex commented Feb 26, 2024

In the kvikio zarr notebook, it mentions:

Some algorithms, such as LZ4, can be used interchangeably on CPU and GPU but Zarr will always use the compressor used to write the Zarr file. We are working with the Zarr team to fix this shortcoming but for now, we will use a workaround where we patch the metadata manually.

Do you know if there is an issue, etc. to track progress on this?

@madsbk @ivirshup I now see the discussion here: rapidsai/kvikio#261

I think it's important to show if data can be read both direct to GPU by this library, and in an environment without the NVIDIA libraries or a GPU.

@ivirshup yes! This is an effort to progress towards this goal -- something that works anywhere, and, if you have the NVIDIA libraries and a GPU, you can get an accelerated version.

I see a link to zarr-developers/numcodecs#316 . Is that where harmonious blosc / kvikio zarr .zarray metadata is being discussed? Or is there something else? CC @joshmoore

@thewtex
Copy link
Owner Author

thewtex commented Mar 4, 2024

Do you know if there is an issue, etc. to track progress on this?

Tracking this now in this repository in #70

@thewtex thewtex merged commit c99e033 into main Mar 4, 2024
26 checks passed
@thewtex thewtex deleted the cucim branch March 4, 2024 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant