Skip to content
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

Cannot Install on Mac Intel #5

Open
abadgerw opened this issue Nov 3, 2023 · 3 comments
Open

Cannot Install on Mac Intel #5

abadgerw opened this issue Nov 3, 2023 · 3 comments

Comments

@abadgerw
Copy link

abadgerw commented Nov 3, 2023

I tried following the Mac OSX instructions on MacBook Pro 2020 Intel (Running Monterey 12.7). I created an environment in Anaconda Navigator with Python 3.11.5 (I have tried with 3.8.18, 3.9.18, and 3.10.13), opened the new environment in the terminal, and then ran the following commands:

python -m pip install -U pip
python -m pip install "cellsparse-api[tensorflow-macos] @ git+https://github.com/ksugar/cellsparse-api.git"

I then got the following error:

ERROR: Ignored the following versions that require a different python version: 3.0.0 Requires-Python >=3.7, <=3.11
ERROR: Could not find a version that satisfies the requirement tensorflow-macos==2.12.0; extra == "tensorflow-macos" (from cellsparse-api[tensorflow-macos]) (from versions: none)
ERROR: No matching distribution found for tensorflow-macos==2.12.0; extra == "tensorflow-macos"

Any insight into what is going wrong?

@abadgerw abadgerw changed the title Cannot Install on Mac Cannot Install on Mac Intel Nov 3, 2023
@abadgerw
Copy link
Author

abadgerw commented Nov 3, 2023

@ksugar I did some more digging and I was able to install tensorflow-macos and tensorflow-metal via the following commands:

SYSTEM_VERSION_COMPAT=0 pip install tensorflow-macos
SYSTEM_VERSION_COMPAT=0 pip install tensorflow-metal

The following command then ran without error:

python -m pip install "cellsparse-api[tensorflow-macos] @ git+https://github.com/ksugar/cellsparse-api.git"

However, when I launch the server with this command:

uvicorn cellsparse_api.main:app

I get the following error:

2023-11-03 16:33:20.767709: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/bin/uvicorn", line 8, in
sys.exit(main())
^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/main.py", line 416, in main
run(
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/main.py", line 587, in run
server.run()
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve
config.load()
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/config.py", line 467, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/cellsparse_api/main.py", line 10, in
from cellsparse.runners import (
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/cellsparse/runners/init.py", line 2, in
from cellsparse.runners.stardist_runner import StarDistRunner
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/cellsparse/runners/stardist_runner.py", line 4, in
from stardist.models import (
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/stardist/models/init.py", line 3, in
from .model2d import Config2D, StarDist2D, StarDistData2D
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/stardist/models/model2d.py", line 8, in
from csbdeep.models import BaseConfig
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/csbdeep/models/init.py", line 5, in
import tensorflow
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/tensorflow/init.py", line 441, in
_ll.load_library(_plugin_dir)
File "/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/tensorflow/python/framework/load_library.py", line 151, in load_library
py_tf.TF_LoadLibrary(lib)
tensorflow.python.framework.errors_impl.NotFoundError: dlopen(/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 0x0006): Symbol not found: (OBJC_CLASS$_MPSGraphGRUDescriptor)
Referenced from: '/Users/waldmanad/opt/anaconda3/envs/cellsparse-api/lib/python3.11/site-packages/tensorflow-plugins/libmetal_plugin.dylib'
Expected in: '/System/Library/Frameworks/MetalPerformanceShadersGraph.framework/Versions/A/MetalPerformanceShadersGraph'

Any help you can provide so I can use your amazing plugin would be much appreciated!

@ksugar
Copy link
Owner

ksugar commented Nov 5, 2023

Hi @abadgerw, thank you for reporting the issue.
This error happens because tensorflow-macos and tensorflow-metal only support Mac computers with Apple silicon or AMD GPUs (see details here).
With your MacBook Pro 2020 Intel, you need to install the CPU version of tensorflow.

conda create -n cellsparse-api -y python=3.11
conda activate cellsparse-api
python -m pip install -U pip
python -m pip install "cellsparse-api[tensorflow] @ git+https://github.com/ksugar/cellsparse-api.git"

I have updated the instructions in README as below.
https://github.com/ksugar/cellsparse-api/tree/main#mac-osx-apple-silicon-or-amd-gpus

@abadgerw
Copy link
Author

abadgerw commented Nov 5, 2023

Thank you! This worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants