Skip to content

Try to change backend to ‘torch’, but still 'tensorflow'. #19542

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

Closed
ranck626 opened this issue Apr 18, 2024 · 1 comment
Closed

Try to change backend to ‘torch’, but still 'tensorflow'. #19542

ranck626 opened this issue Apr 18, 2024 · 1 comment
Assignees
Labels
Gemma Gemma model specific issues

Comments

@ranck626
Copy link

ranck626 commented Apr 18, 2024

I only download torchs and i do not have tensorflow.
I had thought it was a matter of not successfully modifying the backend. But I found out through the output that the modification was successful. It seems that some functions inside keras-nlp are written using tensorflow. I'm guessing this is the issue and would appreciate your attention and answers.
torch 2.1.0
torchaudio 2.1.0
torchvision 0.16.0
cuda11.8/toolkit/11.8.0
cudnn8.5-cuda11.8/8.5.0.96

/home/name/.keras/keras.json
I try KERAS-HOME and KERAS-BACKEND
{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "torch",
"image_data_format": "channels_last"
}
from keras import backend as K
print(K.backend()) # torch

maybe the key is keras-nlp

Traceback (most recent call last):
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/backend/config.py", line 21, in detect_if_tensorflow_uses_keras_3
from tensorflow import keras
ModuleNotFoundError: No module named 'tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/name/codes/gemma_demo.py", line 11, in
import keras_nlp
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/init.py", line 8, in
from keras_nlp import layers
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/layers/init.py", line 8, in
from keras_nlp.src.layers.modeling.alibi_bias import AlibiBias
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/init.py", line 23, in
from keras_nlp.src import layers
File "/home/xuzichao/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/layers/init.py", line 15, in
from keras_nlp.src.layers.modeling.cached_multi_head_attention import (
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/layers/modeling/cached_multi_head_attention.py", line 15, in
from keras_nlp.src.api_export import keras_nlp_export
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/api_export.py", line 17, in
from keras_nlp.src.backend import keras
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/backend/init.py", line 29, in
from keras_nlp.src.backend import config
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/backend/config.py", line 38, in
_USE_KERAS_3 = detect_if_tensorflow_uses_keras_3()
File "/home/name/miniconda3/envs/huaxin/lib/python3.10/site-packages/keras_nlp/src/backend/config.py", line 27, in detect_if_tensorflow_uses_keras_3
raise ValueError(
ValueError: Unable to import keras with tensorflow. Please check your Keras and Tensorflow version are compatible; Keras 3 requires TensorFlow 2.15 or later. See keras.io/getting_started for more information on installing Keras.

@github-actions github-actions bot added the Gemma Gemma model specific issues label Apr 18, 2024
@sampathweb
Copy link
Collaborator

@ranck626 - Please open the issue in keras_nlp repo - https://github.com/keras-team/keras-nlp

Also, keras_nlp uses TensorFlow for preprocessing of text, so its a requirement for preprocessing even if your backend for model is torch.

Closing this issue now. Please open in keras_nlp if its still a issue.

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

No branches or pull requests

3 participants