CuPy vs NumPy

DaurEd
1 min readJan 25, 2021

CuPy is a GPU array backend that implements a subset of NumPy interface.

Every NumPy function doesn’t have CuPy equivalent. Check out the list here. However, most frequently used NumPy functions do have a CuPy equivalent.

If you already have CUDA toolkit installed, check out these commands.

For installing CUDA toolkit, here is one blog which talks about CUDA toolkit installation.

NumPy runs on CPU and thus limiting speed. In the colab notebook, you can realize the difference in time required for same operations on CuPy and NumPy.

To get started with CuPy, following operations are tracked for the time taken and how to use the syntax:

  1. Copying one 2D array to another
  2. Broadcasting Operation
  3. Checking the shape of the 2D arrays and printing the elements
  4. Initializing the 2D arrays
  5. Transposition
  6. Changing CuPy arrays to NumPy
  7. Changing NumPy arrays back to Cupy

-Writers: Piyush Kulkarni, Apoorv Kumar

--

--

DaurEd

Our objective is to be valued leader in providing quality, affordable instruction in studies via practical training, workshops, & experimental learning.