Tensorflow 2.0 – AttributeError: module ‘tensorflow’ has no attribute ‘Session’

According to TF 1:1 Symbols Map, in TF 2.0 you should use tf.compat.v1.Session() instead of tf.Session() https://docs.google.com/spreadsheets/d/1FLFJLzg7WNP6JHODX5q8BDgptKafq_slHpnHVbJIteQ/edit#gid=0 To get TF 1.x like behaviour in TF 2.0 one can run import tensorflow.compat.v1 as tf tf.disable_v2_behavior() but then one cannot benefit of many improvements made in TF 2.0. For more details please refer to the migration guide … Read more

Could not load dynamic library ‘cudart64_101.dll’ on tensorflow CPU-only installation

Tensorflow 2.1+ What’s going on? With the new Tensorflow 2.1 release, the default tensorflow pip package contains both CPU and GPU versions of TF. In previous TF versions, not finding the CUDA libraries would emit an error and raise an exception, while now the library dynamically searches for the correct CUDA version and, if it … Read more

How to prevent tensorflow from allocating the totality of a GPU memory?

You can set the fraction of GPU memory to be allocated when you construct a tf.Session by passing a tf.GPUOptions as part of the optional config argument: # Assume that you have 12GB of GPU memory and want to allocate ~4GB: gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) The per_process_gpu_memory_fraction acts as a hard upper bound … Read more