Closed zchrissirhcz closed 2 years ago
With the latest commit of MegPeak, ./megpeak -d opencl run failed on MacOSX, tested on both Mac Intel x64 and Mac M1.
./megpeak -d opencl
The cmake installation provided FindOpenCL.cmake helps find_package(OpenCL) work, which find the system bundled OpenCL framework.
find_package(OpenCL)
find_package(OpenCL) if(OpenCL_FOUND) message(STATUS "--- OpenCL_FOUND : ${OpenCL_FOUND}") message(STATUS "--- OpenCL_INCLUDE_DIRS : ${OpenCL_INCLUDE_DIRS}") message(STATUS "--- OpenCL_LIBRARIES : ${OpenCL_LIBRARIES}") message(STATUS "--- OpenCL_VERSION_STRING : ${OpenCL_VERSION_STRING}") message(STATUS "--- OpenCL_VERSION_MAJOR : ${OpenCL_VERSION_MAJOR}") message(STATUS "--- OpenCL_VERSION_MINOR : ${OpenCL_VERSION_MINOR}") endif()
Which gives OpenCL_LIBRARIES to:
OpenCL_LIBRARIES
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenCL.framework
Thus, I manually modify libopencl.cpp of opencl-stub in MegPeak, from
libopencl.cpp
#if defined(__APPLE__) || defined(__MACOSX) static const char* default_so_paths[] = { "/System/Library/Frameworks/OpenCL.framework/OpenCL", "libOpenCL.so"};
To
#if defined(__APPLE__) || defined(__MACOSX) static const char* default_so_paths[] = { "/System/Library/Frameworks/OpenCL.framework/OpenCL", "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenCL.framework/OpenCL", // new added "libOpenCL.so"};
But still suffers:
(base) ➜ mac-arm64 git:(main) ✗ ./megpeak -d opencl err: can not find opencl err: failed to load opencl func: clGetPlatformIDs opencl error -32: CL_INVALID_PLATFORM (clGetPlatformIDs(0, nullptr, &nr_platforms) at /Users/zz/work/MegPeak/src/opencl/common.cpp:OpenCLEnv:438) (base) ➜ mac-arm64 git:(main) ✗
Fixed in the PR https://github.com/MegEngine/MegPeak/pull/22
With the latest commit of MegPeak,
./megpeak -d opencl
run failed on MacOSX, tested on both Mac Intel x64 and Mac M1.The cmake installation provided FindOpenCL.cmake helps
find_package(OpenCL)
work, which find the system bundled OpenCL framework.Which gives
OpenCL_LIBRARIES
to:Thus, I manually modify
libopencl.cpp
of opencl-stub in MegPeak, fromTo
But still suffers: