Article directory
Preface
Recently, I wanted to try PaddleOCR's C++ reasoning, but the process was not as good as expected. In addition to many problems, let's talk about the key points here!
1. Environmental preparation
1. Main environment
The environment here refers to some basic environments used by our GPU or CPU, such as CUDA, cudnn, trt, etc. Here I choose to use the official docker image . After entering, just select the version you want. It is recommended to use the latest version. Go back 1-2 versions, this will be more stable and everyone will understand it, as shown below:
2. Source code download
Here you can directly go to github to download the source code .
3. C++ reasoning library download
You can compile this yourself, but be prepared for crashes and various git timeouts. However, if you know how to surf the Internet scientifically, there is no big problem. I will go directly to the official documentation to find the corresponding platform (such as win or linux ) . , when selecting the version here, pay attention to match it with the basic environment you selected in 1.1, as shown below:
select the version in the upper left corner, then select the platform, and then select the corresponding inference library based on whether it is a CPU or a GPU. Note: For math libraries, it is recommended to use MKL.
2. Error message
After the environment is set up, start docker. You can consider mounting the source code and inference library directly, and then follow the md document in PaddleOCR/deploy/cpp_infer step by step. The bugs encountered during the compilation process are as follows
1. Static library calling error
The error is reported as shown below:
This is most likely because there is no libcudnn.so in the cudnn directory given in CmakeLists.txt (or tools/build.sh). You can use the following command to view the specific location of libcudnn.so:
find / -iname "*libcudnn.so*"
Then replace the path of cudnn in CMakeLists.txt (or tools/build.sh).
2.ld returned 1 exit status
The detailed error report is as follows:
You can try the following solutions:
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -o3 ${FLAG_OPENMP} -std=c++11")
Change -o in CMakeLists.txt to -O -
Check whether DWITH_GPU is ON and DWITH_STATIC_LIB is OFF in your tools/build.sh.
Here, I feel that I downloaded the image with GPU, but set DWITH_GPU to OFF during compilation. The normal compilation results are as follows:
Summarize
The above is the entire content of this article. If there are any questions, please feel free to correct them in the comment area.