Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I import tensorflow (version 1.13.1) and need ConfigProto:

import tensorflow as tf  config = tf.ConfigProto(intra_op_parallelism_threads=8,     inter_op_parallelism_threads=8,     allow_soft_placement=True,device_count = {'CPU' : 1, 'GPU' : 1}) 

I get this error:

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

How do I resolve this?

like image 935
SteC Avatar asked May 14 '19 09:05

SteC


1 Answers

ConfigProto disappeared in tf 2.0, so an elegant solution is:

import tensorflow as tf 

and then replace:

tf.ConfigProto by tf.compat.v1.ConfigProto

In fact, the compatibility built in 2.0 to get tf 1.XX: tf.compat.v1 is really helpful.

Useful link: Migrate your tensorflow 1. code to tensorflow 2.: https://www.tensorflow.org/guide/migrate

like image 133
chabir Avatar answered Sep 22 '22 02:09

chabir