Angad Sandhu
Search
Browse
On this page

5.1_Cupy_Lab

Cupy Lab

It's your turn again.

In this lab we will work through some fundamental cupy operations.

Before you begin, please turn off Google Colab's autocompletion by going to the settings gear in the top right -> Editor -> Uncheck "Automatically trigger code completions"

import cupy as cp

1. Create the input data array with the numbers 1 to 500_000_000.

arr = ...
arr

2. Calculate how large the array is in GB with nbytes Hint: GB is 1e9

arr...

3. How many dimensions does the array have?

arr...

4. How many elements does the array have?

arr...

5. What is the shape of the array?

arr...

6. Create a new array with 5_000_000 elements representing the linear space of 0 to 1000.

arr = ...
arr

7. Create a random array that is 10_000 by 5_000.

arr = ...
arr

8. Sort that array.

arr = ...
arr

Extra Credit 9. Reshape the array to have one dimension of length 5

arr = ...
arr

Browse the library