# What is the difference between using opencv-python and building from source?

**URL:** https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627
**Category:** Python
**Tags:** dnn
**Created:** [June 1, 2021, 3:16pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627 "2021-06-01T15:16:13Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nekro](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nekro](https://forum.opencv.org/u/nekro)
#### Post date: [June 1, 2021, 3:16pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/1 "2021-06-01T15:16:13Z")

</div>

I’m currently building OpenCV from source and using the DNN module.  
My end-user would like us to deliver an application that only requires the use of an inference script and a Conda environment.

Please can someone explain what the limitations are with using opencv-python instead of building from source?

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [June 1, 2021, 4:02pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/2 "2021-06-01T16:02:19Z")

</div>

I hope you mean [https://pypi.org/project/opencv-python/](https://pypi.org/project/opencv-python/) because anything listed on _conda_ tends to be unmaintained junk.

that package lacks CUDA, because that’s notoriously fussy about its environment, and it can’t come with non-free algorithms due to licensing.

if _you_ redistribute a binary package, you’ll be subject to the legal stuff too. I doubt that you’ll need any of those non-free algorithms.

the DNN module has many possible backends. OpenCL tends to work anywhere.

practically, there are no limitations to you and your use case.

---

<div class="post-metadata">

### Author: ![nekro](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nekro](https://forum.opencv.org/u/nekro)
#### Post date: [June 1, 2021, 4:22pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/3 "2021-06-01T16:22:35Z")

</div>

@crackwitz Thanks for the info.  
As far as I understand Cuda is required to accelerate the computing on the GPU.  
Does that mean it will work but just not as fast for inference?

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [June 1, 2021, 4:28pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/4 "2021-06-01T16:28:57Z")

</div>

> [@nekro](#):
>
> As far as I understand Cuda is required to accelerate the computing on the GPU.

in general, that’s false.

CUDA can only be used with NVIDIA GPUs. CUDA and NVIDIA hardware are designed for each other.

OpenCL can be used on NVIDIA and AMD GPUs, as well as CPUs. NVIDIA doesn’t give it much love but it’ll run decently.

if that’s news to you, perhaps you’re getting ahead of yourself with these questions.

OpenCV’s `dnn` module can use many different backends, CUDA being one, OpenCL being another.

---

<div class="post-metadata">

### Author: ![nekro](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nekro](https://forum.opencv.org/u/nekro)
#### Post date: [June 2, 2021, 3:46pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/5 "2021-06-02T15:46:09Z")

</div>

@crackwitz thanks for the info.  
I’m installing opencv-python with pip and my end-user has an Nvidia GPU (v100).  
I’ll try using OpenCL for the backend and see if it can use the GPU.

---

<div class="post-metadata">

### Author: ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)
#### Post date: [June 2, 2021, 3:57pm UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/6 "2021-06-02T15:57:48Z")

</div>

your end user should be willing to build OpenCV with cuda on their system. there’s a ton of recipes out there, of various quality, but I’d stick with `cmake-gui` for all the configuration needs.

a `dnn::Net` can be told at runtime what [backend](https://docs.opencv.org/master/db/d30/classcv_1_1dnn_1_1Net.html#a7f767df11386d39374db49cd8df8f59e) and target to prefer. you say `your_net.setPreferableBackend(cv.dnn.DNN_BACKEND_CUDA)` if that’s available.

---

<div class="post-metadata">

### Author: ![nekro](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nekro](https://forum.opencv.org/u/nekro)
#### Post date: [June 4, 2021, 11:46am UTC](https://forum.opencv.org/t/what-is-the-difference-between-using-opencv-python-and-building-from-source/3627/7 "2021-06-04T11:46:56Z")

</div>

@crackwitz thanks again.  
Ideally, yes we would like them to build from source and further down the line we will suggest that. The issue is that they already have a framework in place and are restricted as to which software they can install.  
For the purpose of testing our model we’ll have to use opencv-python initially. I’ve added the option in my script to first check for a GPU, then check if it’s CUDA enabled. If not, it should use OPENCL for the backend and if no GPU is found it should use the CPU.
