 Running gemma model in Mac m2
@ahmednassar,
Looks like this issue is not related to Gemma Model. Instead of using **pip install tensorflow-macos==2.16.0**, could you please try using **pip install tensorflow** as mentioned in the document. 
https://github.com/tensorflow/tensorflow/releases

Thank you! Hi @tilakrayal ,

The venv has `tensorflow 2.16.0rc0` as shown in the below pip command. I think the problem in `tensorflow-text`, why it ignored `tensorflow` and ask for `tensorflow-macos`. Thanks in advance

```
pip show tensorflow
Name: tensorflow
Version: 2.16.0rc0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /Users/ahmednassar/Documents/learning/gemma/gemma_env/lib/python3.11/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, ml-dtypes, numpy, opt-einsum, packaging, protobuf, requests, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
``` From another perspective, why tensorflow-macos has no upgrade support keras 3.0.5? @tilakrayal  I have just tested `v2.16.0-rc0` on my Macbook (Apple M1 Pro) and apparently the statement that `tensorflow-macos` is no longer required, is not true. I observe the following error:

```
Fatal Python error: Illegal instruction
```

which normally would get fixed after installing `tensorflow-macos` explicitly. 

I'm wondering if these releases are tested after all. 

PS: Tested with Python 3.11 on macOS Sonoma 14.3.1 My Apple is M2, I'm not able to install `tensorflow-text` using pip nor local build as the following

```
pip install -U tensorflow-text==2.16.0rc0
ERROR: Could not find a version that satisfies the requirement tensorflow-text==2.16.0rc0 (from versions: none)
ERROR: No matching distribution found for tensorflow-text==2.16.0rc0
```

=========================
```
pip install ./tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
Processing ./tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
INFO: pip is looking at multiple versions of tensorflow-text to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin" (from tensorflow-text) (from versions: 2.12.0, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0)
ERROR: No matching distribution found for tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin"
``` > My Apple is M2, I'm not able to install `tensorflow-text` using pip nor local build as the following
> 
> ```
> pip install -U tensorflow-text==2.16.0rc0
> ERROR: Could not find a version that satisfies the requirement tensorflow-text==2.16.0rc0 (from versions: none)
> ERROR: No matching distribution found for tensorflow-text==2.16.0rc0
> ```
> 
> =========================
> 
> ```
> pip install ./tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
> Processing ./tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
> INFO: pip is looking at multiple versions of tensorflow-text to determine which version is compatible with other requirements. This could take a while.
> ERROR: Could not find a version that satisfies the requirement tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin" (from tensorflow-text) (from versions: 2.12.0, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0)
> ERROR: No matching distribution found for tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin"
> ```

Same issue here with Mac M2 chip. It says
```
Exception encountered: GemmaTokenizer requires the `tensorflow-text` package. Please install with `pip install tensorflow-text`
```

However, when I tried to install `tensorflow-text`, it says

```
ERROR: Could not find a version that satisfies the requirement tensorflow-text (from versions: none)
ERROR: No matching distribution found for tensorflow-text
```

Also, I am curious whether Gemma requires `tensorflow`. I have changed the backend to `torch` using `os.environ["KERAS_BACKEND"] = "torch"`. Why does it still require `tensorflow-text`? While we wait for TensorFlow-text to work with TF 2.16, you could try a workaround to use Gemma with TF 2.15.
```
# Install TensorFlow mac-os 2.15
# Install Tensorflow Text 2.15
pip install -U keras-nlp
pip install -U keras  # This needs to be the last one and will update keras to 3.0.5
```
Can you try these steps and see if that resolves the issue of using Gemma model from Keras-NLP? `tensorflow-text` is still having dependency on `tensorflow-macos `, this dependency will be changed to tensorflow and the new release of `tensorflow-text 2.16.2` will be made available with this patch.
Till then, continue using the workaround as suggested in the above comment. That doesn’t work, tensorflow 2.15 downgrade Keras (uninstall and reinstall Keres 2.15). Then I can’t install Keres 3.0.5 `tensorflow-text` 2.16.2 will most likely be released today and that should fix this issue. Actually, `tensorflow-text` is not available for Mac M1/M2. You could build your own using this blog - https://forums.developer.apple.com/forums/thread/700906

But at this time, we don't have it. Since its a dependency for KerasNLP, we will not be able to use Gemma in mac M1/M2 unless you can build from source for `tensorflow-text`. > `tensorflow-text` 2.16.2 will most likely be released today and that should fix this issue.

Thanks @sampathweb that fixed the issue, one small notice, the fix committed to master not 2.16.2. Thanks again

Please advice if we should close the close the issue? @ahmednassar , Please close the issue if you're issue is resolved. The problem have been fixed (here)[https://github.com/tensorflow/tensorflow/issues/63096#issuecomment-1994918684] and I'm able to run the following code in my M2 chip Apple

```
import keras
import keras_nlp
import numpy as np

gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_2b_en")
out = gemma_lm.generate("Keras is a", max_length=30)
``` Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63096">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/63096">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

2.15.0

### Custom code

Yes

### OS platform and distribution

Macos 14.3.1

### Mobile device

_No response_

### Python version

3.11

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

In order to run the following gemma code I need keras 3.0.5 and `tensorflow-text` which is not compatible with Keras 3.

`tensorflow-text` needs `tensorflow-macos<2.17,>=2.16` but there is no `tensorflow-macos>=2.16` as the following.

```
import keras
import keras_nlp
import numpy as np

gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_2b_en")
out = gemma_lm.generate("Keras is a", max_length=30)
```

```
pip install text/tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
Processing ./text/tensorflow_text-2.16.0rc0-cp311-cp311-macosx_11_0_arm64.whl
INFO: pip is looking at multiple versions of tensorflow-text to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin" (from tensorflow-text) (from versions: 2.12.0, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0)
ERROR: No matching distribution found for tensorflow-macos<2.17,>=2.16.0rc0; platform_machine == "arm64" and platform_system == "Darwin"
```

```
pip install tensorflow-macos==2.16
ERROR: Could not find a version that satisfies the requirement tensorflow-macos==2.16 (from versions: 2.12.0, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0)
ERROR: No matching distribution found for tensorflow-macos==2.16
```

### Standalone code to reproduce the issue

```shell
pip install tensorflow-macos==2.16
ERROR: Could not find a version that satisfies the requirement tensorflow-macos==2.16 (from versions: 2.12.0, 2.13.0rc0, 2.13.0rc1, 2.13.0rc2, 2.13.0, 2.13.1, 2.14.0rc0, 2.14.0rc1, 2.14.0, 2.14.1, 2.15.0rc0, 2.15.0rc1, 2.15.0)
ERROR: No matching distribution found for tensorflow-macos==2.16
```


### Relevant log output

_No response_