Deepdoctection OCR and its quirks - In need of assistants and a bigger brain

Note: I don’t know whether I’m in the right category or if this remotely is interesting to some of you, keep that in mind. Thanks :slight_smile:

Hey everybody,

I think this is gonna be my first post here, previously I was only running around the UnRaid and OPNsense forums but now I’ve found my way here, for a very specific reason:

Recently, through my Job but also through personal interest, I came across Deepdoctection as a method or rather a framework of methods to extract data from Documents and Images, such as PDF’s, Word Documents and etc.

Thus this is a framework, it requires quite the “set” of installed programs which is normal, tho still a challenge when we’re talking about 10 different installs and at least one virtual python environment plus a Ubuntu VM for it. Not complaining, just laying out the basics from a guy who’s still digging deeper and deeper into this “universe”.

So what’s my main issue?
One of the necessary requirements for this is Tensforflow and for that, for its best, you’re in need of a GPU, a NVIDIA GPU to be precise. So, you need the Driver, CUDA, cuDNN and, as an option, TensorRT for the GPU to work its best.
Why I’m telling you that?
Because the CUDA installation process throws out errors like I’m throwing out cereals in the morning, especially dpkg errors in terms of “can’t work this out” type of deal. (I’ll add screenshots in the coming days, my VM just died on me)

What I’m hoping is that someone, here, has similar experience or even worked with it, not just tensorflow but Extraction of Data in general.

I’m not new to Servers and stuff like this but I’m also not the expert in terms of “I’m a walking lexicon”.

So if we could start a discussion here, that’d be really nice. I think this would also be pretty interesting for others to watch along or even try it themselves.

Fun Fact:
Originally I came across the topic because the company I work, was paying for a solution that didn’t ultimately work but it sparked my interest in making something like this work - Both on Site or as a side project and better than a 5 figure paid solution. I guess we all are interested in Tech so I’m not alone with it. :smiley:

Note: I’m not doing this because my Job forces me to do it. Sure it would benefit or workflow but the main reason I’m pursuing it, is because It interests me for the same reason we all love EPYC CPU’s - It’s tech. And It would not surprise me to see Wendell taking in interest in it, from both the technical and software side. :wink:

So I hope this wasn’t to much of a rambling, I’m tired and sort of clueless on why it throws errors all the time.

Cheers, Alex’

EDIT: The Erros I was talking about are these ones here:

1 Like

Update: 1

Well, this is working less than expected. In the meantime I’ve tried both the GPU depended install method of choice and the one only using CPU’s - Nope, not working on my side.
Given all of the different versions needed for this, it’s quite frankly a “clusterfuck” to deal with.

I might be in need of good old “swarm-intelligence” here, cause I’m out of my luck for this one, as of now.

Cheers and Thank you, Alex’

How are you trying to install cuda in your base system? Because it should be doable by just using apt and ubuntu’s own repos for that with a simple apt install nvidia-cudnn nvidia-cuda-toolkit
LMK if that works for you, then we can try to solve this error or move on to the next issue

Hey y’all,
Sorry for the late reply, work got stressful.

So far I’ve been trying to install coda and cudnn through their own commands respectively following this: CUDA Toolkit 11.8 Downloads | NVIDIA Developer
and this: cuDNN Archive | NVIDIA Developer

I also tried, sort of, I believe the command you suggested but it always pulled the latest one and hence I need 11.8 for CUDA and 8.6.0 for cuDNN it isn’t doing what I need it to do.

As said before, I can also be my lack of knowledge.

Cheers and Thank you:)
Alex’

Update 1:

I’ve tried both the method Igor suggested (Deepdoctection OCR and its quirks - In need of assistants and a bigger brain - #3 by igormp) and many different others plus the direct method of using the instructions provided by NVIDIA.

TL:DR: Blackscreen, mismatched versions that make it impossible to run anything, completely bricked installs and so on and so forth. I don’t know why but as of now, the whole NVIDIA side of installing what’s needed for tensor flow and by extend deepdoctection, is impossible for me.
It also through an error of “libtinfo5” missing and I had to dig it up somewhere on the internet for it to be able to install CUDA, only after a reboot it was a black screen multiple times.

Not sure what’s up with all of that but yikes.

Cheers:)

Could you get into more details as to why the latest version doesn’t work for you?
As you have already found out, trying to use older versions is a pain and not really recommended, instead it’d be better to have your stack working on the latest version.

If you could give us a more detailed step-by-step of what you tried to do (from installing CUDA/Nvidia drivers, to your ML libraries and trying to run your software), along with the errors you faced, then we could try to figure out alternatives for each of those steps.

Yes, older versions or not the current ones are a pain a real pain. My issue is that I want to use Tensorflow and when you check the website, it says that is needs NVIDIA CUDA Toolkit 11.8 and cuDNN 8.6.0. TensorRT is optional but we’ll leave that out for now.
The reason It’s so frustrating that it doesn’t really matter how I install Tensorflow, it does not work.
I’ve tried it with a Python Virtual Environment, tried it in the Terminal etc. it does not wants to install it self and is displaying error.
(I’ll attach all my screenshots from not functioning installs at the End, as a little insight.)

Well this will be long but here we go:

  1. Setting up VM on UnRaid with Ubuntu 24.04 LTS
  2. Installing it with the recommended NVIDIA Proprietary Drivers (in my case 535)
    Why? Since I installed Ubuntu for like 15 times now, I came to the realization, after a lot of googling, the going lower doesn’t really work on 24.04 so I’m letting it install 535 on install anyway.
  3. Updating Ubuntu to the current state.
  4. Checking with the ‘nvidia-smi’, ‘nvtop’ and ‘nvcc --version’ commands, if the NVIDIA side of things is installed correctly
    Nvidia-smi usually works out of the box, hence it is installed with the Driver itself.
    nvtop needs to be installed separately and then works just fine.
    nvcc only works, if the CUDA-Toolkit is installed. Which is were the fun part starts:
  5. Tensorflow requieres NVIDIA CUDA Toolkit 11.8 which, based on this can be installed - Only Problem: when I run the command ‘sudo apt-get -y install cuda’ the errors are:
    "
    Errors were encountered while processing:

nvidia-dkms -520

cuda-drivers-520

cuda-drivers nvidia-driver-520

cuda-runtime- 11-8

cuda- 11-8

cuda-demo-suite- 11-8

cuda

E: Sub-process /us/bin/dpkg returned an error code (1)
"
It also throws errors in the process using dpkg which sometimes works and sometimes not. Weird.
6. The same is true for the cuDNN install: Using this and searching for 8.6.0 for 11.x, I download it and install it with gdebi or via Terminal - Result ?: As far as I can tell, it doesn’t work. The whole part of cuDNN is a bit of mystery to me cause I can’t get it to work either.
7. Round up: Everything else, when it comes to installing it, works. What throws me of is CUDA, CUDA Toolkit and cuDNN.

  1. Extra: Just for lols, I’m old yikes, I did try to install deepdoctection anyways regardless of the aforementioned errors and it did this:
    "
    Traceback (most recent call last):

File "/home/comcross/deepdoctection_env/lib/python3.12/site-packages/pip/_vendor/pypro 2vnc connec

main()

File "/home/comcross/deepdoctection_env/lib/python3.12/site-packages/pip/_vendor/pypro

Adressbuch

json_out[‘return_val’] = hook(**hook_input[‘kwargs’])

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/comcross/deepdoctection_env/lib/python3.12/site-packages/pip/_vendor/pypro

return hook(config_settings)

ЛАААААААААААААААААЛАЛ

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/buil

return self._get_build_requires(config_settings, requirements=)

АААААААААААААААААААААААААААААААААААААААААААААААААААААААААЛ

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/buil

self.run_setup ()

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/buil

exec (code, locals())

File “«string>”, line 288, in ‹module>

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_in

return distutils.core.setup(**attrs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_dis

return run_commands (dist)

^^^^^^^^^^^^^^^^^^

File "/ tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_dis

dist.run_commands ()

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_dis

self.run_command (cmd)

File "/ tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/dist

super ().run_ command (command)

File "/ tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_dis

cd.ban/ote-butld.en-165fuat:/overta/11b/prthon3.12/stte-packaces/setuptools/com

|VNC Server-Adresse eingeben oder suchen

server.local:5900

File "/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/commanu,

File “/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py”, line 550, in run self.add_defaults()

File “/ tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/command/egg_info.py”, line 588, in add_defaults sdist.add_defaults(self)

File “/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/command/sdist.py”, line 102, in add_defaults super ().add_defaults()

File “/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py”, line 250, in add_defaults self._add_defaults_ext()

File “/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/sdist.py”, line 335, in _add_defaults_ext self.filelist.extend(build_ext.get_source_files())

File “«string»”, line 204, in get_source_files

File “/tmp/pip-build-env-165fvmfz/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py”, line 107, in getattr raise AttributeError (attr)

AttributeError: cython sources

Tend of outputl

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

Getting requirements to build wheel did not run successfully. exit code: 1

See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. (deepdoctection_env) comcross@comcross:~$
"

I haven’t seen anyone here try to do anything with OCR or deepdoctection for that matter, so there’s no real thread for this as of know and no one who’s able to replicate this and that’s a bit of a bummer.

Anyway, I hope this helps a bit to understand how I’ve tried things lately. Also: This has been done on Ubuntu 22.04 & 24.04.

Cheers & Thank you,
Alex’










Looks like you followed a similar cuda setup as Wendell’s guide. If not this might be tangentially related, it’s written for pytorch, but if you are having trouble installing cuda this might be a alternate.

1 Like

TF ought to work with newer CUDA versions, take a look here:

Guess we found your issue, try to install the latest CUDA for your driver and then we can follow with getting a newer version of TF installed.

From your other errors, seems like you installed a really old TF version that was meant for python 2, hence why the errors with ( and whatnot lol

1 Like

Hey,

sorry for the late reply - Work got pretty stressful.

That’s actually a very interesting thread to begin with but one small problem: Wendell’s way of Installing of CUDA maybe has worked / works for him but not for me.


It does not work. Fun Fact: Somewhat similar to his method, I’ve tried one already - Did not work either. So I’ll try to find another

1 Like

That’s a odd error. If you just want to test inferences, can you use pytorch for CPU extraction instead? If the text extraction is good enough, then you can debug building cuda later.

On the topic of cuda, can you check that the nvidia proprietary drivers are installed? OP had it

The package not found error is related to not having the cuda repo

Also if you want to post the text as a code block ``` \n code output here \n ``` to make it easier you can use markdown formatting on discourse

1 Like

Did you add nvidia repos as he stated at the top of the guide?

# nvidia part 2
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo apt update

Anyhow, I would still recommend against doing it this way and just installing the regular nvidia-cuda-toolkit from the official repos.

(just saw that this was mentioned in the above post, but I had already written it, so eh lol)

1 Like

I did add the repos, at the beginning of Wendells Guide.
I stil happened the way it happened.

Tried your suggested method of using the drivers from the official repos and it worked like charm.

It pulled 535 automatically, I used “nvidia-cuda-toolkit” which pulled CUDA 12 and I installed cuDNN 9.2.0 through the commands listed on the NVIDIA Website.

I skipped the tensorflow thing for now and installed PyTorch, worked like a charm from the beginning on ward.
I’m taking on deepdoctection tomorrow, I’m tired.

Btw, on the flip side, what kinda hardware are u running for something like this?

Thanks in advance & best regards,
Alex

1 Like

Thanks for the tip, that will help in the future.

As written in the reply underneath here, I skipped tensorflow for now and did PyTorch with CUDA for now - Works. Deepdoctection will be a thing for tomorrow and I’ll see what that will bring up.

Btw: What kinda hardware are u running? Just out of curiosity

Thanks in advance and best regards,
Alex

1 Like

On my pc, I have a RTX 2070, 5800x3d, on Fedora 39. I use cuda for ollama.

If you want faster inference, you’ll definitely want to look into gpu acceleration/tensorflow/features

From the same page

1 Like

Oh, nice. I’m eyeing that CPU for Months now, my 3800X in my Desktop is a bit slow for Games and Stuff.

I’m aware of it, that’s why I wanted to go with Tensforflow in the first place, also their KERAS integration in the newer versions might come in handy too.

But just as a silly question in general: Why is PyTorch not as “good” as Tensforflow, given PyTorch can also run with CUDA ?

EDIT / UPDATE:
Since PyTorch requires Detectron2 for it to run, I followed the instructions on the Website, they provide. Then, I got this:


I’m gonna get lunch and see afterwards, what this is.

1 Like

Oh yeah I went from a 2700X to a 5800x3d. I tested my brother’s 3800X, but there was a massive jump in performance. If you are looking to upgrade, definitely keep an eye on micro center, r/buildapcsales, and ebay

Google was early on tensorflow and gpu development.

Iirc torch didn’t have as much cuda support until 2.0

These days it doesn’t matter as much of which framework/library you use. Most models support both

2 Likes

That’s great to hear!

I have a 5950x with 2x3090 in my personal desktop. For anything really intensive I jump into the cloud or make use of my uni’s A100 cluster. But that’s more relevant for training, for inference you can just go with a single, cheaper GPU.

Pytorch also works with GPU accel.

I don’t get where you got that conclusion from. At this point in time PyTorch is often the preferred framework for most stuff, since TF took way too long to adopt some newer stuff. Both are equally capable, it’s often just a matter of personal preference, but PyTorch managed to get a good grasp in the market.

You are running this code in an empty venv, with no previous dependencies. A pip install torch torchvision should fix this error you’re facing, but you’ll likely see other errors.

2 Likes

Oh neat

Does pytorch scale out for distributed computing? Because that looked like a distinguishing feature for Tensorflow?

1 Like

Yes:
https://pytorch.org/tutorials/beginner/dist_overview.html

2 Likes