Closed koaning closed 1 year ago
Oh, and to be clear, when I don't do os.environ["KERAS_BACKEND"] = "jax"
it totally seems to work fine.
I don't see this error on Colab...if possible, can you share a Colab where you've reproduced this error?
I don't see it on local either.
(keras_nlp_temp) abheesht@Abheeshts-MacBook-Air envs % pip install tensorflow torch jaxlib jax keras-core keras-nlp -q
(keras_nlp_temp) abheesht@Abheeshts-MacBook-Air envs % python3
Python 3.9.6 (default, May 7 2023, 23:32:44)
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ["KERAS_BACKEND"] = "jax"
>>> import keras_nlp
Using JAX backend.
Interesting, yeah I am betting this has to do with specific dev environment you have, as we can't just naively repro.
You are running on MacOS?
How are you install tensorflow-text? Or are you not?
What python environment? (pyenv, conda, nothing)
What version of keras-nlp and keras-core do you have? (e.g print(keras_nlp.__version__
)
Not really sure what would cause this, but hopefully with some more info we could get to the bottom.
My bad folks!
It seems that I was using a stale venv. I just removed the venv and reinstalled from scratch which does seem to remove the issue. I can't say for sure what exactly was the culprit here, but since it's clean from a fresh venv ... I'd say it's a false alarm.
Thanks for the quick response though!
Awesome, have fun with KerasNLP!
!pip install keras-nlp !pip install tensorflow --upgrade
Tf version: 2.14.0
ImportError Traceback (most recent call last)
4 frames
/usr/local/lib/python3.10/dist-packages/keras_nlp/src/layers/init.py in
ImportError: cannot import name 'CachedMultiHeadAttention' from partially initialized module 'keras_nlp.src.layers.modeling.cached_multi_head_attention' (most likely due to a circular import) (/usr/local/lib/python3.10/dist-packages/keras_nlp/src/layers/modeling/cached_multi_head_attention.py)
google colab 3.10.12 (sys.version)
Tried using
!pip install tensorflow torch jaxlib jax keras-core keras-nlp -q
as @abheesht17 suggested in comments, still the same error
The same issue happened to me on Google Colab, this fixes it for me as per @koaning mentioned, looks like a stale env. What I did was;
!pip uninstall keras keras-core keras-nlp
!pip install keras==2.15.0 keras-core==0.1.7 keras-nlp==0.6.3
And importing keras_nlp no longer shows that error, weird..
Describe the bug
I just installed jaxlib with keras core and figured I might give
keras_nlp
a spin.However, there seems to be a circular import error.
Additional context
I am using Python v3.9 on a M1 Mac.