I have a program that processes videos using foreground detection in OpenCV 2.4.9/python/on windows and packaged for a windows executable using py2exe. I recently updated opencv to opencv3 and repackaged my program. When i run on my computer (with opencv3 installed locally) everything goes fine.
However, when a user goes and downloads the program and runs it on another computer, they get the warning
Failed to load OpenCL runtime
This just seems to be just a warning, and i can detect no performance issues.
I have a couple options. I can just suppress this specific warning in a try statement, or i can somehow turn off the OpenCL on my computer for packaging the program. Suggestions on either strategy would be appreciated. Anything i am overlooking? To my understanding the OpenCL library is for acceleration using GPU.
Thanks,
the solution will be compiling the OpenCV libs without OpenCL and then link them to your application
I had encounter the same problem, here's my solution:
go to the Intel website and download the OpenCL library, then unzip it
run the install.sh file
If your install fails because of update-alternatives errors, maybe it's because you are using Ubuntu/Debian distro and the Intel install package has a wrong setting with it.
To solve this, xfanzone did a very good job on this. Take a look here.
download the patch zip file and patch your OpenCL package
install it again, now it should work fine
If you just don't need to use OpenCL, you can set the environment var as below:
export OPENCV_OPENCL_RUNTIME=999
Sometimes, if you want to turn on the opencl:
export OPENCV_OPENCL_RUNTIME=
Related
So I have been writing a Python program that utilizes OpenCV for Windows. It's mostly just a project to learn how to use Vision-based Machine Learning. I've gotten the project working with my CPU, and while it "functions" it is abysmally slow, so I wanted to try working with the GPU version instead. Unfortunately, there isn't a python package that has OpenCV with Cuda-enabled GPU functionality (from what I could tell).
So after researching, I found that in order to do what I wanted, I had to compile the OpenCV source code with Cmake. So I set out to do so with the help of this guide which seemed to work (it compiled at least). But now i'm running into the issue of:
I don't actually know how to import this newly built package into my project's venv. I've tried moving the cv2.cp37-win_amd64.pyd into the project's venv site packages, i've tried moving the entire build folder into the project and directly importing it, but neither actually worked... so I'm a little at a loss on what to do to get OpenCV with GPU enabled CUDA working in my project.
EDIT:
I followed the guide that Miki linked, including installing Anaconda and all that jazz. The package imports correctly when I use:
Following #Miki's suggestion, I went through the guide that they linked, following all of the processes, testing that OpenCV was in fact being built correctly with:
set path=%openCvBuild%\install\x64\vc16\bin;%path%
python -c "import cv2; print(f'OpenCV: {cv2.__version__} for python installed and working')"
But it still isn't showing up in the python import in conda, despite being in the env's site-packages folder.
Does anyone know how to profile Python scripts with NVIDIA Nsight Systems?
I'm not sure what I would put in the Target Application field. I tried putting in the Spyder IDE (from Anaconda) and then executing my Python script from there, but I can't seem to import Tensorflow when I do that.
As soon as I import Tensorflow and use it, it tells me "no such module". It seems that the Spyder IDE that I open from NSight Systems is different from the one when I open it normally (without Nsight).
I solved this in windows using the answer from nvidia forum:
So basically you should use a proper python environment and use the complete python directory like:
nsys profile C:\Users\beru\AppData\Local\Programs\Python\Python38\python.exe demo.py
By the way, this answer also helps me to know what to do for profiling python code using nsight system on win. I strongly recommend anyone puzzled by this read it.
I've written a program that utilises the Pillow module (a PIL fork).
I would like to compile the finished program to an .exe for distribution.
I have tried compiling the program with both PyInstaller and Nuitka, however neither of these seem to support the compilation of a program that utilises this external module.
Does anyone know of any other Python compilers that support the compilation of a program that utilises the Pillow module?
Thank you
Installing Anaconda is your best bet.
Anaconda is a complete package of all python programming essentials. It also has your much needed pillow (or the so called python imaging library) built-in.
It comes with certain other python packages built-in and ready-to-use such as numpy, pandas, scipy, matplotlib, and IPython.
It also has an easy-to-use IDE namely Spyder, which is the playground. You get to do all your coding here. Spyder is just like any other text editor but with more functionality an ease of access.
If your looking out for more options in image processing, Anaconda also comes with scikit-image or skmage (also built-in)
In case you want to install OpenCV on your machine, it can be easily done using the Anaconda command prompt using this command:
conda install -c menpo opencv=3.0.0
Visit the website HERE
I decided to have another attempt at compiling my program using Pyinstaller.
Pyinstaller already worked with Pillow, however it ran into problems with programs that utilised Tix.
After a lot of trial and error, I managed to create a solution based on a comment on github.
My solution.
I am writing a small python installer application that will run on linux. However, i don't know which Linux in advanced, so i cant write for any specific python version since i have no idea what is installed on the client computer, if any (do i? is there any thumb rule for python version preinstalled on a Linux machine?).
Is there a optimal way to install a local python version on a client's computer in some temporary directory, use it for the application run-time, than remove it when it is done?
Do you know the machines architecture? If so simply download the python version you want to install on the linux architecture on your server/box/your computer then compress it and upload it to a server somewhere. (or use the link on python.org)
then simply make a bash script to download it and uncompress it. Then install it using shell commands like make or cmake ./configure within the install directory
If you dont know the architecture or are trying to use it on some generic or other you could cross compile it using these cross compilers to cross compile python (or anything coded in c(/c++?))
http://pastebin.com/mxWqBvy8
Typically the general 'rule of thumb' for the python version would be python2.7.x
You could use Pyinstaller to "compile" your python (its origanally win) there is a linux version somewhere, fairly sure its as easy as pyinstaller test.py)
Removing it shouldnt be that hard, rm is universal everywhere
You can bundle your programs with Python itself without requiring the target machine installed Python Interpreter on it.
Check this out: https://wiki.python.org/moin/Freeze
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.