module ‘tensorflow‘ has no attribute ‘config‘

时间:2025-04-08 21:33:37

今天在运行tensorlow时,遇见报错:

module 'tensorflow' has no attribute 'config'

从网上查阅了大量资料,没有发现关于在tensorlow版本为的改错教程,我把解决办法,发出来希望能帮大家节省点时间。

原代码为:

gpus = .list_physical_devices(device_type='GPU')
for gpu in gpus:
    .set_memory_growth(gpu, True)

把原代码换成下面代码即可:

config = .()
config.gpu_options.allow_growth = True
sess = .(config=config)

如果帮助到了你,希望你能点个赞。