今天在运行tensorlow时,遇见报错:
module 'tensorflow' has no attribute 'config'
从网上查阅了大量资料,没有发现关于在tensorlow版本为1.X的改错教程,我把解决办法,发出来希望能帮大家节省点时间。
原代码为:
gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
把原代码换成下面代码即可:
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.compat.v1.Session(config=config)
如果帮助到了你,希望你能点个赞。
在TensorFlow 1.x版本中遇到`tensorflow'模块没有'config'属性`的错误。该博客提供了一种替代方法来设置GPU内存增长。将原有的代码替换为使用`tf.compat.v1.ConfigProto()`和`tf.compat.v1.Session()`来配置GPU内存。此解决方案可能对使用旧版TensorFlow并遇到类似问题的开发者有所帮助。
995

被折叠的 条评论
为什么被折叠?



