mittagessen / kraken

OCR engine for all the languages
http://kraken.re
Apache License 2.0
673 stars 125 forks source link

lift pytorch restrictive version constraints #604

Closed drzraf closed 1 month ago

drzraf commented 1 month ago

conda-forge::pytorch~=2.1.0 sounds an overly restrictive version constraint.... Is it sure >=2.1.0 wouldn't work?

It's worth asking because each pytorch version pulls ~10GB of bundled CUDA libraries. Before requiring a very specific version, it's best to be sure no other one works as well. pytorch 2.4.0 is out and I wonder any would keep Kraken from working but a recent commit 51d593a51ee4b51af174fa4100da9ee59f661da1 downgraded from 2.2.0 to 2.1.0 :|

mittagessen commented 1 month ago

That's not going to happen. We've arrived at the current pinned dependencies because the random library combinations when not doing so regularly broke functionality. In particular, different pytorch versions can cause enormous (10x) differences in memory consumption and training divergence. You'll see that some dependencies are much less restricted. Those are for packages whose maintainers do not randomly break stuff.

pytorch 2.4.0 is out and I wonder any would keep Kraken from working but a recent commit https://github.com/mittagessen/kraken/commit/51d593a51ee4b51af174fa4100da9ee59f661da1 downgraded from 2.2.0 to 2.1.0 :|

Lightning officially only supports up to pytorch 2.2. But that one isn't on conda-forge yet. I can't maintain and keep track of different dependency sets for each packaging system.

drzraf commented 1 month ago

FYI I got it to work full-pip (no conda), using

It's indeed a very sensitive matters of version combinations (eg: shapely version breaking inference in non-obvious ways)

[Sadly, no model fits onto 2GB GPU... yet 😢]

bertsky commented 1 month ago

The problem with Torch 2.1 is that it still uses pkg_resources.packaging, which broke with setuptools v70.

What do you recommend we do?

mittagessen commented 1 month ago

They've pushed pytorch 2.3 onto conda-forge so I can bump up the version as soon as I've verified that everything works.

mittagessen commented 1 month ago

Hm, the issue is there isn't a lightning release that works with pytorch 2.3 yet and conda-forge never got a pytorch 2.2 release. I can pin setuptools below v70 if that helps.

bertsky commented 1 month ago

I can pin setuptools below v70 if that helps.

Yes, then that seems like the best compromise for now.

mittagessen commented 1 month ago

Yes, then that seems like the best compromise for now.

Ok, it's pinned now. I'll tag a new release once a couple of more bug fixes accumulate.