差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
python:pyopencl [2019/08/19 07:16] – ともやん | python:pyopencl [2021/07/23 18:00] – ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
< | < | ||
- | <style> | + | <script type=" |
- | #result pre { | + | |
- | height: 200px; | + | |
- | overflow: scroll; | + | |
- | overflow-x: hidden; | + | |
- | } | + | |
- | | + | |
</ | </ | ||
+ | ~~CLOSETOC~~ | ||
====== PyOpenCL のインストール ====== | ====== PyOpenCL のインストール ====== | ||
+ | ここでは、以下の CPU および GPU を使用してベンチマークを行った。\\ | ||
+ | * AMD® GPU Radeon HD 5870 | ||
+ | * AMD® CPU Phenom™ II X6 1100T Processor | ||
+ | * Intel® GPU HD Graphics 4000 | ||
+ | * Intel® CPU Core™ i7-3517U CPU @ 1.90GHz | ||
+ | * NVIDIA® GPU GeForce GT 640M | ||
+ | * NVIDIA® Tesla® T4 | ||
+ | |||
+ | < | ||
+ | <div id=" | ||
+ | < | ||
+ | google.charts.load(' | ||
+ | packages: [' | ||
+ | }); | ||
+ | google.charts.setOnLoadCallback(drawMultSeries); | ||
+ | | ||
+ | function drawMultSeries() { | ||
+ | let data = google.visualization.arrayToDataTable([ | ||
+ | [' | ||
+ | [' | ||
+ | {v: 0.0000072220, | ||
+ | [' | ||
+ | {v: 0.0007947200, | ||
+ | [' | ||
+ | {v: 0.0010557440, | ||
+ | [' | ||
+ | {v: 0.0010633330, | ||
+ | [' | ||
+ | {v: 0.0011095000, | ||
+ | [' | ||
+ | {v: 0.0015742400, | ||
+ | ]); | ||
+ | | ||
+ | let options = { | ||
+ | title: ' | ||
+ | chartArea: { | ||
+ | width: ' | ||
+ | }, | ||
+ | width: 600, | ||
+ | height: 400, | ||
+ | is3D: true, | ||
+ | hAxis: { | ||
+ | title: '<- fast | slow ->', | ||
+ | minValue: 0, | ||
+ | scaleType: ' | ||
+ | }, | ||
+ | vAxis: { | ||
+ | title: ' | ||
+ | }, | ||
+ | explorer: { | ||
+ | actions: [' | ||
+ | axis: ' | ||
+ | keepInBounds: | ||
+ | maxZoomIn: 4.0 | ||
+ | } | ||
+ | }; | ||
+ | | ||
+ | let chart = new google.visualization.BarChart(document.getElementById(' | ||
+ | chart.draw(data, | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | 本家: [[https:// | ||
+ | OpenCL本家: | ||
+ | |||
+ | ===== OpenCL 開発環境 ===== | ||
+ | OpenCL を利用するには OS プラットフォームに関係なく、[[c_cpp: | ||
===== Windows ===== | ===== Windows ===== | ||
PyOpenCL をインストールするには、[[windows: | PyOpenCL をインストールするには、[[windows: | ||
- | \\ | + | |
+ | PyOpenCL 仮想環境の作成を行う。(任意)\\ | ||
+ | <WRAP prewrap 100% # | ||
+ | < | ||
+ | $ python -m venv py38opencl | ||
+ | $ . py38opencl\Scripts\activate | ||
+ | (py38opencl) $ python -m pip install --upgrade pip | ||
+ | Collecting pip | ||
+ | Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB) | ||
+ | | ||
+ | Installing collected packages: pip | ||
+ | Attempting uninstall: pip | ||
+ | Found existing installation: | ||
+ | Uninstalling pip-20.1.1: | ||
+ | Successfully uninstalled pip-20.1.1 | ||
+ | Successfully installed pip-20.2.3 | ||
+ | </ | ||
+ | </ | ||
pybind11、Mako をインストールする。\\ | pybind11、Mako をインストールする。\\ | ||
<WRAP prewrap 100% #result> | <WRAP prewrap 100% #result> | ||
< | < | ||
- | > pip install pybind11 | + | > pip install pybind11 |
Collecting pybind11 | Collecting pybind11 | ||
- | Downloading | + | Downloading pybind11-2.5.0-py2.py3-none-any.whl (296 kB) |
- | | + | |
- | Collecting | + | Collecting |
- | Downloading | + | Downloading Mako-1.1.3-py2.py3-none-any.whl (75 kB) |
- | | + | |
- | Collecting MarkupSafe> | + | Collecting MarkupSafe> |
- | Downloading | + | Downloading MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl |
- | Installing collected packages: pybind11, MarkupSafe, | + | Installing collected packages: pybind11, MarkupSafe, |
- | Running setup.py install for Mako ... done | + | Successfully installed |
- | Successfully installed | + | |
</ | </ | ||
</ | </ | ||
+ | |||
PyOpenCL をインストールする。\\ | PyOpenCL をインストールする。\\ | ||
< | < | ||
行 37: | 行 118: | ||
< | < | ||
Collecting pyopencl | Collecting pyopencl | ||
- | Downloading | + | Downloading pyopencl-2020.2.2.tar.gz (352 kB) |
- | | + | |
- | Collecting numpy (from pyopencl) | + | Collecting numpy |
- | | + | |
- | | + | Collecting pytools> |
- | Collecting pytools> | + | Downloading pytools-2020.4.tar.gz (67 kB) |
- | Downloading | + | |
- | | + | Collecting decorator> |
- | Collecting decorator> | + | Downloading decorator-4.4.2-py2.py3-none-any.whl |
- | Downloading | + | Collecting appdirs> |
- | Collecting appdirs> | + | Downloading appdirs-1.4.4-py2.py3-none-any.whl |
- | Downloading | + | Collecting six>=1.8.0 |
- | Collecting six>=1.9.0 (from pyopencl) | + | |
- | | + | Using legacy ' |
+ | Using legacy ' | ||
Installing collected packages: numpy, decorator, appdirs, six, pytools, pyopencl | Installing collected packages: numpy, decorator, appdirs, six, pytools, pyopencl | ||
- | | + | |
- | Running setup.py install for pyopencl ... done | + | Running setup.py install for pyopencl ... done |
- | Successfully installed appdirs-1.4.3 decorator-4.4.0 numpy-1.17.0 pyopencl-2019.1 pytools-2019.1.1 six-1.12.0 | + | Successfully installed appdirs-1.4.4 decorator-4.4.2 numpy-1.19.2 pyopencl-2020.2.2 pytools-2020.4 six-1.15.0 |
</ | </ | ||
</ | </ | ||
- | ==== OpenCL ベンチマーク ==== | + | ===== OpenCL ベンチマーク |
OpenCL のベンチマークには以下のプログラムを使用しました。\\ | OpenCL のベンチマークには以下のプログラムを使用しました。\\ | ||
https:// | https:// | ||
行 146: | 行 228: | ||
</ | </ | ||
- | === MGC 開発マシン === | + | ===== MGC 開発マシン |
- | {{:python: | + | {{python: |
**HIS Radeon HD 5870**\\ | **HIS Radeon HD 5870**\\ | ||
< | < | ||
行 156: | 行 238: | ||
Shading Units: 1400 | Shading Units: 1400 | ||
</ | </ | ||
- | {{:python: | + | {{python: |
\\ | \\ | ||
- | **AMD Phenom(tm) II X6 1100T Processor, Black Edition 3.30GHz**\\ | + | **AMD Phenom(™) II X6 1100T Processor, Black Edition 3.30GHz**\\ |
< | < | ||
TDP: 125W | TDP: 125W | ||
行 165: | 行 247: | ||
</ | </ | ||
※FLOPS は理論値(4 FLOPS/Clock × 3.3GHz × 6コア)\\ | ※FLOPS は理論値(4 FLOPS/Clock × 3.3GHz × 6コア)\\ | ||
- | {{:python: | + | {{python: |
\\ | \\ | ||
< | < | ||
- | > benchmark-all.py | + | > python |
Execution time of test without OpenCL: | Execution time of test without OpenCL: | ||
=============================================================== | =============================================================== | ||
行 198: | 行 280: | ||
</ | </ | ||
- | === マウスコンピュータ LB-L561S === | + | ===== マウスコンピュータ LB-L561S |
- | {{:python: | + | {{python: |
**NVIDIA GeForce GT 640M**\\ | **NVIDIA GeForce GT 640M**\\ | ||
< | < | ||
行 209: | 行 291: | ||
Shading Units: 384 | Shading Units: 384 | ||
</ | </ | ||
- | {{:python: | + | {{python: |
\\ | \\ | ||
**Intel(R) HD Graphics 4000**\\ | **Intel(R) HD Graphics 4000**\\ | ||
行 221: | 行 303: | ||
</ | </ | ||
\\ | \\ | ||
- | **Intel(R) | + | **Intel® |
< | < | ||
TDP: 17W | TDP: 17W | ||
行 271: | 行 353: | ||
Device max clock speed: 1150 MHz | Device max clock speed: 1150 MHz | ||
Device compute units: 16 | Device compute units: 16 | ||
- | Execution time of test: 0.0007987200 | + | Execution time of test: 0.0007947200 s |
+ | Results OK | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Google Colaboratory (略称: Colab) ===== | ||
+ | **CPU: Intel® Xeon® CPU @ 2.30GHz**\\ | ||
+ | **GPU: NVIDIA® Tesla® T4**\\ | ||
+ | < | ||
+ | TDP: 70W | ||
+ | FLOPS: 8.141 TFLOPS | ||
+ | GPU Clock: 585 MHz | ||
+ | 1590 MHz(Boost) | ||
+ | Memory Clock: 1250 MHz | ||
+ | Shading Units: 2560 | ||
+ | </ | ||
+ | \\ | ||
+ | <WRAP prewrap 100%> | ||
+ | < | ||
+ | Execution time of test without OpenCL: | ||
+ | =============================================================== | ||
+ | Platform name: NVIDIA CUDA | ||
+ | Platform profile: FULL_PROFILE | ||
+ | Platform vendor: NVIDIA Corporation | ||
+ | Platform version: OpenCL 1.2 CUDA 10.1.152 | ||
+ | --------------------------------------------------------------- | ||
+ | Device name: Tesla P4 | ||
+ | Device type: ALL | GPU | ||
+ | Device memory: | ||
+ | Device max clock speed: 1113 MHz | ||
+ | Device compute units: 20 | ||
+ | Execution time of test: 0.0010557440 | ||
Results OK | Results OK | ||
</ | </ | ||
行 282: | 行 395: | ||
> pip install pyopencl | > pip install pyopencl | ||
</ | </ | ||
- | <WRAP prewrap 100% #result> | + | <WRAP prewrap 100% #result_long> |
< | < | ||
Collecting pyopencl | Collecting pyopencl | ||
行 425: | 行 538: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ==== error: Microsoft Visual C++ 14.0 is required. が発生する ==== | ||
+ | < | ||
+ | > pip install pyopencl | ||
+ | </ | ||
+ | |||
+ | <WRAP prewrap 100% # | ||
+ | < | ||
+ | Collecting pyopencl | ||
+ | Using cached pyopencl-2020.2.1.tar.gz (352 kB) | ||
+ | Requirement already satisfied: numpy in c: | ||
+ | Requirement already satisfied: pytools> | ||
+ | Requirement already satisfied: decorator> | ||
+ | Requirement already satisfied: appdirs> | ||
+ | Requirement already satisfied: six> | ||
+ | Using legacy setup.py install for pyopencl, since package ' | ||
+ | Installing collected packages: pyopencl | ||
+ | Running setup.py install for pyopencl ... error | ||
+ | ERROR: Command errored out with exit status 1: | ||
+ | | ||
+ | cwd: C: | ||
+ | Complete output (70 lines): | ||
+ | running install | ||
+ | running build | ||
+ | running build_py | ||
+ | creating build | ||
+ | creating build\lib.win-amd64-3.8 | ||
+ | creating build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\algorithm.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\array.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\bitonic_sort.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\bitonic_sort_templates.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\cache.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\capture_call.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\clmath.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\clrandom.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\cltypes.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\elementwise.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\invoker.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\ipython_ext.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\reduction.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\scan.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\tools.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\version.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\_buffers.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\_cluda.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\_mymako.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | copying pyopencl\__init__.py -> build\lib.win-amd64-3.8\pyopencl | ||
+ | creating build\lib.win-amd64-3.8\pyopencl\characterize | ||
+ | copying pyopencl\characterize\performance.py -> build\lib.win-amd64-3.8\pyopencl\characterize | ||
+ | copying pyopencl\characterize\__init__.py -> build\lib.win-amd64-3.8\pyopencl\characterize | ||
+ | creating build\lib.win-amd64-3.8\pyopencl\compyte | ||
+ | copying pyopencl\compyte\array.py -> build\lib.win-amd64-3.8\pyopencl\compyte | ||
+ | copying pyopencl\compyte\dtypes.py -> build\lib.win-amd64-3.8\pyopencl\compyte | ||
+ | copying pyopencl\compyte\__init__.py -> build\lib.win-amd64-3.8\pyopencl\compyte | ||
+ | creating build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\gen_elemwise.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\gen_reduction.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\setup_opencl.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\test_gpu_elemwise.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\test_gpu_ndarray.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | copying pyopencl\compyte\ndarray\__init__.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray | ||
+ | running egg_info | ||
+ | writing pyopencl.egg-info\PKG-INFO | ||
+ | writing dependency_links to pyopencl.egg-info\dependency_links.txt | ||
+ | writing requirements to pyopencl.egg-info\requires.txt | ||
+ | writing top-level names to pyopencl.egg-info\top_level.txt | ||
+ | reading manifest file ' | ||
+ | reading manifest template ' | ||
+ | warning: no files found matching ' | ||
+ | warning: no files found matching ' | ||
+ | warning: no files found matching ' | ||
+ | warning: no files found matching ' | ||
+ | warning: no files found matching ' | ||
+ | writing manifest file ' | ||
+ | creating build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-airy.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-bessel-j-complex.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-bessel-j.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-bessel-y.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-complex.h -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-eval-tbl.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-hankel-complex.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | copying pyopencl\cl\pyopencl-ranluxcl.cl -> build\lib.win-amd64-3.8\pyopencl\cl | ||
+ | creating build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123 | ||
+ | copying pyopencl\cl\pyopencl-random123\array.h -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123 | ||
+ | copying pyopencl\cl\pyopencl-random123\openclfeatures.h -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123 | ||
+ | copying pyopencl\cl\pyopencl-random123\philox.cl -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123 | ||
+ | copying pyopencl\cl\pyopencl-random123\threefry.cl -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123 | ||
+ | running build_ext | ||
+ | building ' | ||
+ | error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": | ||
+ | ---------------------------------------- | ||
+ | ERROR: Command errored out with exit status 1: ' | ||
+ | </ | ||
+ | </ | ||
+ | 手軽に済ませたい場合は [[windows: | ||
==== fatal error C1083: include ファイルを開けません。' | ==== fatal error C1083: include ファイルを開けません。' | ||
< | < | ||
- | >pip install pyopencl | + | > pip install pyopencl |
</ | </ | ||
- | <WRAP prewrap 100% #result> | + | <WRAP prewrap 100% #result_long> |
< | < | ||
Collecting pyopencl | Collecting pyopencl | ||
行 528: | 行 738: | ||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
+ | |||
+ | [[https:// | ||
[[https:// | [[https:// | ||
+ | [[https:// | ||
+ | |||
[[https:// | [[https:// | ||
[[https:// | [[https:// | ||
[[http:// | [[http:// | ||
- | |||