I've created a python program for object detection and OCR, using torchvision and tesseract, respectively (finetuned pretrained models). Now, when I run it on my laptop (with i7 7700), it takes about 4-5s to process a single image, and I'm satisfied with that.
What I would like to do is run the program on my Raspberry PI 4 (with 4GB ram, and running 64bit Raspbian). After trying out a few libraries' versions, I've managed to run it with some of them set to older ones (torch~=1.8.0, torchvision~=0.9.0, opencv-python~=4.5.3.56, numpy~=1.21.1, matplotlib~=3.4.2, Pillow~=8.3.1, pytesseract~=0.3.8). Now, that same program is run on the PI in about 60s per image, and what puzzles me most is the repeatedly spammed message OpenBLAS Warning : Detect OpenMP Loop and this application may hang. Please rebuild the library with USE_OPENMP=1 option.
. Now this was confusing to me, because I've never needed to build anything from source before, but after some googling, I've figured out that OpenCV may be the problem, specifically the OpenBLAS library it uses. So, with the goal of building the OpenBLAS library with USE_OPENMP=1, I've downloaded the OpenBLAS repo and followed the guide given here.
Thing is, now this library is built and installed, I guess, and there is a new /opt/OpenBLAS
folder present on my system with bin
, include
and lib
subfolders. However, whenever I run my python script, it still takes about 60s and spams the same message, so I guess this has not quite fixed it. So, how do I make opencv-python use this newly compiled OpenBLAS? Do I have to compile it myself, and if so, how? I haven't managed to find anywhere in its guides how to build it with "custom" OpemBLAS. Lastly, if OpenCV is not the problem, where else could the OpenBLAS Warning stem from?
Thank you for your time :D
Just a small update, I've tried running export OMP_NUM_THREADS=1
, and the warning disappeared, and the program runs in 45-50s for 1 image. But that is still not fast enough, so I've tried setting export OMP_NUM_THREADS=2
, but that worsens the performance and the warning returns.