SHARE
TWEET

Untitled

a guest Jul 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.  "cells": [
  3.   {
  4.    "cell_type": "markdown",
  5.    "metadata": {},
  6.    "source": [
  7.     "# Cupy Numpy Comparison"
  8.    ]
  9.   },
  10.   {
  11.    "cell_type": "markdown",
  12.    "metadata": {},
  13.    "source": [
  14.     "## Numpy"
  15.    ]
  16.   },
  17.   {
  18.    "cell_type": "code",
  19.    "execution_count": 1,
  20.    "metadata": {},
  21.    "outputs": [],
  22.    "source": [
  23.     "import numpy"
  24.    ]
  25.   },
  26.   {
  27.    "cell_type": "code",
  28.    "execution_count": 2,
  29.    "metadata": {},
  30.    "outputs": [],
  31.    "source": [
  32.     "array = numpy.random.random((10000, 10000))"
  33.    ]
  34.   },
  35.   {
  36.    "cell_type": "code",
  37.    "execution_count": 3,
  38.    "metadata": {},
  39.    "outputs": [
  40.     {
  41.      "data": {
  42.       "text/plain": [
  43.        "0.8"
  44.       ]
  45.      },
  46.      "execution_count": 3,
  47.      "metadata": {},
  48.      "output_type": "execute_result"
  49.     }
  50.    ],
  51.    "source": [
  52.     "array.nbytes / 1e9"
  53.    ]
  54.   },
  55.   {
  56.    "cell_type": "code",
  57.    "execution_count": 4,
  58.    "metadata": {},
  59.    "outputs": [
  60.     {
  61.      "name": "stdout",
  62.      "output_type": "stream",
  63.      "text": [
  64.       "923 ms ± 2.59 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
  65.      ]
  66.     }
  67.    ],
  68.    "source": [
  69.     "%%timeit \n",
  70.     "numpy.fft.fft2(array)"
  71.    ]
  72.   },
  73.   {
  74.    "cell_type": "markdown",
  75.    "metadata": {},
  76.    "source": [
  77.     "## Cupy"
  78.    ]
  79.   },
  80.   {
  81.    "cell_type": "code",
  82.    "execution_count": 5,
  83.    "metadata": {},
  84.    "outputs": [],
  85.    "source": [
  86.     "import cupy"
  87.    ]
  88.   },
  89.   {
  90.    "cell_type": "code",
  91.    "execution_count": 6,
  92.    "metadata": {},
  93.    "outputs": [],
  94.    "source": [
  95.     "garray = cupy.random.random((10000, 10000))"
  96.    ]
  97.   },
  98.   {
  99.    "cell_type": "code",
  100.    "execution_count": 7,
  101.    "metadata": {},
  102.    "outputs": [
  103.     {
  104.      "data": {
  105.       "text/plain": [
  106.        "0.8"
  107.       ]
  108.      },
  109.      "execution_count": 7,
  110.      "metadata": {},
  111.      "output_type": "execute_result"
  112.     }
  113.    ],
  114.    "source": [
  115.     "garray.nbytes / 1e9"
  116.    ]
  117.   },
  118.   {
  119.    "cell_type": "code",
  120.    "execution_count": 8,
  121.    "metadata": {},
  122.    "outputs": [
  123.     {
  124.      "name": "stdout",
  125.      "output_type": "stream",
  126.      "text": [
  127.       "24.8 ms ± 109 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
  128.      ]
  129.     }
  130.    ],
  131.    "source": [
  132.     "%%timeit \n",
  133.     "cupy.fft.fft2(garray)\n",
  134.     "cupy.cuda.Device().synchronize()"
  135.    ]
  136.   }
  137.  ],
  138.  "metadata": {
  139.   "kernelspec": {
  140.    "display_name": "Python 3",
  141.    "language": "python",
  142.    "name": "python3"
  143.   },
  144.   "language_info": {
  145.    "codemirror_mode": {
  146.     "name": "ipython",
  147.     "version": 3
  148.    },
  149.    "file_extension": ".py",
  150.    "mimetype": "text/x-python",
  151.    "name": "python",
  152.    "nbconvert_exporter": "python",
  153.    "pygments_lexer": "ipython3",
  154.    "version": "3.6.8"
  155.   }
  156.  },
  157.  "nbformat": 4,
  158.  "nbformat_minor": 4
  159. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top