Closed psobolewskiPhD closed 1 year ago
Thanks for so much @psobolewskiPhD for going through the pain. I didn't realise that I forgot mention TF in the Readme. It is in the installation instructions, which is what I intended people to follow.
The problem with tensorflow is that the installation, especially with the GPU, can go easily wrong depending on the platform and it is better to follow the official TF tensorflow.
I will remove the pip install
from the readme and insist on the installation instructions.
On another note: we are moving away from TF and will have a napari-n2v that is PyTorch based next year.
@psobolewskiPhD Could you try a pip install -e .
on your mac with the current main branch? Does it install tensorflow-metal
? (install napari[all]==0.4.15 beforehand)
The napari pinned dependency sucks indeed, it is due to the fact that we wanted compatibility with napari-assistant. I am also not a fan of pinning this one down, so we will try to find another solution in the near future to maintain the compatibility and keep up with later versions.
Couple notes: tensorflow-macos
and tensorflow-metal
arn't arm64 specific, so you could just use darwin flags. See: https://pypi.org/project/tensorflow-macos/#files https://developer.apple.com/metal/tensorflow-plugin/
Also, just FYI pip install napari[all]
doesn't work on arm64 because pyqt5 doesn't have a pip wheel. Anyhow, in an conda-forge env with pyqt5 and imagecodecs everything works with:
pip install git+https://github.com/juglab/napari-n2v.git
Marginally slower than using Apple TF dependencies following the link above (~160 ms vs ~125 ms), so you may still want to mention that in the instructions.
Good to know, thanks again for keeping up with the project and sharing your macOS magic! I must admit that I am totally oblivious to how people do DL/napari on macOS and I didn't see anything on the napari website regarding pyqt5/macOS (probably my fault).
Also, just FYI
pip install napari[all]
doesn't work on arm64 because pyqt5 doesn't have a pip wheel. Anyhow, in an conda-forge env with pyqt5 and imagecodecs everything works with:pip install git+https://github.com/juglab/napari-n2v.git
I am not sure I follow. Do you do something along these lines ? :
conda create -n napari-n2v -c conda-forge python=3.9 napari pyqt5 imagecodecs
pip install git+[...]
, later with pip install napari-n2v
)And would this also be valid for x86? Or macOS x86 users should rather install napari
through pip?
Marginally slower than using Apple TF dependencies following the link above (~160 ms vs ~125 ms), so you may still want to mention that in the instructions.
What are you timing there ?
Sorry I wasn't clear. The two things that are missing arm64 from pypi are Qt5 (pyqt or pyside) and imagecodecs. In my experience everything else works. (Qt6 is on pypi, but still some issues in napari/vispy) So I normally make conda envs with those two from conda-forge. Making an env with napari from conda-forge works too, it should pull pyqt5. But yes, this should probably be better documented on napari.org—officially I think arm64 isn't supported.
For tensorflow, I normally setup the env using Apple instructions and then install napari (typically from conda-forge via mamba cause it's just faster), etc. But as noted above it's not needed to make the env using apple's channel. All of the instructions should work the same x86 or arm64.
Regarding the timing, when I run predict
I get this in the terminal:
2022-10-28 18:56:58.631369: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
1/1 [==============================] - 0s 138ms/step
Great, thanks a lot for the help!
One thing I forgot! the apple tensorflow-metal bit is only officially supported for macOS 12 and higher. It works on 11.x, in my experience, but some things are flakey.
I updated the installation instructions: https://juglab.github.io/napari-n2v/installation.html
I added the arm64 condition back in the setup.cfg, otherwise the tox tests fail during the CI with Github Actions. Once I will have time, I will try to figure out what happens.
Might be due to not-macOS 12? shrug
@jdeschamps I made a PR to fix conda-forge instructions. Plus add back tensorflow-metal. Tested locally and it all works, even without the apple env.
So my first go with this plugin was eventful: my napari got downgraded which broke some things (need to make a napari issue to prevent that) and then the demo widget didn't work (this is solved!). So I made a fresh env and installed there using pip following the instructions and that didn't work, traceback below. I guess the plugin doesn't specify tensorflow as a requirement and none the other requirements do either? 🤔 Either those requirements should be fixed—then the napari GUI installer can work—or the docs should be explicit about how to install. FYI: on macOS arm64 it works perfectly in a tensorflow env set up following Apple instructions: https://developer.apple.com/metal/tensorflow-plugin/ with a ~2x speedup using tensorflow-metal vs CPU only (tensorflow-macos).