基础环境:Anaconda、Keras、tensorflow
问题
报错:
AttributeError: module 'tensorflow_core._api.v2.config' has no attribute 'experimental_list_devices'
原因
定位到 tensorflow_backend.py 这个源文件的第506行,提示没有experimental_list_devices
解决
根据报错提示的路径,找到 tensorflow_backend.py 源文件的第506行,将
_LOCAL_DEVICES = tf.config.experimental_list_devices()
改为
devices = tf.config.list_logical_devices()
_LOCAL_DEVICES = [x.name for x in devices]
完美解决!
参考: