This is a installation log to enable GPU version ppafm runs macOS(13.4)
To use the GPU version of [[ppafm]] on macOS, I installed pyopencl
and pocl
as following, instead of using pip
to install.
conda install -c conda-forge pyopencl
conda install -c conda-forge pocl
pip install pyopencl
~/Github/ppafm/examples/PTCDA_Hartree main* ❯ ./run_gpu.py 22:13:12
PACKAGE_PATH = /Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm
CPP_PATH = /Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/cpp
Initializing an OpenCL environment on Apple
UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed
Traceback (most recent call last):
File "/Users/huangj4/Github/ppafm/examples/PTCDA_Hartree/./run_gpu.py", line 15, in <module>
afmulator = AFMulator(
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/AFMulator.py", line 102, in __init__
oclu.init_env()
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 75, in init_env
FFcl.init(env)
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/field.py", line 34, in init
cl_program = env.loadProgram(env.CL_PATH / 'FF.cl')
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 30, in loadProgram
program = cl.Program(self.ctx, f.read()).build(options=['-I', cl_path])
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/pyopencl/__init__.py", line 534, in build
self._prg, was_cached = self._build_and_catch_errors(
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/pyopencl/__init__.py", line 582, in _build_and_catch_errors
raise err
pyopencl._cl.RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE
Build on <pyopencl.Device 'Apple M2 Pro' on 'Apple' at 0x1027f00>:
program_source:15:10: fatal error: 'splines.cl' file not found
#include "splines.cl"
^~~~~~~~~~~~
(options: -I "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/cl" -I /Users/huangj4/anaconda3/lib/python3.10/site-packages/pyopencl/cl)
(source saved as /var/folders/r7/78fts_m10097pxwwrsd4yt2m0000gp/T/tmpnywgt4uj.cl)
I uninstall it by pip uninstall pyopencl
and then use conda to install.
conda install -c conda-forge pyopencl
Then another error comes:
PACKAGE_PATH = /Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm
CPP_PATH = /Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/cpp
Traceback (most recent call last):
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 68, in get_platforms
platforms = cl.get_platforms()
pyopencl._cl.LogicError: clGetPlatformIDs failed: PLATFORM_NOT_FOUND_KHR
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/huangj4/Github/ppafm/examples/PTCDA_Hartree/./run_gpu.py", line 15, in <module>
afmulator = AFMulator(
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/AFMulator.py", line 102, in __init__
oclu.init_env()
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 74, in init_env
env = OCLEnvironment(i_platform)
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 14, in __init__
platforms = get_platforms()
File "/Users/huangj4/anaconda3/lib/python3.10/site-packages/ppafm/ocl/oclUtils.py", line 70, in get_platforms
raise RuntimeError('Could not find any OpenCL platforms. Check that the OpenCL ICD for your device is installed.')
RuntimeError: Could not find any OpenCL platforms. Check that the OpenCL ICD for your device is installed.
Followed by https://documen.tician.de/pyopencl/misc.html#installation , I tried to install pocl
conda install -c conda-forge pocl
It worked.
pocl
actually uses the CPU as the compute device, so it's not ideal. In the first error, the problem seems to be that the compiler is not finding one of the files in the source folder, so the include path is somehow not being passed to the compiler properly, but there does seem to be an OpenCL compiler available, so it should run withoutpocl
.