Tag Archives: Raise runtimeerror in tensorflow

Tensorflow Error raise RuntimeError(‘The Session graph is empty.  Add operations to the ‘ RuntimeError:

Raise runtimeerror (‘the session graph is empty. Add operations to the ‘

RuntimeError: The Session graph is empty.  Add operations to the graph before calling run().

This is when installing tensorflow, in order to test whether the installation is successful, and then use the online method, but there is an error when running the following code

import tensorflow as tf

import os

# os.environ [“TF_ CPP_ MIN_ LOG_ Level “] =’1 ‘# this is the default display level, displaying all information

os.environ [“TF_ CPP_ MIN_ LOG_ LEVEL”]=’2’

sess = tf.Session ()

a = tf.constant (2)

b = tf.constant (2)

print( sess.run (a+b))

At first, I suspected that my local problem, tensorflow, had not been completely downloaded. Later, baidu did not solve it. Then I thought whether there was an error in the installation process. The problem really lies here. After I created the tensorflow environment, I executed PIP install tensorflow The default download is version 2.0.0, but CONDA does not support it, so we need to see the tensorflow supported by CONDA before downloading

Version, execute the following command CONDA search — full – name tensorflow, as shown in the figure

Well, here we choose according to our Python version of tensorflow, and then execute

PIP install tensorflow = = 1. X.x