Возникли ошибки. Проделывал все тоже самое на ноутбуке под этой же системой. Но там идет вычисление на CPU, поэтому, наверное, ошибок подобных не возникало. Я к сожалению вижу ошибки, но пока что их понять не могу,потому что с python работаю +- впервые. Говорит, что не найден Opencl_2.2, но pacman, говорит что есть. Быть может как то их переустановить по особенному.
/home/vlasov/Project/venv/bin/python /home/vlasov/Project/main.py
Traceback (most recent call last):
File "/home/vlasov/Project/main.py", line 2, in <module>
import pyopencl as cl
File "/home/vlasov/Project/venv/lib/python3.9/site-packages/pyopencl/__init__.py", line 29, in <module>
import pyopencl.cltypes # noqa: F401
File "/home/vlasov/Project/venv/lib/python3.9/site-packages/pyopencl/cltypes.py", line 22, in <module>
from pyopencl.tools import get_or_register_dtype
File "/home/vlasov/Project/venv/lib/python3.9/site-packages/pyopencl/tools.py", line 37, in <module>
from pyopencl._cl import bitlog2 # noqa: F401
ImportError: /opt/cuda/lib64/libOpenCL.so.1: version `OPENCL_2.2' not found (required by /home/vlasov/Project/venv/lib/python3.9/site-packages/pyopencl/_cl.cpython-39-x86_64-linux-gnu.so)
Process finished with exit code 1
код на Python взят для тестов с офф сайта.
import numpy as np
import pyopencl as cl
a_np = np.random.rand(50000).astype(np.float32)
b_np = np.random.rand(50000).astype(np.float32)
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
mf = cl.mem_flags
a_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a_np)
b_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b_np)
prg = cl.Program(ctx, """
__kernel void sum(
__global const float *a_g, __global const float *b_g, __global float *res_g)
{
int gid = get_global_id(0);
res_g[gid] = a_g[gid] + b_g[gid];
}
""").build()
res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes)
prg.sum(queue, a_np.shape, None, a_g, b_g, res_g)
res_np = np.empty_like(a_np)
cl.enqueue_copy(queue, res_np, res_g)
# Check on CPU with Numpy:
print(res_np - (a_np + b_np))
print(np.linalg.norm(res_np - (a_np + b_np)))
assert np.allclose(res_np, a_np + b_np)
Вот, что говорит pacman
extra/libclc 11.0.0-1 [установлен]
Library requirements of the OpenCL C
programming language
extra/ocl-icd 2.2.13-1 [установлен]
OpenCL ICD Bindings
extra/opencl-clhpp 2.0.12-1
OpenCL C++ header files
extra/opencl-headers 2:2020.06.16-1 [установлен]
OpenCL (Open Computing Language) header
files
extra/opencl-mesa 20.3.1-1 [установлен]
OpenCL support for AMD/ATI Radeon mesa
drivers
extra/opencl-nvidia 455.45.01-2 [установлен]
OpenCL implemention for NVIDIA
extra/opencl-nvidia-390xx 390.138-1
OpenCL implemention for NVIDIA
community/clinfo 3.0.20.11.20-1
Simple OpenCL application that enumerates
all available platform and device
properties
community/clpeak 1.1.0-1
A tool which profiles OpenCL devices to
find their peak capacities
community/erlang-cl 1.2.4-2
OpenCL binding for Erlang
community/intel-compute-runtime 20.48.18558-1 [установлен]
Intel(R) Graphics Compute Runtime for
oneAPI Level Zero and OpenCL(TM) Driver
community/intel-graphics-compiler 1:1.0.5435-1 [установлен]
Intel Graphics Compiler for OpenCL
community/intel-opencl-clang 11.0.0-1 [установлен]
Wrapper library around clang that can
compile OpenCL C kernels to SPIR-V modules
community/mesa-git 21.0.0_devel.132192.04c7fce799a-1
an open-source implementation of the
OpenGL specification, git version
community/pocl 1.6-1
Portable OpenCL is an open-source
implementation of OpenCL which can be
easily adapted for new targets
community/pyopencl-headers 1:2020.2.1-2
A complete, object-oriented language
binding of OpenCL to Python
community/python-pyopencl 1:2020.2.1-2
A complete, object-oriented language
binding of OpenCL to Python
multilib/lib32-ocl-icd 2.2.13-1
OpenCL ICD Bindings (32-bit)
multilib/lib32-opencl-mesa 20.3.1-1
OpenCL support for AMD/ATI Radeon mesa
drivers (32-bit)
multilib/lib32-opencl-nvidia 455.45.01-3
OpenCL implemention for NVIDIA (32-bit)
multilib/lib32-opencl-nvidia-390xx 390.138-1
OpenCL implemention for NVIDIA (32-bit)