How to get the SESSION from the GPU system in TF-2.14.X

I’m new to ML/tensorflow. Recently, TensorFlow released the new version 2.14.x with pip install tensorflow[and-cuda]. The below codes are not working after installing this package.

Anyone help me to provide the solution?

gpuops=tf.GPUOptions
tf.Session(cf=tf.ConfigProto(gpu_options=gpuops, log_device_placement=False))

Thanks
Sadheesh

Hi @Sadheesh_S

tf.ConfigProto() Api and tf.session are used in TF 1.x and are deprecated to use in TF 2.x. This is the reason these api are not working in TF 2.x.

You can use below code in TF 2.x for the same:

#To list all gpus
gpus = tf.config.list_physical_devices('GPU')

# Restrict TensorFlow to only use the first GPU
tf.config.set_visible_devices(gpus[0], 'GPU')

Please refer to the link to have fine grained control of GPU using TensorFlow.