-
Notifications
You must be signed in to change notification settings - Fork 141
demo"movielens-1m-keras-with-horovo.py" run failed with "Exception: Optimizer type is not supported! got <class 'keras.src.optimizers.adam.Adam'>" #487
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
Comments
In the movielens-1m-keras folder under demo/dynamic_embedding, python movielens-1m-keras.py --mode=train --epochs=1 reports the same error. OS Env: centos 6.10 2025-04-03 17:50:15.477693: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:479] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered |
发现在/root/anaconda3/lib/python3.10/site-packages/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_optimizer.py 文件中判断的优化器是属于 Keras 2.x legacy 和 Keras 2.x 版本的优化器接口。 但demo里面import的优化器<keras.src.optimizers.adam.Adam>是属于 Keras 3.x版本的优化器,这个应该怎么解决? |
我换成了tf 2.15.1 ,tfra 0.7.0,能正常运行demo。 |
tensorflow 2.16.1 默认使用 keras 3,可以照下面方法使用 keras 2 试试 To continue using Keras 2.0, do the following. Install tf-keras via pip install tf-keras~=2.16 To switch tf.keras to use Keras 2 (tf-keras), set the environment variable TF_USE_LEGACY_KERAS=1 directly or in your python program with import os;os.environ["TF_USE_LEGACY_KERAS"]="1". Please note that this will set it for all packages in your Python runtime program Change the keras import: replace import tensorflow.keras as keras or import keras with import tf_keras as keras. Update any tf.keras references to keras. |
System information
above all are installed by "pip install tensorflow==2.16.2 tensorflow-recommenders-addons==0.8.0"
and reinstall horovod with "HOROVOD_WITH_TENSORFLOW=1 pip install --no-cache-dir horovod"
Describe the bug
[1,0]:Traceback (most recent call last):
[1,0]: File "/mnt/mfs/mfs6/cvr_tf_fm/code_complie/recommenders-addons-0.8.0/demo/dynamic_embedding/movielens-1m-keras-with-horovod/movielens-1m-keras-with-horovod.py", line 782, in
[1,0]: app.run(main)
[1,0]: File "/usr/local/lib/python3.9/site-packages/absl/app.py", line 308, in run
[1,0]: _run_main(main, args)
[1,0]: File "/usr/local/lib/python3.9/site-packages/absl/app.py", line 254, in _run_main
[1,0]: sys.exit(main(argv))
[1,0]: File "/mnt/mfs/mfs6/cvr_tf_fm/code_complie/recommenders-addons-0.8.0/demo/dynamic_embedding/movielens-1m-keras-with-horovod/movielens-1m-keras-with-horovod.py", line 770, in main
[1,0]: train()
[1,0]: File "/mnt/mfs/mfs6/cvr_tf_fm/code_complie/recommenders-addons-0.8.0/demo/dynamic_embedding/movielens-1m-keras-with-horovod/movielens-1m-keras-with-horovod.py", line 631, in train
[1,0]: optimizer = de.DynamicEmbeddingOptimizer(optimizer, synchronous=True)
[1,0]: File "/usr/local/lib/python3.9/site-packages/tensorflow_recommenders_addons/dynamic_embedding/python/ops/dynamic_embedding_optimizer.py", line 859, in DynamicEmbeddingOptimizer
[1,0]: raise Exception(f"Optimizer type is not supported! got {str(type(self))}")
[1,0]:Exception: Optimizer type is not supported! got <class 'keras.src.optimizers.adam.Adam'>
Primary job terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
Code to reproduce the issue
use this demo "https://github.com/tensorflow/recommenders-addons/blob/master/demo/dynamic_embedding/movielens-1m-keras-with-horovod/movielens-1m-keras-with-horovod.py" without any change
Other info / logs
run this demo with bash -x start.sh and detail info is as follow:
++ nvidia-smi --query-gpu=name --format=csv,noheader
++ wc -l
I also run with "python movielens-1m-keras-with-horovod.py --mode=train --model_dir=./model_dir --export_dir=./export_dir --steps_per_epoch=20000 --shuffle=True" and got the same error.
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
The text was updated successfully, but these errors were encountered: