-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
imageio.plugins.freeimage.download() downloads wrong architecture on Apple Silicon #628
Comments
Disclaimer: Not a Mac user, so my Mac experience is limited. The helper script that downloads freeimage ( I think the solution here would be to add an ARM binary for Mac to the repo and to also check the user's processor architecture when selecting the download target. However, it would be good if somebody with Mac experience could comment on this as well :) |
Yeah, we've already improved this for ffmpeg by providing a separate repo+package for it, and we want to do the same for freeimage. Just a a lack of time. |
@irieger : I just came across this one, the Homebrew library worked just fine for me: |
Would love to have freeimage in my virtualenv sandbox rather than condo or brew. |
@sfjohnston Yes I think that can be done, but it will require a larger refactor. First off, for For freeimage to then run on M1, we would have to then create our own precompiled binaries and distribute them. This is - essentially - why others chose the brew/conda route because the packages there do that for you. So yes, it can happen (and should) happen. I can't tell you when though, because we core devs are currently busy solving other issues. That said if you - or someone else - would like to volunteer in spearheading this effort it will likely happen sooner than later. I will - of course - support you during that process :). |
Thank you for responding.
Had a few minutes this morning and got freeimage to compile for arm64, and
a universal one.
Started to do the work myself, but found a solution online that made things
easier.
- Downloaded FreeImage from sourceforge:
http://downloads.sourceforge.net/freeimage/FreeImage3180.zip
- Unzip and apply the attached patchfile. The origin of these changes is
from the following link, though I did create a different solution in the
Makefile.osx:
https://www.ultraengine.com/community/topic/59665-freeimage-build-errors/
- make
- copy the resulting dylib from Dist to ~/Library/Application
Support/imageio
- Note that imageio wants to download dylibs to a freeimage
subdirectory, but on my machine that folder is not in the library search
path, but the parent "imageio" directory is.
The quickest fix for imageio may be to incorporate this revised
patchfile in the build process for the binary file downloaded on osx by the
internal downloader. I haven't fully tested it with all image combinations,
but I was able to test on both intel and apple silicon to confirm it works
on both. Note that the universal binary can be compiled on either Apple
Silicon or Intel.
[macos_universal_fixes.diff.gz](https://github.com/imageio/imageio/files/7833730/macos_universal_fixes.diff.gz)
|
Interesting find @sfjohnston. I had a look at the diff and it all looks like reasonable changes; I can't test them further at the moment because I'm currently on a Windows machine. That said, the build should ultimately be done by GH Action runners, so once that exists I think we will add it there :) I'm actually not sure how we got the currently available macOS binaries. @almarklein, what has the process been so far? Depending on that, we might be able to build them the old way, add the binary to our suite, and close this issue for now. |
Copying the binaries from the freeimage sourceforge page :/ Ideally, as mentioned earlier in this issue, there would be a new project (called e.g. |
Can someone shed light on the current status? I tried a few of the suggested workarounds, but not all are working:
In summary, there are currently only some conda-based ways to get it to work, but not reliably. Is that correct, or am I missing something? Until there is a new approach, wouldn't it be easiest to simply amend the existing "download"-approach with a pre-compiled arm64 library? |
This is causing some drama on the latest macOs Github Actions runner currently. They have been updated to use macOS Sonoma sometimes last week and the freeimage library cannot be loaded properly now. Would not it make sense to update the current freeimage download to use an ARM library? The first M1 was released in November 2020 so it is probably about time to switch to ARM fully and drop x64 support? Cheers, Thomas |
The best way forward, imo, is to improve imageio-freeimage so that it posts platform specific wheels to pypi that each contain the appropriate freeimage library. Then in imageio, rely on A short-term fix is also possible, by:
I don't have any time to work on this, and I suspect @FirefoxMetzger has neither. But I can review pull requests. Is anyone interested in helping out with this? |
I agree with @almarklein . Having a wheel that ships the binary alongside it would be the best solution. The problem is that there currently isn't motivation to build this and FreeImage was last updated in 2018. I tried building this a while back (PR here); however, I hit a wall for MacOS. As it turns out, you have to tweak the FreeImage source to make things compile and this means we'd have to maintain a custom fork. I don't think there is enough community interest here to support this. Zooming out a bit, we have alternative readers for most formats that FreeImage supports today. Pillow covers the bulk of it and the rest will soon be covered by our new rawpy plugin (PR here). Since this will provide us with coverage of all supported formats, and considering the lack of development on the FreeImage side, the better thing to do would be to deprecate the FreeImage plugin. It will continue to exist in its standalone repo for those who want (or need) it, but removing it here would make it more difficult for unaware users to start depending on abandoned code - and it would not randomly break our (otherwise working) CI/CD pipeline. @almarklein Conda is building FreeImage for M1? I didn't know, but will have a look. If it provides working binaries I can make the PR to add logic for M1 vs x86 Macs.
It's true, I haven't had much time for dev work. I've been promoted last month (yay me 🎉) and have been busy transitioning between roles. |
@almarklein I just checked the conda files. There is indeed an arm64 version, but when I unpack it the resulting library is only 500kB in size. For comparison, all existing FreeImage libraries in |
Homebrew also ships it and we use it with It is certainly working on the new Sonoma runners from Github Actions. |
I uploaded Brew's version: imageio/imageio-binaries@4491157 |
Congratulations! |
Awesome! I will block some time towards the end of the week to modify the plugin to download a hardware-specific version on Apple. |
Hello,
I'm using python (3.9.2) on a Mac Mini M1 installed via conda as a native Apple Silicon/arm64 executable. When I install imageio and execute
The downloaded libfreeimage...dylib is for x64:
When executing, I don't get an error regarding the wrong architecture, but I can't open files like EXR which should require freeimage.
The text was updated successfully, but these errors were encountered: