Questions tagged [cupy]
CuPy is an implementation of NumPy-compatible multi-dimensional array on CUDA.
338
questions
0
votes
1
answer
22
views
Using CPU memory to store GPU output
I was wondering whether it could be possible to tell cupy to store the output of some calculation (carried on the GPU) directly on the CPU memory. I am currently trying to use cupy.scipy.sparse.eigsh ...
3
votes
1
answer
59
views
Transferring a Pointer From C++ To Python Compatible with Host and Device Memory
I have a Python function (named apply_filter), whose execution may involve either the CPU (using NumPy) and GPU (using CuPy). The function takes an input-buffer object, represting a pointer to data ...
0
votes
0
answers
12
views
How to do cupyx distributed matrix multiplication
Can someone provide an example of how to do distributed sparse matrix multiplication with cupyx on an MPI cluster with 4 gpus per node. I cannot find this in the documentation. Thanks.
The below ...
0
votes
0
answers
40
views
How to bundle cupy code to .exe by using pyinstaller
I'm trying to bundle a ".py" file which contains simple cupy code to ".exe" by pyinstaller, but fail to open the ".exe" file.
Target Code:
import cupy as cp
a = cp.ones(...
0
votes
0
answers
32
views
Is cupy.einsum always synchronizing?
It seems that cupy.einsum always synchronizes. See this:
import cupy as cp
import time
N = 3000
A = cp.random.rand(N, N)
B = cp.random.rand(N, N)
print("matmul")
T1 = time.time()
for i in ...
0
votes
2
answers
43
views
Multiply 2D array by each element from 1D array to obtain a 3D array without usage of loops
We have two NumPy arrays with different shapes (n,n) and (m,):
A = [[1 2 3],
[4 5 6],
[7 8 9]]
B = [1 2 3 4]
I would like to multiply the 2D array A by each element from the 1D array B to obtain a ...
0
votes
1
answer
63
views
Using half precision with CuPy
I am trying to compile a simple CUDA kernel with CuPy using the half precision format provided by the cuda_fp16 header file.
My kernel looks like this:
code = r'''
extern "C" {
#include <...
1
vote
1
answer
113
views
Looking for fast binary convolution on GPU
I have a large and small 2d numpy boolean array. I want to know all positions where this smaller array fits on the larger array. If for a specific location no element of the smaller and (sliced) ...
1
vote
0
answers
80
views
"Cupyx.scipy.sparse" problem: "cupy_backends.cuda.api.driver.CUDADriverError:an illegal memory access was encountered"
Take summary, we try to do human segmentation on a social media video using an unsupervised deep CNN. The processing extract each video frame (using OpenCV). The video frame is segmented by a CNN to ...
0
votes
2
answers
38
views
How to apply the pseudo-inverse of a matrix to N arrays with Cupy?
I want to apply the cupy.linalg.pinv function to 100k arrays, but I see a drop in performance compared to the Numpy equivalent.
My 100k arrays are two dimensions arrays. The main array shape is: (...
0
votes
0
answers
286
views
CuPy not picking the CUDA_PATH
I have CUDA Toolkit installed using the Nvidia installer but for whatever reason CuPy points to the wrong path. I installed cupy-cuda11x using pip on a conda environment.
(py39) E:\>python
...
0
votes
0
answers
31
views
Why different Random Walks with Restart have different results?
I've written two programs to conduct RWR.
One uses a networkx graph and I conduct the run on the transition probability matrix:
import numpy as np
import networkx as nx
def run_rwr(nxgraph, a, steps)...
0
votes
0
answers
105
views
How to use Stream in cupy to achieve parallel computation in code?
I want to use CUDA streams to speed up computation on the GPU. The following code achieves signal processing by repeatedly running a segment of code. I hope that the code can perform parallel ...
1
vote
0
answers
71
views
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 ...
0
votes
0
answers
217
views
Installing CUPY and Pytorch
First of all, my system is Windows server 2016 and I have 3 CUDATOOLKIT installed with version=10.1, 11.8 and 12.1. I first installed Pytorch with CUDATOOLKIT=11.8 and it worked. Then when I tried ...
0
votes
0
answers
61
views
How to draw many circles in pygame using shaders?
I am relatively new to shaders and I was wondering how to draw many objects at once.
Here's the scenario: I am using Cupy to hold an array of circles with attributes of: x and y position and x and y ...
1
vote
1
answer
147
views
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 = ...
0
votes
0
answers
60
views
How do you correctly use Cupy's GPU accelerated library in python?
I am a complete beginner to parallel programming and would like to get into it. I've started using Cupy in a new python script I've been working on.
The task is to have many, many circles with 4 ...
0
votes
0
answers
27
views
cupy: Excessive memory usage with boolean indexing?
The current behavior:
import cupy as cp
big = cp.zeros( (4_000, 4_000, 120), dtype=cp.float32) # ~ 7.6 GiB
idx = cp.ones( (4_000, 4_000), dtype=cp.bool_) # ~ 16 MiB
b2 = big[idx] # ~ 24 GiB
System:...
0
votes
1
answer
194
views
How to write and read images using GPU accelerated code in python?
I am a nuby to GPU coding. How to write and read images using GPU accelerated code in python? I have tried cupyimg, but the error says no such module named cupyimg. I tried cupyimg.scipy.misc etc. too....
0
votes
0
answers
29
views
Is there a way to share a CuPy array between two python processes?
is there a way to share the same CuPy array between two Python processes without replicating it?
For NumPy, there is the multiprocessing.shared_memory mechanism. Is there a similar mechanism for CuPy?...
0
votes
0
answers
61
views
How to process multiple images at the same time with "cupyx.scipy.ndimage.map_coordinates"
I need to sample from multiple images by a fixed, pre-computed set of coordinates with in python high performance. Currently, these images are loaded into a cupy array of dimension [channel,height,...
2
votes
1
answer
415
views
How do I force cupy to free all gpu memory after going out of scope?
I have a memory intensive gpu-based (CUDA C++ linked with cython) model to execute that has a substantial preprocessing step before running. Until now, the preprocessing step has been done on the cpu, ...
0
votes
0
answers
38
views
Improving performance of loading data to GPU
Approach 1 (scipy sparse matrix -> numpy array -> cupy array; approx 20 minutes per epoch)
I have written neural network from scratch (no pytorch or tensorflow) and since numpy does not run ...
0
votes
0
answers
29
views
Cupy compiler error when summing over singleton axis
My code includes a line where I sum over the first dimension of an array. This works fine if I use an array with non-singleton dimension, for example:
test = cp.ones((2, 3, 4))
test1 = cp.sum(test, ...
0
votes
0
answers
48
views
How to get address of a cupy array?
Is there a way to get the memory address of cupy arrays? similar to pytorch and numpy tensors/arrays, we can get the address of the first element and compare them:
For pytorch:
import torch
x = torch....
0
votes
1
answer
170
views
Cupy is slower than numpy at emulating dot product with one hot vector
I was trying to implement neural network from scratch. However it is not possible to run numpy on GPU. So I tried using cupy and benchmarking performance improvement over numpy.
I have following code ...
0
votes
1
answer
122
views
Creating a function for 3D mean using cupy and reduction kernel to apply to cupy's generic filter
I am trying to use cupy to speed up processing for the scipy generic_filter function. I want the cupy generic_filter function to take a kernel function which calculates the mean of a 3D array. However,...
0
votes
1
answer
55
views
TypeError python cupy
I'm trying to use cupy to speed up numerical integration. But I ran into the following problem, which is illustrated by the code below. Let the function for integration be given by its values in ...
0
votes
1
answer
169
views
Cupy Code Optimization: How to speed up nested for loops
I would like to optimize the python code between the 2 perf_counter functions.
By using cupy I already obtained substantial improvement compared to numpy.
I was asking myself if there is some ...
0
votes
0
answers
23
views
Why is VmLck and VmPin in `/proc/<PID>/status` not correct?
When I use a = torch.tensor([100,1000,1000], pin_memory=True) or b = cupyx.zeros_pinned([100,1000,1000]), the result of cat /proc/<PID>/status | grep Vm is as follows:
Why are VmLck and VmPin ...
0
votes
0
answers
110
views
Cupy API and elementwise kernel for faster neural network
I know I can easily rewrite numpy dot product in cupy dot product by using corresponding API:
import numpy as np
import cupy as cp
arr1 = np.array([[1, 2], [3, 4]])
arr2 = np.array([[5, 6], [7, 8]])
...
0
votes
0
answers
124
views
Parallelizing for Loops for parameter study in python
I am currently working on parallelizing large parameter studies of a system of equations with only 2 coupled ODE. A trivial "for loop parallelization" using the CPU resulted in a runtime of ...
0
votes
0
answers
160
views
Random sampling with numpy works but cupy gives "Unsupported dtype <U20"
I am trying translate my negative sampling code in numpy to cupy.
First I have following import in my jupyter notebook:
import cupy as cp
I have a list of strings my jupyter notebook:
In: l = ['...
0
votes
0
answers
81
views
Does cupy have a function that works the same as pandas groupby?
I have an array where the first column is an identifier and the next 5 columns are data. I would like to de-mean the data, within each column, grouped by the identifier. I could move the cupy array ...
0
votes
2
answers
83
views
How to use cupy.lib.stride_tricks.as_strided(x, shape=None, strides=None)
I was using:
np.lib.stride_tricks.sliding_window_view
with a 1D-array and two parameters (the array and the length of the subset n) to slice it into slices of n elements (n < 1D-array.shape, of ...
0
votes
0
answers
62
views
Installation of CuPy on NVIDIA Drive AGX Xavier
I am trying to install CuPy on NVIDIA Drive AGX Xavier deveopment kit. Since, wheels are not available for this architecture, I am building from source using the command
CUDA_PATH="/usr/local/...
0
votes
1
answer
509
views
is there any way to install cupy without Cuda
pip install cupy won't install cupy without cuda.
Linux: lubuntu v21.10
pip v3.10
conda v22.11.1
I have linux installed on an older laptop and it doesn't have any dedicated GPU.
I have a python ...
0
votes
0
answers
108
views
ONNX runtime predictions on raw CuPy arrays?
I am following the ONNX inference tutorial at: https://github.com/onnx/models/blob/main/vision/classification/onnxrt_inference.ipynb.
Instead of doing the pre-processing in pure NumPy, I have re-...
0
votes
1
answer
73
views
cupy AttributeError: 'list' object has no attribute 'dtype'
I'm trying to use the library cupy to replace numpy on some code. I'm trying to use the roots but
I get an AttributeError: 'list' object has no attribute 'dtype'. I don't have a problem with numpy
if ...
0
votes
0
answers
81
views
Correctly converting a TF tensor to a DLpack pointer for computation
I am currently experimenting with performing some pre-processing in CuPy within a larger TensorFlow pipeline. As I understand, one can convert both a CuPy array and a Tensorflow into a DLpack capsule, ...
-1
votes
1
answer
74
views
Calculate least squares in batches
I want to calculate a Gaussian process. For this I need to calculate the following equation:
f = X @ Z^-1 @ y
To handle the inverse I use c = Z^-1 @ y which is the solution of the problem Z @ c = y. ...
-1
votes
1
answer
61
views
dtype Error while running sample Cupy on python
I am running the following test code:
import cupy as cp
import pandas as pd
arr = [{'df1': pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}),
'df2': pd.DataFrame({'C': [7, 8, 9], 'D': [10, 11, 12]})},
{'...
0
votes
0
answers
14
views
Question: Math performance with respect to dtype
It is my understanding that all operations performed on the CUDA toolkit are performed in floats. I am curious if there is any advantage/disadvantage performing math operations against large 3 ...
0
votes
1
answer
76
views
An error occurred when using the flatten() and reshape() functions of the cupy module
I originally used numpy to run my program, and then I rewritten the program to use cupy, but an error occurred when using the cupy.flatten() function
Here is the minimal example
import cupy
import ...
0
votes
1
answer
139
views
How to make numpy functions workable for cupy?
Good evening everyone! I have some following code snippets as follows.
I'm trying to convert the numpy functions to cupy, as it takes a long time to process through numpy.
But whenever I run this code,...
0
votes
0
answers
77
views
combine multiple FFT operation on GPU within python
I am using pytorch for calculating the 3d convolution using the FFT.
The current code does an FFT first, then a pointwise multiplication in Fourier space and finally an inverse FFT. The code works but ...
1
vote
0
answers
134
views
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 ...
0
votes
1
answer
264
views
Cupy config shows no cuda device
I built a docker contaiener to be deployed on HPC+GPU via singularity. when i run
cp.show_config()
OS: Linux-5.4.0-135-generic-x86_64-with-glibc2.31
Python Version: 3.9.12
CuPy Version: 9.6.0
CuPy ...
1
vote
1
answer
162
views
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,...