# Using OpenCL with DNN on M1 Mac

**URL:** <https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517>\
**Category:** Python\
**Tags:** dnn, opencl, build, apple\
**Created:** [March 31, 2021, 6:22pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517 "2021-03-31T18:22:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kevin](https://forum.opencv.org/u/kevin)\
**Post date:** [March 31, 2021, 6:22pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517/1 "2021-03-31T18:22:07Z")

</div>

I am new to using OpenCV. I have a python script that uses the DNN to do some video processing and it does not use the GPU when running.

I am using an M1 MacBook, which supports OpenCL.

I added these lines into my code:  
**net.setPreferableBackend(cv.dnn.DNN\_BACKEND\_OPENCV)**  
**net.setPreferableTarget(cv.dnn.DNN\_TARGET\_OPENCL)**

But it still does not use the GPU.

How can I use GPU acceleration?

Environment:  
OpenCV 4.5.2-pre built for arm with WITH\_OPENCL=ON  
Running using python 3.8 on conda

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 31, 2021, 6:28pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517/2 "2021-03-31T18:28:55Z")

</div>

did you _build_ the python cv2 wrappers locally ?

please check, what `cv2.getBuildInformation()` has to say about opencl support

---

<div class="post-metadata">

**Author:** ![kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kevin](https://forum.opencv.org/u/kevin)\
**Post date:** [March 31, 2021, 6:30pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517/3 "2021-03-31T18:30:28Z")

</div>

I followed the instructions exactly as they are here: [Building and Installing OpenCV 4.5.0 on an M1 Mac | Sayak Paul](https://sayak.dev/install-opencv-m1/)

I am not sure what it means to build the wrapper. Did I do that in the steps in that link?

---

<div class="post-metadata">

**Author:** ![kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kevin](https://forum.opencv.org/u/kevin)\
**Post date:** [March 31, 2021, 6:35pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517/4 "2021-03-31T18:35:06Z")

</div>

When I did cv2.getBuildInformation(), the output includes the following:

> OpenCL: YES (no extra features)  
> Include path: NO  
> Link libraries: -framework OpenCL

---

<div class="post-metadata">

**Author:** ![Mohsen\_Mohaidat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mohsen_mohaidat/32/2114_2.png) [@Mohsen\_Mohaidat](https://forum.opencv.org/u/Mohsen_Mohaidat)\
**Post date:** [May 25, 2021, 6:16pm UTC](https://forum.opencv.org/t/using-opencl-with-dnn-on-m1-mac/2517/5 "2021-05-25T18:16:53Z")

</div>

Hello Kevin,

Have you fixed your issue ? I am having the same thing, I need your tips if you figure out how did you enable the gpu acceleration  
Thanks
