cupy_array[:] = numpy_array does not work
See original GitHub issueIt would be nice if __setitem__
worked with Numpy arrays as right-hand side. Currently one gets the error
Traceback (most recent call last):
File "cupy/core/core.pyx", line 1575, in cupy.core.core.ndarray.__setitem__
File "cupy/core/core.pyx", line 3043, in cupy.core.core._scatter_op
File "cupy/core/core.pyx", line 442, in cupy.core.core.ndarray.fill
ValueError: non-scalar numpy.ndarray cannot be used for fill
A straightforward implementation could first cast to a cupy array and then do the usual setitem. An optimization for same dtype and size (assuming contiguous memory) would be to just use cudaMemcpy
cupy_array.data.copy_from_host
, but that may not be very relevant.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Basics of CuPy — CuPy 11.4.0 documentation
The cupy.asnumpy() method returns a NumPy array (array on the host), whereas cupy.asarray() method returns a CuPy array ...
Read more >cuPy error : Implicit conversion to a host NumPy array via ...
Converting a cuDF series into a CuPy array with cupy.asarray(series) requires CuPy-compatible data types. You may want to double check your ...
Read more >Standard array subclasses — NumPy v1.23 Manual
Subclassing a numpy.ndarray is possible but if your goal is to create an array with modified behavior, as do dask arrays for distributed...
Read more >Using your GPU with CuPy - The Carpentries Incubator
CuPy is a GPU array library that implements a subset of the NumPy and SciPy interfaces. This makes it a very convenient tool...
Read more >Python CuPy - GeeksforGeeks
It is an implementation of a NumPy-compatible multi-dimensional array on CUDA. CuPy consists of cupy.ndarray, the core multi-dimensional ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@orodbhen Try setting the env var
CUPY_EXPERIMENTAL_SLICE_COPY=1
.There’s at least
cupy.asarray()
that can take a numpy array.