You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've wanted to use your program with docker on Linux but I had the following problems:
Issue 1:
Following PaddleOCR environment setup instructions I used the paddlepaddle/paddle:2.1.3-gpu-cuda10.2-cudnn7 image, then I installed paddlepaddle-gpu, paddleocr and videocr-PaddleOCR. So I tried to run videocr like the Colab example, getting the following error:
ImportError: cannot import name 'shadow_var_between_sub_programs' from 'paddle.distributed.passes.pass_utils'
I fixed it by downloading the latest pass_utils.py from PaddleOCR repo, this way everything worked.
Issue 2:
Afterward I noticed that the OCR was performed via CPU, as nvidia-smi did not show active GPU usage and running the following returned False:
As I already installed the Nvidia Container Toolkit I tried to start a new container with the same image, to understand if the problem was within the image or from something else. So I did:
docker stop ppocr
docker container remove ppocr
docker image -a
docker image rm [ID]
sudo docker run --gpus all --name ppocr -v $PWD:/paddle --shm-size=64G --network=host -it paddlepaddle/paddle:2.1.3-gpu-cuda10.2-cudnn7 /bin/bash
I immediately tried to check for GPU usage with the python snippet above and it returned True. Next I installed videocr-PaddleOCR and checked again, this time it returned False.
Then I tried installing videocr-PaddleOCR on a newer docker image pulled from the Hub (paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6) and repeated the steps above, so I checked GPU after starting the container, after installing paddlepaddle-gpu, and after installing videocr, having the same results as before (but this time no ImportError) --> so running paddleocr alone works on GPU, after installing videocr it does not anymore...
As I do understand very little of everything programming-related, my solution (in order to have videocr on gpu) is as follows:
Start a docker container with paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6 as image
Clone this repo git clone https://github.com/devmaxxing/videocr-PaddleOCR and edit the requirements.txt file so that only includes:
Install python -m pip install . and run! Now it uses gpu (as running the first snippet returns True even after installing videocr).
Note:
I reached this conclusion by chance, but if I have to give a reasoning behind is the presence of paddlepaddle in the original requirements.txt file, as I noted paddlepaddle-gpu and paddlepaddle together return gpu usage as False regardless of docker image.
To be sure I only included all the missing dependencies: (i.e. on the clean docker image i installed paddlepaddle-gpu, then pip freeze and cross-checked to get everything that was missing from the original requirements.txt), and added paddleocr=2.7.0.2 due to #16 as using the latest paddleocr I encountered the same issue.
Note-bis:
Here is the code I used (as taken from Colab) to test videocr
Thanks for the heads up. For issue 1, I tested the GPU setup in Google Colab which uses paddlepaddle-gpu 2.5.1 from https://mirror.baidu.com/pypi/simple and did not have this issue. Do you have the exact paddlepaddle-gpu and paddleocr versions that was used when you encountered the pass_utils issue?
For issue 2, I have removed the paddlepaddle requirement from the setup.py script and renamed the requirements.txt file to requirements_cpu.txt to make it more clear.
Hi, I've wanted to use your program with docker on Linux but I had the following problems:
Issue 1:
Following PaddleOCR environment setup instructions I used the
paddlepaddle/paddle:2.1.3-gpu-cuda10.2-cudnn7
image, then I installedpaddlepaddle-gpu
,paddleocr
andvideocr-PaddleOCR
. So I tried to run videocr like the Colab example, getting the following error:I fixed it by downloading the latest
pass_utils.py
from PaddleOCR repo, this way everything worked.Issue 2:
Afterward I noticed that the OCR was performed via CPU, as
nvidia-smi
did not show active GPU usage and running the following returnedFalse
:As I already installed the Nvidia Container Toolkit I tried to start a new container with the same image, to understand if the problem was within the image or from something else. So I did:
I immediately tried to check for GPU usage with the python snippet above and it returned
True
. Next I installed videocr-PaddleOCR and checked again, this time it returnedFalse
.Then I tried installing videocr-PaddleOCR on a newer docker image pulled from the Hub (
paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6
) and repeated the steps above, so I checked GPU after starting the container, after installingpaddlepaddle-gpu
, and after installingvideocr
, having the same results as before (but this time no ImportError) --> so runningpaddleocr
alone works on GPU, after installing videocr it does not anymore...As I do understand very little of everything programming-related, my solution (in order to have videocr on gpu) is as follows:
paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6
as imagegit clone https://github.com/devmaxxing/videocr-PaddleOCR
and edit therequirements.txt
file so that only includes:python -m pip install .
and run! Now it uses gpu (as running the first snippet returnsTrue
even after installing videocr).Note:
I reached this conclusion by chance, but if I have to give a reasoning behind is the presence of
paddlepaddle
in the originalrequirements.txt
file, as I noted paddlepaddle-gpu and paddlepaddle together return gpu usage asFalse
regardless of docker image.To be sure I only included all the missing dependencies: (i.e. on the clean docker image i installed paddlepaddle-gpu, then
pip freeze
and cross-checked to get everything that was missing from the originalrequirements.txt
), and addedpaddleocr=2.7.0.2
due to #16 as using the latest paddleocr I encountered the same issue.Note-bis:
Here is the code I used (as taken from Colab) to test videocr
Note-last:
I wanted to thank you for this program as it helped me a lot, I wanted to share my experience as I lost some good few hours but now seem to be fixed.
The text was updated successfully, but these errors were encountered: