Skip to content

Experiment with CuPy GPU arrays #3007

Closed

Description

@mrocklin

Dask contains parallel algorithms for parallel arrays based on the numpy syntax. While commonly used with numpy arrays they also work with other libraries that mimic subsets of the numpy ndarray API.

The CuPy library implements a NumPy API compatible GPU ndarray. It would be interesting to see how these two libraries interact, where performance bottlenecks are, and under what conditions they may be effectively used together.

To experiment with this one would want to do a few things:

  1. Register cupy operations for concatenate and tensordot. Examples doing this for the sparse library are at the top of dask/array/core.py
  2. Create a GPU array using da.from_array, or da.from_delayed and da.concatenate/stack. See http://dask.pydata.org/en/latest/array-creation.html
  3. If you want to use distributed computing then ensure that cupy ndarrays can be efficiently serialized, probably by implementing __setstate__ and __getstate__ methods for them if they don't already exist.

This should be sufficient to get something up and running.

Activity

  1. jakirkham commented on Dec 17, 2017

    @jakirkham
    Member

    May be worth looking at libgpuarray/pygpu as well.

  2. mrocklin commented on Dec 17, 2017

    @mrocklin
    MemberAuthor

    Sure, assuming that it matches a decent subset of the the np.ndarray API. I suspect that there are other options out there as well.

  3. sjperkins commented on Dec 18, 2017

    @sjperkins
    Member

    This would be a great addition!

    I would guess that scheduling of asynchronous:

    1. array transfers both on and off the GPU.
    2. GPU kernels.

    in the presence of limited GPU memory is going to the challenge.

  4. rzu512 commented on Dec 20, 2017

    @rzu512

    How about theano?

  5. jakirkham commented on Jan 9, 2018

    @jakirkham
    Member

    theano at least in the latest version uses libgpuarray/pygpu.

  6. jakirkham commented on Jan 21, 2018

    @jakirkham
    Member

    Should have mentioned Bohrium before. There are some similarities between it and Dask in that it lazy evaluates things and provides a NumPy-like interface.

    That said, Bohrium is focused on computations on a single CPU or GPU and makes use of OpenCL to do so. Also it compiles things as it is run much like Theano.

    I think there is a really interesting possibility of using Dask Distributed to construct graphs that contain functions with Bohrium. Then fuse many of these operations down to tasks. Finally submitting them to workers where they are built and run. Thus allowing one to create high performance operations distributed on nodes with ease on larger than memory data.

  7. jakirkham commented on Mar 27, 2018

    @jakirkham
    Member

    Probably should add numba here too.

    Edit: Though this is a different sort of strategy than wrapping a NumPy API-compatible GPU Array class.

  8. jakirkham commented on Mar 27, 2018

    @jakirkham
    Member

    Has anyone been actively exploring this space? Would be interested to know what sort of things have been tried/learned. :)

  9. hmaarrfk commented on Jul 4, 2018

    @hmaarrfk
    Contributor

    How badly does cupy perform if you use the delayed interface?

  10. mrocklin commented on Jul 4, 2018

    @mrocklin
    MemberAuthor
  11. hmaarrfk commented on Jul 4, 2018

    @hmaarrfk
    Contributor

    I don't think it would ;). I guess the only thing to worry about it resource contention for the GPU(s), though, I guess that is always something to worry about.

  12. mrocklin commented on Jul 4, 2018

    @mrocklin
    MemberAuthor
  13. pmoulik commented on Jul 20, 2018

    @pmoulik

    As a new user of dask, I have a naive question on how to manage GPU's on a multi-node multi-GPU cluster (accessed using dask-jobqueue and appropriate scheduler) from inside a python script (not from command prompt like in https://youtu.be/jLQ2wAwapRg?t=894) with or without using cupy/numba. A simple application could be a matrix-matrix multiplication. A solution is to use mpi4py with cupy GPU arrays to allocate chunks of the matrices to a particular GPU; is there a simpler or similar solution while using dask arrays?

  14. mrocklin commented on Oct 24, 2018

    @mrocklin
    MemberAuthor

    I'm going to go ahead and close this. This topic is being handled piece by piece in other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions