toni-heittola / dcase2020_task1_baseline

DCASE2020 Challenge Task 1 baseline system
MIT License
25 stars 22 forks source link

AttributeError: module 'tensorflow' has no attribute 'ConfigProto' #5

Closed dby124 closed 3 years ago

dby124 commented 4 years ago

when I run task1a, it reported the following error

[E] Uncaught exception (logging.py:221) Traceback (most recent call last): File "task1a.py", line 1297, in sys.exit(main(sys.argv)) File "task1a.py", line 206, in main processed_items = do_learning( File "task1a.py", line 680, in do_learning dcase_util.keras.setup_keras( File "/root/anaconda3/lib/python3.8/site-packages/dcase_util/decorators/decorators.py", line 14, in call return self.f(*args, **kwargs) File "/root/anaconda3/lib/python3.8/site-packages/dcase_util/keras/utils.py", line 302, in setup_keras config = tf.ConfigProto( AttributeError: module 'tensorflow' has no attribute 'ConfigProto'

Package version: dcase_util 0.2.12 / dcase_util 0.2.16 keras 2.4.3 tensorflow 2.3.1 Python 3.7.4

I found that it may caused by the mismatched package version, so I installed tensorflow==1.14.0. And then another error was reported. It is shown as following: Traceback (most recent call last): File "task1a.py", line 1297, in sys.exit(main(sys.argv)) File "task1a.py", line 211, in main overwrite=overwrite File "task1a.py", line 860, in do_learning shuffle=param.get_path('learner.parameters.fit.shuffle') File "/usr/local/python3/lib/python3.7/site-packages/keras/engine/training.py", line 1178, in fit validation_freq=validation_freq) File "/usr/local/python3/lib/python3.7/site-packages/keras/engine/training_arrays.py", line 200, in fit_loop callbacks._call_batch_hook('train', 'begin', batch_index, batch_logs) File "/usr/local/python3/lib/python3.7/site-packages/keras/callbacks.py", line 84, in _call_batch_hook batch_hook = getattr(callback, hook_name) AttributeError: 'ProgressLoggerCallback' object has no attribute 'on_train_batch_begin'

I also tried other suggestions for these problems, but it can't be solved. I appreciate if you can give me some suggestions.

toni-heittola commented 3 years ago

The baseline system was originally developed for TensorFlow v1.x. You were using v2.3.1, which has a slightly different API. The error is coming from the dcase_util library which currently has utilities only for TensorFlow v1.x. Utilities for TensorFlow v2.x will be finally released in the upcoming version v0.2.17 of this library shortly.

The error coming after you downgraded to TensorFlow v1.14.0 is caused by the mismatched Keras version. The attributes such as on_train_batch_begin were introduced to Keras callbacks in v.2.2 and dcase_util versions <= 0.2.16 work only with Keras <= 2.1.x.

andres-fr commented 3 years ago

Just a couple of minor updates as for May 2021:

The error above is triggered if someone (oops) installs the requirements.txt from a fresh conda environment. Those aren't meant for that case, right? The conda instructions should be followed instead. Still, there were a couple of changes I needed to make to get it up: Librosa needed the forge channel and libsndfile was missing:

conda install -c conda-forge librosa
conda install -c conda-forge libsndfile 

That is for task 1b. For task 1a, OpenL3 was also further required, with numpy >=1.17.3. The following fixed it for me:

pip install numpy==1.17.3
pip install openl3

Tested on a fresh 3.6 conda environment, Linux server with Nvidia driver 450 and worked like a charm.

Anyway, it seems that pip installing dcase_util already upgrades the conda librosa, so maybe that one could be dropped altogether.

Cheers,
Andres