Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.99k stars 5.18k forks source link

Resolve numpy errors w/ MEASURE_RESONANCES #6399

Closed HumbleDeer closed 6 months ago

HumbleDeer commented 7 months ago

In lieu of issues like these: https://klipper.discourse.group/t/failed-to-import-numpy-module/4528/7

Supposedly, a recent version of Numpy changed the default implementation of BLAS from Atlas to OpenBLAS, causing the original documentation's installation of Atlas to be fruitless. The exact cause of what changed the default isn't clear to me as of now.

I added the libopenblas-base package which could be missing, causing the importing of numpy to fail when running MEASURE_RESONANCES or SHAPER_CALIBRATE commands. When it does fail on numpy because of this package, it was not very verbose about it.

I left the installation of Atlas in, because it doesn't seem to impact anything as of now.

For some reason, editing on Klipper3d/klipper submitted my patch branch on my fork of danger-klipper. Should be fine though, since there's no apparent other difference.

HumbleDeer commented 7 months ago

Testing needed

I'd like someone with a setup like this one to test whether installing the added OpenBLAS package AND removing the Atlas package still fixes the issue, or if removing the Atlas package breaks other things that still rely on it.

If removing it breaks other things, we might want to find other ways to get NumPy to use Atlas again that don't involve tons of complex update-alternatives commands.

More resources:

Choose whether NumPy uses OpenBLAS or Atlas: https://stackoverflow.com/questions/12249089/how-to-use-numpy-with-openblas-instead-of-atlas-in-ubuntu

OpenBLAS vs Atlas: https://stackoverflow.com/questions/17858104/what-is-the-relation-between-blas-lapack-and-atlas

cereal7802 commented 7 months ago

`root@voron2:~# apt list --installed|egrep -i "blas|atlas"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libblas3/oldstable,now 3.9.0-3+deb11u1 arm64 [installed,automatic] root@voron2:~# cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" `

Here is the output of my printer that has been setup for a little while and uses klipper with input shaper. I do not have the atlas package installed, although it is available for the distro. libopenblas-base is also available but not installed.

HumbleDeer commented 7 months ago

The package libopenblas-dev could be a possible candidate, as it's a metapackage for itself, libopenblas0, as well as some other things.

My debian12 can't find a package called libopenblas-base, though.

Digging for answers in the repos

The repository entry for libopenblas0-dev lists ´libopenblas0-baseas a dependency on Buster, but does not do so on Bullseye and Bookworm. Aptitude does not try to install it when I attempt to installlibopenblas0-dev` from the repositories.

https://packages.debian.org/buster/libopenblas-dev

dep: libopenblas-base (= 0.3.5+ds-3)

https://packages.debian.org/bullseye/libopenblas-dev

dep: libopenblas-pthread-dev or libopenblas-openmp-dev or libopenblas-serial-dev dep: libopenblas0 (= 0.3.13+ds-3+deb11u1)

https://packages.debian.org/bookworm/libopenblas-dev

dep: libopenblas-pthread-dev or libopenblas-openmp-dev or libopenblas-serial-dev dep: libopenblas0 (= 0.3.21+ds-4)

When looking at libopenblas0 (dependency), it has its own dependencies that are the same as the bullseye/bookwork libopenblas0-dev packages but the non-dev versions. https://packages.debian.org/bookworm/libopenblas0

dep: libopenblas0-pthread or libopenblas0-openmp or libopenblas0-serial

Conclusion

I suppose this determines that the packages have in fact changes since Buster, and that may be why NumPy by default now uses different packages?

In fact, yes. The packages have changed. In Bullseye, the libopenblas-base package was changed into a transitional metapackage and it was removed alltogether in Bookworm. Not surprising; Buster is ancient by now.

https://packages.debian.org/bullseye/libopenblas-base

This is a transitional dummy package, which can be safely removed.

Proposed solution

Do we need separate install instructions for Debian Buster and Debian Bullseye/Bookworm? Or do we finally deprecate Buster, if the packages using numpy, used by numpy and/or related to our software allow this?

HumbleDeer commented 7 months ago

@shiftingtech I'm tagging you as this may interest you and/or be more your jam? You also wrote the fix post in Discord for the bugged udev package

Do I convert this into an Issue, paste all info in the issue, and go from there?

github-actions[bot] commented 7 months ago

Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html

There are some steps that you can take now:

  1. Perform a self-review of your Pull Request by following the steps at: https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review If you have completed a self-review, be sure to state the results of that self-review explicitly in the Pull Request comments. A reviewer is more likely to participate if the bulk of a review has already been completed.
  2. Consider opening a topic on the Klipper Discourse server to discuss this work. The Discourse server is a good place to discuss development ideas and to engage users interested in testing. Reviewers are more likely to prioritize Pull Requests with an active community of users.
  3. Consider helping out reviewers by reviewing other Klipper Pull Requests. Taking the time to perform a careful and detailed review of others work is appreciated. Regular contributors are more likely to prioritize the contributions of other regular contributors.

Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available.

Best regards, ~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.