sowson/darknet

Any plan to make a Python Interface to use OpenCL?

luvwinnie opened this issue · 10 comments

I really Impressed your work done on OpenCL Darknet fork! I have tried your fork and able to use AMD Radeon Pro 560 on my macbook pro 2017! Do you have any plan to make a python interface to use the AMD GPU?

I have tried to use the following to set gpu, but it seems like didn't work

set_gpu = lib.opencl_set_device
set_gpu.argtypes = [c_int]

set_gpu(1)

I'm not familiar with OpenCL , however, i have been able to use python do the inference, although the yolov3 model seems like not using AMD GPU @@, this is my fork.

sorry to say, but I have not to know python at all :-( I will look on your fork soon, thanks for this issue!

@luvwinnie Thank you! I saw your fork can you do it one more time by changing CMakeLists.txt and Makefile but in a generic way? I do not know python as I said but if you extend only CMake/Make files by adding not deleting it would be an honor if you pull request and contribute with me. Thanks! :-).

@luvwinnie btw, did you tried set GPU to 0? 0 is the first GPU in your system. thanks!

@sowson thanks for viewing my fork! I will try to make a change with CMakeLists.txt and Makefile in the future and make a PR. I'm not familiar with CMake, it could take some time though. ^ ^;

With my macbook pro i have 2 gpus, index 0 is the Intel Graphics and index 1 is the Radeon.
The following code is the information show by the OpenCL.

Device IDs: 2
Device ID: 1
Device name: AMD Radeon Pro 560 Compute Engine
Device vendor: AMD
Device opencl availability: OpenCL 1.2
Device opencl used: 1.2 (Mar  5 2020 22:38:07)
Device double precision: YES
Device max group size: 256
Device address bits: 32

I think i need to take some time to figure out what's happen behind the OpenCL when using the shared object within python. ><, But with the original Darknet it seems like the python code work with CUDA.

Maybe we should figure out a way to confirm whether the Neural net is being loaded to GPU.

no worries... take your time! :P.

I tried to print some debug information within the function opencl_set_device function, it seems like when every inference it printing some debug information...., not really get the timing that opencl_set_device is being invoked. Any idea of this?

void opencl_set_device(int n)
{
    opencl_device_ct_t = ngpusg;
    int i, d;
    for(i = 0; i < ngpusg; ++i) {
        d = gpusg[i];
        printf("setting device %d\n",i);
        if (d == n) {
            opencl_device_id_t = i;
            break;
        }
    }
}

this is for multi-GPU only method to switch in different threads between GPUs :). You should not touch it at all :P.