Categories
Misc

`set_session` is not available when using TensorFlow 2.0.

Hi All.

I am using Keras and Tensorflow 2.0. I have code that tries to
set the number of inter and intra op threads. I have added the
session stuff for compatability, but it still won’t work right.

from keras import backend as K

….

….

import tensorflow as tf

session_conf =
tf.compat.v1.ConfigProto(inter_op_parallelism_threads=int(os.environ[‘NUM_INTER_THREADS’]),

intra_op_parallelism_threads=int(os.environ[‘NUM_INTRA_THREADS’]))

sess =
tf.compat.v1.Session(graph=tf.compat.v1.get_default_graph(),
config=session_conf)

K.set_session(sess)

Then it blows up with:

RuntimeError: `set_session` is not available when using
TensorFlow 2.0.

Any advice?

submitted by /u/dunn_ditty

[visit reddit]

[comments]

Leave a Reply

Your email address will not be published.