Questions tagged [cupy]

CuPy is an implementation of NumPy-compatible multi-dimensional array on CUDA.

About CuPy

From the CuPy homepage:

High Performance with CUDA

CuPy is an open-source matrix library accelerated with NVIDIA CUDA. It also uses CUDA-related libraries including cuBLAS, cuDNN, cuRand, cuSolver, cuSPARSE, cuFFT and NCCL to make full use of the GPU architecture.

Highly Compatible with NumPy

CuPy's interface is highly compatible with ; in most cases it can be used as a drop-in replacement. All you need to do is just replace numpy with cupy in your Python code. It supports various methods, indexing, data types, broadcasting and more.

CuPy consists of the core multi-dimensional array class, cupy.ndarray, and many functions on it. It supports a subset of numpy.ndarray interface.

Resources

339 questions
1
vote
0 answers

cupy.cuda.memory.OutOfMemoryError: Out of memory allocating 80,384 bytes (allocated so far: 0 bytes)

When I tried to perform a matrix multiplication using a 10000x10000 matrix placed on GPU 1 with CuPy, I received an OutOfMemoryError. So I tried performing the same operation using a 100x100 matrix placed on GPU 1, but I encountered the same error.:…
zsfyyds
  • 11
  • 1
1
vote
1 answer

cupyx.scipy.spatial cdist "RuntimeError: pylibraft is not installed"

I have been trying to transfer the scipy function cdist over to the gpu using cupy. from cupyx.scipy.spatial import distance as cudist import cupy as cu a = cu.array([1,2]) b = cu.array([3,4]) c = cudist.cdist(a, b, metric="euclidean") I get…
raceee
  • 477
  • 5
  • 14
1
vote
0 answers

Cupy DLL load failed

I am trying to use cupy to speed up some background numpy operations in my python code but when attempting to import cupy I am told that the DLL load failed, importError: DLL load failed. I am fairly inexperienced when it comes to handling things…
Tim
  • 15
  • 4
1
vote
1 answer

CuPy parallel searchsorted

The current searchsorted works perfect with 1-d arrays: import cupy as cp ref = cp.arange(5, dtype=cp.float32) secs = cp.arange(10, dtype=cp.float32) cp.searchsorted(ref,secs) the result is: array([0, 1, 2, 3, 4, 5, 5, 5, 5, 5]) I want a function…
Kang Liang
  • 63
  • 6
1
vote
1 answer

Assigned a complex value in cupy RawKernel

I am a beginner learning how to exploit GPU for parallel computation using python and cupy. I would like to implement my code to simulate some problems in physics and require to use complex number, but don't know how to manage it. Although there are…
OhnTzu
  • 23
  • 5
1
vote
0 answers

Cupy to speed up 4D plot with Matplotlib

I recently started looking at matplotlib to do some data visualization and understand better how some stats work in a game. This lead me to learn how to make 3D and then 4D visualization using matplotlib, but I quickly realized that the calculation…
firestorck
  • 31
  • 4
1
vote
0 answers

How to speed up SVD computation

I need to perform SVD (singular value decomposition) on a multi-dimensional matrix. The matrix can have the shape like [31329, 128, 36]. If you look up cupy.linalg.svd, you will find that SVD needs to be broadcasted to all 31329 2D-matrices of the…
ztan
  • 31
  • 1
  • 2
1
vote
1 answer

DASK GPU running out of memory with unified allocator

I asked a somewhat similar question the other day. I have tried pinging the DASK slack forum, and their discourse forum but to no avail. I am currently trying to create a large memory on the CPU, move chunks of data to the GPU to perform…
JOKKINATOR
  • 356
  • 1
  • 11
1
vote
0 answers

CuPy equivalent of numpy.memmap

I have a large (several terabytes) file on disk that represents a matrix of 64-bit floating point numbers. I have a Python script that performs linear algebra operations on a subset of the rows of this matrix. When using NumPy, I use numpy.memmap to…
galpo
  • 183
  • 1
  • 7
1
vote
0 answers

Using CuPy/cuDF, remove elements that are not distant enough to their previous elements from a sorted list

The purpose of the code is similar to this post I have a code that runs on CPUs: import pandas as pd def remove(s: pd.Series, thres:int): pivot = -float("inf") new_s = [] for e in s: if (e-pivot)>thres: …
dacapo1142
  • 59
  • 5
1
vote
0 answers

cupy/numpy ignores duplicate indexes

When we uses arrays as indexes cupy/numpy ignores duplicates. Example: import cupy as cp matrix = cp.zeros((3, 3)) xi = cp.asarray([0, 1, 1, 2]) yi = cp.asarray([0, 1, 1, 2]) matrix[xi, yi] += 1 print(matrix.get()) Output: [[1. 0. 0.] [0. 1. 0.] …
1
vote
0 answers

How to do indexing with ndarray to mask index in numpy?

I have a 4d array to mask and a 2d array to mask index. i should masking ndarray data using 2d array indices and i dont want to using for-loop. how should i do? for example, mask_arr = np.random.rand(5,10,100) idx_arr = np.random.randint(10,…
Young
  • 19
  • 3
1
vote
1 answer

Jupyter notebook : Import error: DLL load failed (but works on .py) without Anaconda

I was trying to use CuPy inside a Jupyter Notebook on Windows10 and got this error : ---> from cupy_backends.cuda.libs import nvrtc ImportError: DLL load failed while importing nvrtc: The specified procedure could not be found. This is triggered by…
ImARandom
  • 31
  • 3
1
vote
1 answer

How to use cupy with tensorrt?

Edit: I solve it, code in the answer. I meet a problem: using numpy and opencv to preprocess data is slower than torchvision and results in the whole process based on tensorrt is slower than pytorch. So I try to use opencv-cuda and cupy to…
ning
  • 11
  • 2
1
vote
1 answer

Cupy sparse matrix does not correspond to its Scipy equivalence?

I digged the documentation for cupy sparse matrix. as in scipy I expect to have something like this: from scipy.sparse import csr_matrix A_csr = csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]) but in cupy here: To convert CuPy ndarray to CuPy sparse…
Abolfazl
  • 1,047
  • 2
  • 12
  • 29