{ "cells": [ { "cell_type": "markdown", "id": "d2e341ff-0c1e-40e8-8c33-9e3039de8013", "metadata": {}, "source": [ "# Cupy Lab\n", "\n", "It's your turn again.\n", "\n", "In this lab we will work through some fundamental `cupy` operations." ] }, { "cell_type": "code", "execution_count": null, "id": "cc4596d8-d9ff-4c66-8822-246c0fc830c7", "metadata": {}, "outputs": [], "source": [ "import cupy as cp" ] }, { "cell_type": "markdown", "id": "7535d7ab-1dd8-407a-bd30-7422e8391fc7", "metadata": {}, "source": [ "**1. Create the input data array with the numbers `1` to `500_000_000`.** " ] }, { "cell_type": "code", "execution_count": null, "id": "5f1a613f-bc87-4950-b195-a66bb5bc05d3", "metadata": {}, "outputs": [], "source": [ "arr = ...\n", "arr" ] }, { "cell_type": "markdown", "id": "9b2a320b-b202-4d62-88de-981130756987", "metadata": {}, "source": [ "**2. Calculate how large the array is in GB with `nbytes`** _Hint: GB is `1e9`_" ] }, { "cell_type": "code", "execution_count": null, "id": "50530f2c-29bf-4061-8f84-bc5be00a5622", "metadata": {}, "outputs": [], "source": [ "arr..." ] }, { "cell_type": "markdown", "id": "8dfdc34c-f616-491f-a0c6-8add195412f8", "metadata": {}, "source": [ "**3. How many dimensions does the array have?**" ] }, { "cell_type": "code", "execution_count": null, "id": "ffc15dad-e2fd-4b96-8b39-3496519d0656", "metadata": {}, "outputs": [], "source": [ "arr..." ] }, { "cell_type": "markdown", "id": "ee24ecbe-2b39-43ea-9319-cdfa08f52fb1", "metadata": {}, "source": [ "**4. How many elements does the array have?**" ] }, { "cell_type": "code", "execution_count": null, "id": "b15cdf25-eb35-4926-b306-90ffd62b3d28", "metadata": {}, "outputs": [], "source": [ "arr..." ] }, { "cell_type": "markdown", "id": "c6cb7de1-20ef-4edf-a4b1-3abe40e83ab8", "metadata": {}, "source": [ "**5. What is the shape of the array?**" ] }, { "cell_type": "code", "execution_count": null, "id": "63887722-c9d7-405e-a019-e75646115541", "metadata": {}, "outputs": [], "source": [ "arr..." ] }, { "cell_type": "markdown", "id": "35f4e58d-9cbe-4e71-8b65-42f9460531e3", "metadata": {}, "source": [ "**6. Create a new array with `5_000_000` elements representing the linear space of `0` to `1000`.**" ] }, { "cell_type": "code", "execution_count": null, "id": "1527b4f6-5d75-47d4-97e0-d0e78bbc59f9", "metadata": {}, "outputs": [], "source": [ "arr = ...\n", "arr" ] }, { "cell_type": "markdown", "id": "1e0b80a2-4bb0-40a0-82e6-366a47f26b43", "metadata": {}, "source": [ "**7. Create a random array that is `10_000` by `5_000`.**" ] }, { "cell_type": "code", "execution_count": null, "id": "2f51aa2e-b994-4a91-aed6-4a4632eb7050", "metadata": {}, "outputs": [], "source": [ "arr = ...\n", "arr" ] }, { "cell_type": "markdown", "id": "f8ab4e20-cc42-4335-8a8a-bb695631185a", "metadata": {}, "source": [ "**8. Sort that array.**" ] }, { "cell_type": "code", "execution_count": null, "id": "4ec06270-6e08-4cce-9385-9dc8b53e95fd", "metadata": {}, "outputs": [], "source": [ "arr = ...\n", "arr" ] }, { "cell_type": "markdown", "id": "dc675e4c-66e6-4a9e-8f68-96802c7f96ad", "metadata": {}, "source": [ "**Extra Credit 9. Reshape the array to have one dimension of length `5`**" ] }, { "cell_type": "code", "execution_count": null, "id": "cdde560b-5ba6-484c-a601-00b7ef71273d", "metadata": {}, "outputs": [], "source": [ "arr = ...\n", "arr" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }