python: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

本家: Home - pyopencl 2021.2.6 documentation
OpenCL本家: OpenCL - The Open Standard for Parallel Programming of Heterogeneous Systems

OpenCL を利用するには OS プラットフォームに関係なく、OpenCL 開発環境構築 が必要である。

PyOpenCL をインストールするには、Microsoft Visual Studio、および、OpenCL 開発環境構築 が必要である。

PyOpenCL 仮想環境の作成を行う。(任意)

$ 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)
     |████████████████████████████████| 1.5 MB 656 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-20.2.3

pybind11、Mako をインストールする。

> pip install pybind11 mako
Collecting pybind11
  Downloading pybind11-2.5.0-py2.py3-none-any.whl (296 kB)
     |████████████████████████████████| 296 kB 652 kB/s
Collecting mako
  Downloading Mako-1.1.3-py2.py3-none-any.whl (75 kB)
     |████████████████████████████████| 75 kB 414 kB/s
Collecting MarkupSafe>=0.9.2
  Downloading MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl (16 kB)
Installing collected packages: pybind11, MarkupSafe, mako
Successfully installed MarkupSafe-1.1.1 mako-1.1.3 pybind11-2.5.0

PyOpenCL をインストールする。

> pip install pyopencl
Collecting pyopencl
  Downloading pyopencl-2020.2.2.tar.gz (352 kB)
     |████████████████████████████████| 352 kB 544 kB/s
Collecting numpy
  Using cached numpy-1.19.2-cp38-cp38-win_amd64.whl (13.0 MB)
Collecting pytools>=2017.6
  Downloading pytools-2020.4.tar.gz (67 kB)
     |████████████████████████████████| 67 kB 828 kB/s
Collecting decorator>=3.2.0
  Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting appdirs>=1.4.0
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting six>=1.8.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Using legacy 'setup.py install' for pyopencl, since package 'wheel' is not installed.
Using legacy 'setup.py install' for pytools, since package 'wheel' is not installed.
Installing collected packages: numpy, decorator, appdirs, six, pytools, pyopencl
    Running setup.py install for pytools ... done
    Running setup.py install for pyopencl ... done
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 のベンチマークには以下のプログラムを使用しました。
https://github.com/stefanv/PyOpenCL/blob/master/examples/benchmark-all.py

Python3 用に修正したもの

benchmark-all.py
# example provided by Roger Pau Monn'e
 
import pyopencl as cl
import numpy
import numpy.linalg as la
import datetime
from time import time
 
a = numpy.random.rand(1000).astype(numpy.float32)
b = numpy.random.rand(1000).astype(numpy.float32)
c_result = numpy.empty_like(a)
 
# Speed in normal CPU usage
time1 = time()
for i in range(1000):
        for j in range(1000):
                c_result[i] = a[i] + b[i]
                c_result[i] = c_result[i] * (a[i] + b[i])
                c_result[i] = c_result[i] * (a[i] / 2.0)
time2 = time()
print("Execution time of test without OpenCL: ", time2 - time1, "s")
 
 
for platform in cl.get_platforms():
    for device in platform.get_devices():
        print("===============================================================")
        print("Platform name:", platform.name)
        print("Platform profile:", platform.profile)
        print("Platform vendor:", platform.vendor)
        print("Platform version:", platform.version)
        print("---------------------------------------------------------------")
        print("Device name:", device.name)
        print("Device type:", cl.device_type.to_string(device.type))
        print("Device memory: ", device.global_mem_size//1024//1024, 'MB')
        print("Device max clock speed:", device.max_clock_frequency, 'MHz')
        print("Device compute units:", device.max_compute_units)
 
        # Simnple speed test
        ctx = cl.Context([device])
        queue = cl.CommandQueue(ctx, 
                properties=cl.command_queue_properties.PROFILING_ENABLE)
 
        mf = cl.mem_flags
        a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)
        b_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b)
        dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY, b.nbytes)
 
        prg = cl.Program(ctx, """
            __kernel void sum(__global const float *a,
            __global const float *b, __global float *c)
            {
                int loop;
                int gid = get_global_id(0);
                for(loop=0; loop<1000;loop++)
                {
                    c[gid] = a[gid] + b[gid];
                    c[gid] = c[gid] * (a[gid] + b[gid]);
                    c[gid] = c[gid] * (a[gid] / 2.0);
                }
            }
        """).build()
 
        exec_evt = prg.sum(queue, a.shape, None, a_buf, b_buf, dest_buf)
        exec_evt.wait()
        elapsed = 1e-9*(exec_evt.profile.end - exec_evt.profile.start)
 
        #print("Execution time of test: %g s" % elapsed)
        print("Execution time of test: %.10f s" % elapsed)
 
        c = numpy.empty_like(a)
        #cl.enqueue_read_buffer(queue, dest_buf, c).wait()
        cl.enqueue_copy(queue, c, dest_buf)
        error = 0
        for i in range(1000):
                if c[i] != c_result[i]:
                        error = 1
        if error:
                print("Results doesn't match!!")
        else:
                print("Results OK")

MGC TheCircle CPU GPU
HIS Radeon HD 5870

TDP: 188W
FLOPS: 2.72 TFLOPS
GPU Clock: 850 MHz
Memory Clock: 1200 MHz
Shading Units: 1400

HIS Radeon HD 5870

AMD Phenom(™) II X6 1100T Processor, Black Edition 3.30GHz

TDP: 125W
FLOPS: 79.2 GFLOPS
CPU Clock: 3.30 GHz

※FLOPS は理論値(4 FLOPS/Clock × 3.3GHz × 6コア)
AMD Phenom(™) II X6 1100T Processor 3.30GHz

> python benchmark-all.py
Execution time of test without OpenCL:  9.64494013786316 s
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 2.0 AMD-APP (1800.11)
---------------------------------------------------------------
Device name: Cypress
Device type: GPU
Device memory:  1024 MB
Device max clock speed: 850 MHz
Device compute units: 20
Execution time of test: 0.0000072220 s
Results OK
===============================================================
Platform name: AMD Accelerated Parallel Processing
Platform profile: FULL_PROFILE
Platform vendor: Advanced Micro Devices, Inc.
Platform version: OpenCL 2.0 AMD-APP (1800.11)
---------------------------------------------------------------
Device name: AMD Phenom(tm) II X6 1100T Processor
Device type: CPU
Device memory:  16382 MB
Device max clock speed: 3311 MHz
Device compute units: 6
Execution time of test: 0.0010633330 s
Results OK

LB-L561S CPU GPU
NVIDIA GeForce GT 640M

TDP: 32 W
FLOPS: 480 GFLOPS
GPU Clock: 625 MHz
Memory Clock: 900 MHz
              1800 MHz effective
Shading Units: 384

NVIDIA GeForce GT 640M

Intel(R) HD Graphics 4000

TDP: 45W
FLOPS: 217.6~332.8 GFLOPS
GPU Clock: 350 MHz
          1150 MHz(Boost)
Memory Clock: System Shared
Shading Units: 128


Intel® Core(™) i7-3517U CPU @ 1.90GHz

TDP: 17W
FLOPS: 30.4 GFLOPS
CPU Clock: 1.90 GHz

※FLOPS は理論値(8 FLOPS/Clock × 1.9GHz × 2コア)

Execution time of test without OpenCL:  10.292678594589233 s
===============================================================
Platform name: NVIDIA CUDA
Platform profile: FULL_PROFILE
Platform vendor: NVIDIA Corporation
Platform version: OpenCL 1.2 CUDA 10.1.131
---------------------------------------------------------------
Device name: GeForce GT 640M
Device type: GPU
Device memory:  1024 MB
Device max clock speed: 708 MHz
Device compute units: 2
Execution time of test: 0.0015742400 s
Results OK
===============================================================
Platform name: Intel(R) OpenCL
Platform profile: FULL_PROFILE
Platform vendor: Intel(R) Corporation
Platform version: OpenCL 1.2
---------------------------------------------------------------
Device name:        Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz
Device type: CPU
Device memory:  16263 MB
Device max clock speed: 1900 MHz
Device compute units: 4
C:\Python37\lib\site-packages\pyopencl\__init__.py:235: CompilerWarning: Non-empty compiler output encountered. Set the environment variable PYOPENCL_COMPILER_OUTPUT=1 to see more.
  "to see more.", CompilerWarning)
Execution time of test: 0.0011095000 s
Results OK
===============================================================
Platform name: Intel(R) OpenCL
Platform profile: FULL_PROFILE
Platform vendor: Intel(R) Corporation
Platform version: OpenCL 1.2
---------------------------------------------------------------
Device name: Intel(R) HD Graphics 4000
Device type: GPU
Device memory:  1400 MB
Device max clock speed: 1150 MHz
Device compute units: 16
Execution time of test: 0.0007947200 s
Results OK

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


Execution time of test without OpenCL:  5.938735008239746 s
===============================================================
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:  7611 MB
Device max clock speed: 1113 MHz
Device compute units: 20
Execution time of test: 0.0010557440 s
Results OK
> pip install pyopencl
Collecting pyopencl
  Using cached https://files.pythonhosted.org/packages/1b/0e/f49c0507610aae0bc2aba6ad1e79f87992d9e74e6ea55af23e436075502e/pyopencl-2019.1.tar.gz
Requirement already satisfied: numpy in c:\python37\lib\site-packages (from pyopencl) (1.16.4)
Requirement already satisfied: pytools>=2017.6 in c:\python37\lib\site-packages (from pyopencl) (2019.1.1)
Requirement already satisfied: decorator>=3.2.0 in c:\python37\lib\site-packages (from pyopencl) (4.4.0)
Requirement already satisfied: appdirs>=1.4.0 in c:\python37\lib\site-packages (from pyopencl) (1.4.3)
Requirement already satisfied: six>=1.9.0 in c:\python37\lib\site-packages (from pyopencl) (1.12.0)
Installing collected packages: pyopencl
  Running setup.py install for pyopencl ... error
    ERROR: Complete output from command 'c:\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-dtgmmbt_\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-ok7vcln_\install-record.txt' --single-version-externally-managed --compile:
    ERROR: ---------------------------------------------------------------------------
    Pybind11 is not installed.
    ---------------------------------------------------------------------------
    Very likely, the build process after this message will fail.

    Simply press Ctrl+C and type
    python -m pip install pybind11
    to fix this. If you don't, the build will continue
    in a few seconds.

    [1] https://pybind11.readthedocs.io/en/stable/
    ---------------------------------------------------------------------------
    Continuing in 1 seconds...
    ---------------------------------------------------------------------------
    Mako is not installed.
    ---------------------------------------------------------------------------
    That is not a problem, as most of PyOpenCL will be just fine
    without it. Some higher-level parts of pyopencl (such as
    pyopencl.reduction) will not function without the templating engine
    Mako [1] being installed. If you would like this functionality to
    work, you might want to install Mako after you finish
    installing PyOpenCL.

    Simply type
    python -m pip install mako
    either now or after the installation completes to fix this.

    [1] http://www.makotemplates.org/
    ---------------------------------------------------------------------------
    Hit Ctrl-C now if you'd like to think about the situation.
    ---------------------------------------------------------------------------
    Continuing in 1 seconds...
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\algorithm.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\array.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\bitonic_sort.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\bitonic_sort_templates.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\cache.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\capture_call.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\clmath.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\clrandom.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\cltypes.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\elementwise.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\invoker.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\ipython_ext.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\reduction.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\scan.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\tools.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\version.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_buffers.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_cluda.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_mymako.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\__init__.py -> build\lib.win-amd64-3.7\pyopencl
    creating build\lib.win-amd64-3.7\pyopencl\characterize
    copying pyopencl\characterize\performance.py -> build\lib.win-amd64-3.7\pyopencl\characterize
    copying pyopencl\characterize\__init__.py -> build\lib.win-amd64-3.7\pyopencl\characterize
    creating build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\array.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\dtypes.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\__init__.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    creating build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\gen_elemwise.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\gen_reduction.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\setup_opencl.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\test_gpu_elemwise.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\test_gpu_ndarray.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\__init__.py -> build\lib.win-amd64-3.7\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 'pyopencl.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.h'
    warning: no files found matching 'doc\_static\*.css'
    warning: no files found matching 'doc\_templates\*.html'
    warning: no files found matching '*.py.in'
    writing manifest file 'pyopencl.egg-info\SOURCES.txt'
    creating build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-airy.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-j-complex.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-j.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-y.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-complex.h -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-eval-tbl.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-hankel-complex.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-ranluxcl.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    creating build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\array.h -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\openclfeatures.h -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\philox.cl -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\threefry.cl -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    running build_ext
    building 'pyopencl._cl' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -Ipybind11/include -Ic:\python37\Include -IC:\Users\tomoyan\AppData\Roaming\Python\Python37\Include -Ic:\python37\lib\site-packages\numpy\core\include -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpsrc/wrap_constants.cpp /Fobuild\temp.win-amd64-3.7\Release\src/wrap_constants.obj -fvisibility=hidden /EHsc /DVERSION_INFO=\"2019.1\"
    cl : コマンド ライン warning D9002 : 不明なオプション '-fvisibility=hidden' を無視します。
    wrap_constants.cpp
    C:\Users\tomoyan\AppData\Local\Temp\pip-install-dtgmmbt_\pyopencl\src\wrap_cl.hpp(57): fatal error C1083: include ファイルを開けません。'CL/cl.h':No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command "'c:\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-dtgmmbt_\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-ok7vcln_\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\tomoyan\AppData\Local\Temp\pip-install-dtgmmbt_\pyopencl\

Pybind11, Mako をインストールしてから PyOpenCL をインストールする。

> pip install pybind11 Mako
Collecting pybind11
  Downloading https://files.pythonhosted.org/packages/5d/85/c7a8dffda52ce25a8bcfe9a28b6861bdd52da59ae001fdd4173e054b7d9b/pybind11-2.3.0-py2.py3-none-any.whl (147kB)
     |████████████████████████████████| 153kB 1.3MB/s
Collecting Mako
  Downloading https://files.pythonhosted.org/packages/1b/a5/023aba3d69aacef6bfc13797bdc3dd03c6fb4ae2dcd2fde7dffc37233924/Mako-1.0.14.tar.gz (462kB)
     |████████████████████████████████| 471kB 3.3MB/s
Collecting MarkupSafe>=0.9.2 (from Mako)
  Downloading https://files.pythonhosted.org/packages/65/c6/2399700d236d1dd681af8aebff1725558cddfd6e43d7a5184a675f4711f5/MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl
Installing collected packages: pybind11, MarkupSafe, Mako
  Running setup.py install for Mako ... done
Successfully installed Mako-1.0.14 MarkupSafe-1.1.1 pybind11-2.3.0
> pip install pyopencl
Collecting pyopencl
  Using cached pyopencl-2020.2.1.tar.gz (352 kB)
Requirement already satisfied: numpy in c:\users\tomoyan\py38_opencl\lib\site-packages (from pyopencl) (1.19.1)
Requirement already satisfied: pytools>=2017.6 in c:\users\tomoyan\py38_opencl\lib\site-packages (from pyopencl) (2020.4)
Requirement already satisfied: decorator>=3.2.0 in c:\users\tomoyan\py38_opencl\lib\site-packages (from pyopencl) (4.4.2)
Requirement already satisfied: appdirs>=1.4.0 in c:\users\tomoyan\py38_opencl\lib\site-packages (from pyopencl) (1.4.4)
Requirement already satisfied: six>=1.9.0 in c:\users\tomoyan\py38_opencl\lib\site-packages (from pyopencl) (1.15.0)
Using legacy setup.py install for pyopencl, since package 'wheel' is not installed.
Installing collected packages: pyopencl
    Running setup.py install for pyopencl ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\tomoyan\py38_opencl\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-kysbgjhb\\pyopencl\\setup.py'"'"'; __file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-kysbgjhb\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-u_d5qgvn\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\tomoyan\py38_opencl\include\site\python3.8\pyopencl'
         cwd: C:\Users\tomoyan\AppData\Local\Temp\pip-install-kysbgjhb\pyopencl\
    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 'pyopencl.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.h'
    warning: no files found matching 'doc\_static\*.css'
    warning: no files found matching 'doc\_templates\*.html'
    warning: no files found matching '*.py.in'
    warning: no files found matching 'pyproject.toml'
    writing manifest file 'pyopencl.egg-info\SOURCES.txt'
    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 'pyopencl._cl' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\tomoyan\py38_opencl\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-kysbgjhb\\pyopencl\\setup.py'"'"'; __file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-kysbgjhb\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-u_d5qgvn\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\tomoyan\py38_opencl\include\site\python3.8\pyopencl' Check the logs for full command output.

手軽に済ませたい場合は Build Tools for Visual Studio をインストールする。

> pip install pyopencl
Collecting pyopencl
  Using cached https://files.pythonhosted.org/packages/1b/0e/f49c0507610aae0bc2aba6ad1e79f87992d9e74e6ea55af23e436075502e/pyopencl-2019.1.tar.gz
Requirement already satisfied: numpy in c:\python37\lib\site-packages (from pyopencl) (1.16.4)
Requirement already satisfied: pytools>=2017.6 in c:\python37\lib\site-packages (from pyopencl) (2019.1.1)
Requirement already satisfied: decorator>=3.2.0 in c:\python37\lib\site-packages (from pyopencl) (4.4.0)
Requirement already satisfied: appdirs>=1.4.0 in c:\python37\lib\site-packages (from pyopencl) (1.4.3)
Requirement already satisfied: six>=1.9.0 in c:\python37\lib\site-packages (from pyopencl) (1.12.0)
Installing collected packages: pyopencl
  Running setup.py install for pyopencl ... error
    ERROR: Complete output from command 'c:\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-wwvlcaj3\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-ne3hm7p_\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\algorithm.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\array.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\bitonic_sort.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\bitonic_sort_templates.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\cache.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\capture_call.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\clmath.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\clrandom.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\cltypes.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\elementwise.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\invoker.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\ipython_ext.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\reduction.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\scan.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\tools.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\version.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_buffers.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_cluda.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\_mymako.py -> build\lib.win-amd64-3.7\pyopencl
    copying pyopencl\__init__.py -> build\lib.win-amd64-3.7\pyopencl
    creating build\lib.win-amd64-3.7\pyopencl\characterize
    copying pyopencl\characterize\performance.py -> build\lib.win-amd64-3.7\pyopencl\characterize
    copying pyopencl\characterize\__init__.py -> build\lib.win-amd64-3.7\pyopencl\characterize
    creating build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\array.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\dtypes.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    copying pyopencl\compyte\__init__.py -> build\lib.win-amd64-3.7\pyopencl\compyte
    creating build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\gen_elemwise.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\gen_reduction.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\setup_opencl.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\test_gpu_elemwise.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\test_gpu_ndarray.py -> build\lib.win-amd64-3.7\pyopencl\compyte\ndarray
    copying pyopencl\compyte\ndarray\__init__.py -> build\lib.win-amd64-3.7\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 'pyopencl.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.h'
    warning: no files found matching 'doc\_static\*.css'
    warning: no files found matching 'doc\_templates\*.html'
    warning: no files found matching '*.py.in'
    writing manifest file 'pyopencl.egg-info\SOURCES.txt'
    creating build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-airy.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-j-complex.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-j.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-bessel-y.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-complex.h -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-eval-tbl.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-hankel-complex.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    copying pyopencl\cl\pyopencl-ranluxcl.cl -> build\lib.win-amd64-3.7\pyopencl\cl
    creating build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\array.h -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\openclfeatures.h -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\philox.cl -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    copying pyopencl\cl\pyopencl-random123\threefry.cl -> build\lib.win-amd64-3.7\pyopencl\cl\pyopencl-random123
    running build_ext
    building 'pyopencl._cl' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -Ipybind11/include -Ic:\python37\Include -IC:\Users\tomoyan\AppData\Roaming\Python\Python37\Include -Ic:\python37\lib\site-packages\numpy\core\include -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpsrc/wrap_constants.cpp /Fobuild\temp.win-amd64-3.7\Release\src/wrap_constants.obj -fvisibility=hidden /EHsc /DVERSION_INFO=\"2019.1\"
    cl : コマンド ライン warning D9002 : 不明なオプション '-fvisibility=hidden' を無視します。
    wrap_constants.cpp
    C:\Users\tomoyan\AppData\Local\Temp\pip-install-wwvlcaj3\pyopencl\src\wrap_cl.hpp(57): fatal error C1083: include ファイルを開けません。'CL/cl.h':No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command "'c:\python37\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\tomoyan\\AppData\\Local\\Temp\\pip-install-wwvlcaj3\\pyopencl\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tomoyan\AppData\Local\Temp\pip-record-ne3hm7p_\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\tomoyan\AppData\Local\Temp\pip-install-wwvlcaj3\pyopencl\

OpenCL 開発環境構築 を行ってから PyOpenCL をインストールする。

  • python/pyopencl.txt
  • 最終更新: 2023/09/27 08:05
  • by ともやん