DeadSix27 / waifu2x-converter-cpp

Improved fork of Waifu2X C++ using OpenCL and OpenCV
MIT License
792 stars 86 forks source link

Processor Detection Error on MacOS 10.15 #226

Closed sgsunder closed 4 years ago

sgsunder commented 4 years ago

Running on MacOS 10.15. Output of waifu2x-converter-cpp -l is:

   0: Intel(R) UHD Graphics 630                    (OpenCL    ): num_core=24
   1: AMD Radeon Pro 5500M Compute Engine          (OpenCL    ): num_core=24
   2: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (FMA       ): num_core=16
   3: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (OpenCL    ): num_core=16

For some reason, the program defaults to using 2 normally, and 0 when the --force-OpenCL option is passed, so I would have to specify -p 1 manually to use my faster GPU for computing.

This isn't that big of a deal to me, but it feels like a bug in that the program doesn't prefer the clearly faster option for compute.

YukihoAA commented 4 years ago

@sgsunder

please try #234

sgsunder commented 4 years ago

@YukihoAA Pulled and tried #234, it now defaults to processor 0 (Intel iGPU). It's better, but ideally it would default to processor 1 (Radeon discrete graphics).

YukihoAA commented 4 years ago

@sgsunder please try commit 373da61 thank you.

sgsunder commented 4 years ago

@YukihoAA the commit didn't change any behaviour on my end, still defaults to iGPU.

YukihoAA commented 4 years ago

@sgsunder

please test commit c4bae07 on test-processor branch and run waifu2x-converter-cpp -l to check your GPU type

sample: image

EDIT1: wrong commit number

sgsunder commented 4 years ago

@YukihoAA output of command on c4bae07 :

./waifu2x-converter-cpp -l
   0: Intel(R) UHD Graphics 630                    (OpenCL-UNKOWN-GPU): num_core=24
   1: AMD Radeon Pro 5500M Compute Engine          (OpenCL-UNKOWN-GPU): num_core=24
   2: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (FMA       ): num_core=16
   3: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (OpenCL-UNKOWN-CPU): num_core=16
YukihoAA commented 4 years ago

@sgsunder did you installed chipset, graphics driver correctly? also, check build options about opencl.

it seems your OpenCL environment cannot read manufacture information.

please check commit 8b6c9a7 and run to check platform info.

sgsunder commented 4 years ago

Some more details if they might help you:

OpenCL v1.2 is pre-installed by macOS 10.15, I haven't tried any newer version as OpenCL is deprecated by Apple.

Haven't messed with any GPU/chipset drivers. It is a legit Macbook (not a Hackintosh) so all the drivers/kernel-level support should have been included with the macOS install.

Results of cmake . -DOPENCV_PREFIX=/usr/local/Cellar/opencv/4.3.0/:

-- Found git, set version to: v5.3.3 (HEAD-8b6c9a7)
-- System is: Darwin (Apple)
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
-- CUDA not found. disabled.
--
-- Config summary:
--  OpenCV: 4.3.0
--  OpenCL: 1.2
--  CUDA: Not found
--  Unicode: TRUE
--  Installing models to: /usr/local/share/waifu2x-converter-cpp
--  Not building test binaries
--  Building for: Unix Makefiles-x86_64
--
-- Configuring done
-- Generating done
-- Build files have been written to: [REMOVED]

Results of make:

Scanning dependencies of target conv
[  4%] Building C object CMakeFiles/conv.dir/conv.c.o
[  9%] Linking C executable conv
[  9%] Built target conv
[ 14%] Generating modelHandler_OpenCL.cl.h
[ 14%] Built target gensrcs
Scanning dependencies of target w2xc
[ 28%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_fma.cpp.o
[ 28%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_sse.cpp.o
[ 28%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_OpenCL.cpp.o
[ 42%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_avx.cpp.o
[ 42%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler.cpp.o
[ 42%] Building CXX object CMakeFiles/w2xc.dir/src/w2xconv.cpp.o
[ 57%] Building CXX object CMakeFiles/w2xc.dir/src/convertRoutine.cpp.o
[ 57%] Building CXX object CMakeFiles/w2xc.dir/src/modelHandler_CUDA.cpp.o
[ 57%] Building CXX object CMakeFiles/w2xc.dir/src/threadPool.cpp.o
[ 61%] Building CXX object CMakeFiles/w2xc.dir/src/common.cpp.o
[ 66%] Building CXX object CMakeFiles/w2xc.dir/src/cvwrap.cpp.o
[ 71%] Building CXX object CMakeFiles/w2xc.dir/src/Env.cpp.o
[ 76%] Building CXX object CMakeFiles/w2xc.dir/src/Buffer.cpp.o
[ 80%] Building CXX object CMakeFiles/w2xc.dir/src/tstring.cpp.o
[ 85%] Linking CXX shared library libw2xc.dylib
[ 85%] Built target w2xc
Scanning dependencies of target waifu2x-converter-cpp
[ 95%] Building CXX object CMakeFiles/waifu2x-converter-cpp.dir/src/tstring.cpp.o
[ 95%] Building CXX object CMakeFiles/waifu2x-converter-cpp.dir/src/main.cpp.o
[100%] Linking CXX executable waifu2x-converter-cpp
[100%] Built target waifu2x-converter-cpp
YukihoAA commented 4 years ago

@sgsunder so.. what was output of commit 8b6c9a7 with waifu2x-converter-cpp -l ?

sgsunder commented 4 years ago

Sorry for the delay

./waifu2x-converter-cpp -l
Platform: Apple
   0: Intel(R) UHD Graphics 630                    (OpenCL-UNKOWN-GPU): num_core=24
   1: AMD Radeon Pro 5500M Compute Engine          (OpenCL-UNKOWN-GPU): num_core=24
   2: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (FMA       ): num_core=16
   3: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (OpenCL-UNKOWN-CPU): num_core=16
YukihoAA commented 4 years ago

thank you @sgsunder,

try commit 62dd502 and waifu2x-converter-cpp -l

EDIT1: changed commit number - slightly improved.

sgsunder commented 4 years ago

@YukihoAA

This seems to work! Tested an image conversion as well and it uses the Radeon GPU by default now.

Output:

Platform: Apple
   0: AMD Radeon Pro 5500M Compute Engine          (OpenCL-AMD-GPU): num_core=24
   1: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (FMA       ): num_core=16
   2: Intel(R) UHD Graphics 630                    (OpenCL-INTEL-GPU): num_core=24
   3: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz     (OpenCL-INTEL-CPU): num_core=16