Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: System.Runtime.InteropServices.SEHException: "External component has thrown an exception." - using PaddleDevice.Gpu() #107

Open
PavlikBender opened this issue Aug 13, 2024 · 4 comments

Comments

@PavlikBender
Copy link

PavlikBender commented Aug 13, 2024

Description

Today i've download your magnificent project. And I wrote sample from https://github.com/sdcb/PaddleSharp/blob/master/docs/ocr.md . It was worked perfectly, but very CPU demanding.
And I'm trying to start program using GPU but I have error here -> _paddleOcrAll.Run(src).Text;

System.Runtime.InteropServices.SEHException: "External component has thrown an exception."
в Sdcb.PaddleInference.Native.PaddleNative.PD_TensorCopyFromCpuFloat(IntPtr pd_tensor, IntPtr data)
   в Sdcb.PaddleInference.PaddleTensor.SetData(Single[] data)
   в Sdcb.PaddleOCR.PaddleOcrDetector.RunRaw(Mat src, Size& resizedSize)
   в Sdcb.PaddleOCR.PaddleOcrDetector.Run(Mat src)
   в Sdcb.PaddleOCR.PaddleOcrAll.Run(Mat src, Int32 recognizeBatchSize)
   в ScreTran.ExecutionService.PaddleOCRRecognize(Byte[] sampleImageData) в C:\Users\bbben\source\repos\ScreTran\Services\ExecutionService.cs:строка 131
   в ScreTran.ExecutionService.RecognizeTextAndTranslate() в C:\Users\bbben\source\repos\ScreTran\Services\ExecutionService.cs:строка 141
   в System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

BTW: I have Nvidia 4060 GPU. Maybe I need something else install except nuget packages?

Steps to reproduce the bug

Install latest nuget packages:
Sdcb.PaddleInference
Sdcb.PaddleInference.runtime.win64.cu120-sm86-89
Sdcb.PaddleOCR
Sdcb.PaddleOCR.Models.Local
OpenCvSharp4.runtime.win

Minimal program:

byte[] myPng = File.ReadAllBytes("..filename.png");

using var _paddleOcrAll = new PaddleOcrAll(LocalFullModels.EnglishV4, PaddleDevice.Gpu())
{
    AllowRotateDetection = false,
    Enable180Classification = false,
};

using var src = Cv2.ImDecode(myPng , ImreadModes.Color);
var resultText = _paddleOcrAll.Run(src).Text;

IDE

Visual Studio 2022

OS version

Windows 11

@PavlikBender
Copy link
Author

PavlikBender commented Aug 14, 2024

I've installed CUDA and cuDNN. It's already work with GPU. And how I understand I need to install TensorRT, but this page https://www.pythonf.cn/read/64495 unavailable.

@PavlikBender
Copy link
Author

@sdcb do the end user need to install CUDA and cuDNN? I've compiled sample project and send to my friend and program doesn't work. Friend doesn't install CUDA and cuDNN

@n0099
Copy link
Contributor

n0099 commented Aug 14, 2024

do the end user need to install CUDA and cuDNN?

Yes.

@PavlikBender
Copy link
Author

Yes.

That's very sad. I thought it compiles with all needed libs. I can't force end user download CUDA and cuDNN. Then only thing left is stay on CPU recognition :C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants