Can't compile for OpenCL 1.2
I have an AMD 5700G CPU with internal GPU. There is no official driver from AMD to support OpenCL, but there is an OpenCL implementation that does: http://portablecl.org/index.html
I installed this and clinfo gives me an OpenCL target: `~/KataGo$ clinfo Number of platforms 1 Platform Name Portable Computing Language Platform Vendor The pocl project Platform Version OpenCL 2.0 pocl 1.8 Linux, None+Asserts, RELOC, LLVM 11.1.0, SLEEF, DISTRO, POCL_DEBUG Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd cl_pocl_content_size Platform Extensions function suffix POCL
Platform Name Portable Computing Language
Number of devices 1
Device Name pthread-AMD Ryzen 7 5700G with Radeon Graphics
Device Vendor AuthenticAMD
Device Vendor ID 0x1022
Device Version OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-generic
Driver Version 1.8
Device OpenCL C Version OpenCL C 1.2 pocl
Device Type CPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 16
Max clock frequency 4673MHz
Device Partition (core)
Max number of sub-devices 16
Supported partition types equally, by counts
Supported affinity domains (n/a)
Max work item dimensions 3
Max work item sizes 4096x4096x4096
Max work group size 4096
=== CL_PROGRAM_BUILD_LOG ===
error: unknown target CPU 'generic'
Device pthread-AMD Ryzen 7 5700G with Radeon Graphics failed to build the program, log: error: unknown target CPU 'generic'
Preferred work group size multiple (kernel) <getWGsizes:1504: create kernel : error -45>
Preferred / native vector sizes
char 16 / 16
short 16 / 16
int 8 / 8
long 4 / 4
half 0 / 0 (n/a)
float 8 / 8
double 4 / 4 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Address bits 64, Little-Endian
Global memory size 31333728256 (29.18GiB)
Error Correction support No
Max memory allocation 8589934592 (8GiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type Read/Write
Global Memory cache size 16777216 (16MiB)
Global Memory cache line size 64 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 536870912 pixels
Max 1D or 2D image array size 2048 images
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 128
Local memory type Global
Local memory size 524288 (512KiB)
Max number of constant args 8
Max constant buffer size 524288 (512KiB)
Max size of kernel argument 1024
Queue properties
Out-of-order execution Yes
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
printf() buffer size 16777216 (16MiB)
Built-in kernels (n/a)
Device Extensions cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_fp64 cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp64
NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Portable Computing Language clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [POCL] clCreateContext(NULL, ...) [default] Success [POCL] clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1) Platform Name Portable Computing Language Device Name pthread-AMD Ryzen 7 5700G with Radeon Graphics clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) Success (1) Platform Name Portable Computing Language Device Name pthread-AMD Ryzen 7 5700G with Radeon Graphics clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name Portable Computing Language Device Name pthread-AMD Ryzen 7 5700G with Radeon Graphics
ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.14 ICD loader Profile OpenCL 3.0 `
When I try to build the OpenCL backend I get: `~/KataGo/cpp$ cmake . -DUSE_BACKEND=OPENCL -- Building 'katago' executable for GTP engine and other tools. -- -DUSE_BACKEND=OPENCL, using OpenCL backend. -- Including Git revision in the compiled executable, specify -DNO_GIT_REVISION=1 to disable -- Could NOT find OpenCL (missing: OpenCL_LIBRARY OpenCL_INCLUDE_DIR) CMake Warning at CMakeLists.txt:324 (message): OpenCL not found, attempting to see if CUDA exists and has OpenCL since sometimes CUDA may provide OpenCL where cmake can't find it.
-- Could not find nvcc, please set CUDAToolkit_ROOT. CMake Error at CMakeLists.txt:327 (message): OpenCL installation not found
-- Configuring incomplete, errors occurred! See also "/home/werner/KataGo/cpp/CMakeFiles/CMakeOutput.log". See also "/home/werner/KataGo/cpp/CMakeFiles/CMakeError.log". `
There is a line with an error in the clinfo output, maybe that's the problem? Any clue how to fix that?
Hi, I am trying to give you some advice. For your igpu like Ryzen 5700G, the graphic core arch is still same as Vega dgpu so you can try to install driver from gpu like Radeon Vii, reference the guide Radeon™ Software for Linux® Installation.
Do you know where the lib and include dirs are for your OpenCL installation? If so, it may work to specify -DOpenCL_LIBRARY=... -DOpenCL_INCLUDE_DIR=... but replacing the ... with the appropriate paths to those directories when running cmake.
Hi David, thanks for your answer. I installed pocl via apt (sudo apt install pocl-opencl-icd), so I guess no source code was installed this way - but I'm not a dev. So I got the source for the project (git clone https://github.com/pocl/pocl.git), and tried as you said... but then I get
:~/KataGo/cpp$ cmake . -DUSE_BACKEND=OPENCL -DOpenCL_LIBRARY=~/Downloads/pocl/lib -DOpenCL_INCLUDE_DIR=~/Downloads/pocl/include -- Building 'katago' executable for GTP engine and other tools. -- -DUSE_BACKEND=OPENCL, using OpenCL backend. -- Including Git revision in the compiled executable, specify -DNO_GIT_REVISION=1 to disable -- Found OpenCL: /home/werner/Downloads/pocl/lib -- Setting up build for GNU or Clang. -- Enabling GNU-specific build options. -- Configuring done WARNING: Target "katago" requests linking to directory "/home/werner/Downloads/pocl/lib". Targets may link only to libraries. CMake is dropping the item. -- Generating done -- Build files have been written to: /home/werner/KataGo/cpp
And then when I try "make" anyway, I get a trillion errors like
/usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3204: undefined reference to clReleaseMemObject'
/usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3205: undefined reference to clReleaseMemObject' /usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3206: undefined reference to clReleaseMemObject'
/usr/bin/ld: CMakeFiles/katago.dir/neuralnet/openclbackend.cpp.o: in function BatchNormLayer::~BatchNormLayer()': /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:895: undefined reference to clReleaseMemObject'
/usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:896: undefined reference to clReleaseMemObject' /usr/bin/ld: CMakeFiles/katago.dir/neuralnet/openclbackend.cpp.o: in function NeuralNet::testEvaluateConv(ConvLayerDesc const*, int, int, int, bool, bool, std::vector<float, std::allocatorclCreateBuffer' /usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3149: undefined reference to clReleaseMemObject'
/usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3150: undefined reference to clReleaseMemObject' /usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3151: undefined reference to clReleaseMemObject'
/usr/bin/ld: /home/werner/KataGo/cpp/neuralnet/openclbackend.cpp:3152: undefined reference to clReleaseMemObject' /
which is probably due to the "lib" error in the first step. Is that fixable easily? Sorry, no dev here :)