Advertisement
Guest User

Untitled

a guest
May 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {
  7. "collapsed": false
  8. },
  9. "outputs": [
  10. {
  11. "data": {
  12. "text/plain": [
  13. "<Executor: scheduler=localhost:8786 workers=80 threads=80>"
  14. ]
  15. },
  16. "execution_count": 1,
  17. "metadata": {},
  18. "output_type": "execute_result"
  19. }
  20. ],
  21. "source": [
  22. "from distributed import Executor, progress, wait\n",
  23. "e = Executor('localhost:8786')\n",
  24. "e"
  25. ]
  26. },
  27. {
  28. "cell_type": "code",
  29. "execution_count": 2,
  30. "metadata": {
  31. "collapsed": false
  32. },
  33. "outputs": [],
  34. "source": [
  35. "import dask.array as da\n",
  36. "x = da.random.randint(0, 2000, size=(10240, 1024000), \n",
  37. " chunks=(40, 1024000)).astype('u2')\n"
  38. ]
  39. },
  40. {
  41. "cell_type": "code",
  42. "execution_count": 3,
  43. "metadata": {
  44. "collapsed": false
  45. },
  46. "outputs": [
  47. {
  48. "name": "stderr",
  49. "output_type": "stream",
  50. "text": [
  51. "/opt/anaconda/lib/python3.5/site-packages/dask/imperative.py:5: UserWarning: dask.imperative has been moved to dask.delayed\n",
  52. " warn(\"dask.imperative has been moved to dask.delayed\")\n"
  53. ]
  54. },
  55. {
  56. "name": "stdout",
  57. "output_type": "stream",
  58. "text": [
  59. "CPU times: user 202 ms, sys: 166 µs, total: 202 ms\n",
  60. "Wall time: 2.84 s\n"
  61. ]
  62. }
  63. ],
  64. "source": [
  65. "%%time\n",
  66. "x = e.persist(x)\n",
  67. "wait(x)"
  68. ]
  69. },
  70. {
  71. "cell_type": "code",
  72. "execution_count": 4,
  73. "metadata": {
  74. "collapsed": false
  75. },
  76. "outputs": [
  77. {
  78. "name": "stdout",
  79. "output_type": "stream",
  80. "text": [
  81. "CPU times: user 75.8 ms, sys: 3.98 ms, total: 79.8 ms\n",
  82. "Wall time: 78.8 ms\n"
  83. ]
  84. }
  85. ],
  86. "source": [
  87. "%%time\n",
  88. "y = (x.rechunk((80, 512000))\n",
  89. " .rechunk((160, 256000))\n",
  90. " .rechunk((320, 128000))\n",
  91. " .rechunk((640, 64000))\n",
  92. " .rechunk((1280, 32000))\n",
  93. " .rechunk((2560, 16000))\n",
  94. " .rechunk((5120, 8000))\n",
  95. " .rechunk((10240, 4000)))\n",
  96. "z = y.sum()"
  97. ]
  98. },
  99. {
  100. "cell_type": "code",
  101. "execution_count": 5,
  102. "metadata": {
  103. "collapsed": false
  104. },
  105. "outputs": [
  106. {
  107. "name": "stdout",
  108. "output_type": "stream",
  109. "text": [
  110. "CPU times: user 528 ms, sys: 28.6 ms, total: 556 ms\n",
  111. "Wall time: 1min 35s\n"
  112. ]
  113. },
  114. {
  115. "data": {
  116. "text/plain": [
  117. "[10480510468080]"
  118. ]
  119. },
  120. "execution_count": 5,
  121. "metadata": {},
  122. "output_type": "execute_result"
  123. }
  124. ],
  125. "source": [
  126. "%%time\n",
  127. "e.get(z.dask, z._keys())"
  128. ]
  129. },
  130. {
  131. "cell_type": "code",
  132. "execution_count": null,
  133. "metadata": {
  134. "collapsed": true
  135. },
  136. "outputs": [],
  137. "source": []
  138. }
  139. ],
  140. "metadata": {
  141. "kernelspec": {
  142. "display_name": "Python 3",
  143. "language": "python",
  144. "name": "python3"
  145. },
  146. "language_info": {
  147. "codemirror_mode": {
  148. "name": "ipython",
  149. "version": 3
  150. },
  151. "file_extension": ".py",
  152. "mimetype": "text/x-python",
  153. "name": "python",
  154. "nbconvert_exporter": "python",
  155. "pygments_lexer": "ipython3",
  156. "version": "3.5.1"
  157. }
  158. },
  159. "nbformat": 4,
  160. "nbformat_minor": 0
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement