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
11
votes
2 answers

Is it possible to install cupy on google colab?

I am trying to run chainer with GPU on google colab. This requires cupy installed however I fail to install this properly as it cannot find the cuda environment in my colab vm. Error message as follows... Collecting cupy Downloading…
jusjosgra
  • 375
  • 2
  • 4
  • 14
10
votes
1 answer

Asynchronous GPU memory transfer with cupy

Is it possible to asynchronously transfer memory from/to GPU with cupy (or chainer)? I'm training a relatively small network with very large data that does not fit into the GPU memory. This data should be kept on CPU memory and provided to GPU for…
Keisuke FUJII
  • 1,306
  • 9
  • 13
7
votes
1 answer

Extended example to understand CUDA, Numba, Cupy, etc

Mostly all examples of Numba, CuPy and etc available online are simple array additions, showing the speedup from going to cpu singles core/thread to a gpu. And commands documentations mostly lack good examples. This post is intended to provide a…
rod_CAE
  • 81
  • 5
6
votes
2 answers

No module named 'cupy' on Google Colab

I'm working on the FastPhotoStyle project: https://github.com/NVIDIA/FastPhotoStyle and I follow the steps of its tutorial: https://github.com/NVIDIA/FastPhotoStyle/blob/master/TUTORIAL.md I'm running Example 1 on Google Colab where default…
Amber Ji
  • 63
  • 1
  • 1
  • 3
6
votes
1 answer

How to fully release GPU memory used in function

I'm using cupy in a function that receives a numpy array, shoves it on the GPU, does some operations on it and returns a cp.asnumpy copy of it. The problem: The memory is not freed after the function (as seen in ndidia-smi). I know about the…
clemisch
  • 967
  • 8
  • 18
5
votes
1 answer

Difference between cupy.asnumpy() and get()

Given a CuPy array a, there are two ways to get a numpy array from it: a.get() and cupy.asnumpy(a). Is there any practical difference between them? import cupy as cp a = cp.random.randint(10, size=(4,5,6,7)) b = a.get() c = cp.asnumpy(a) assert…
Adam Selker
  • 146
  • 2
  • 10
5
votes
1 answer

How to run python on GPU with CuPy?

I'm trying to execute Python code on GPU using CuPy library. However, when I run nvidia-smi, no GPU processes are found. Here's the code: import numpy as np import cupy as cp from scipy.stats import rankdata def…
pairon
  • 427
  • 1
  • 7
  • 18
5
votes
0 answers

CuPy Concurrency

I'm using CuPy (7.0.0) and try to get concurrent streams with a simple example script: import cupy as cp # creating streams map_streams = [] for i in range(0, 100): map_streams.append(cp.cuda.stream.Stream(non_blocking=True)) asize = (1000,…
5
votes
1 answer

How to use CUDA pinned "zero-copy" memory for a memory mapped file?

Objective/Problem In Python, I am looking for a fast way to read/write data from a memory mapped file to a GPU. In a previous SO overflow post [ Cupy OutOfMemoryError when trying to cupy.load larger dimension .npy files in memory map mode, but…
SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
5
votes
2 answers

Cupy get error in multithread.pool if GPU already used

I tried to use cupy in two parts of my program, one of them being parallelized with a pool. I managed to reproduce it with a simple example: import cupy import numpy as np from multiprocessing import pool def f(x): return…
4
votes
2 answers

What is the best way to write a module that uses CuPy if available, and falls back to Numpy/Scipy otherwise?

I'm writing a module that will use CuPy (an implementation of the Numpy and Scipy APIs using CUDA) for fast analysis of data my workplace works with, but I want the functions to be usable on computers that don't have access to CuPy. I was considered…
Colin
  • 10,447
  • 11
  • 46
  • 54
4
votes
3 answers

Is there any way to boost matrix multiplication using multiple GPUs?

I want to multiply two huge matrices, size is more than 100,000 rows and columns. I run the task on a server that has several GPUs, let's say 8 RTX 3090 GPUs, their ram size is 24GB, apparently, the matrix cannot fit in it, so I cannot use…
吴慈霆
  • 523
  • 2
  • 15
4
votes
0 answers

CUDA path not detected. Set CUDA_PATH environment variable if CuPy fails to load

C:\Users\jkim4\Anaconda3\lib\site-packages\cupy\_environment.py:213: UserWarning: CUDA path could not be detected. Set CUDA_PATH environment variable if CuPy fails to load. warnings.warn( Traceback (most recent call last): File…
ju won kim
  • 41
  • 1
  • 1
  • 2
4
votes
1 answer

TypeError: Implicit conversion to a NumPy array is not allowed. Please use `.get()` to construct a NumPy array explicitly. - CuPy

I would like to use the numpy function np.float32(im) with CuPy library in my code. im = cupy.float32(im) but when I run the code I'm facing this error: TypeError: Implicit conversion to a NumPy array is not allowed. Please use `.get()` to…
Francesco Laiti
  • 1,791
  • 2
  • 13
  • 19
4
votes
1 answer

ValueError: non-scalar numpy.ndarray cannot be used for fill - CuPy

When I try to use the library CuPy with osgeo, I'm facing this error: ValueError: non-scalar numpy.ndarray cannot be used for fill I'm trying to fill this array: im = cupy.zeros([ds.RasterYSize, ds.RasterXSize, ds.RasterCount], dtype=np.float32) …
Francesco Laiti
  • 1,791
  • 2
  • 13
  • 19
1
2 3
22 23