Beginning first with CuPy, we will apply the implementations that we learned about CuPy so far, with our first CuPy program. Note that it does not use NumPy to generate the random number as well. In fact, it's a pure CuPy program. The NumPy module is not imported at all.
- First, open a new file on PyCharm, as shown here in the screenshot:
- Now use the following code that simply replaces NumPy syntax with CuPy. This is a regular and basic format in CuPy that looks exactly like NumPy, apart from the importing of the latter module:
import cupy as cp #Importing CuPy
from timeit import default_timer as timer #To record computation time
N = 500000000 #500 million elements
# Starting timer to record GPU computation time
start = timer()
# Setting two arrays all with zero values
a_cp = cp.zeros...