QBoard » Artificial Intelligence & ML » AI and ML - Tensorflow » What does a tensorflow session exactly do?

What does a tensorflow session exactly do?

  • I have tensorflow's gpu version installed, as soon as I create a session, it shows me this log:

    I tensorflow/core/common_runtime/gpu/gpu_device.cc:885] Found device 0 with properties: name: GeForce GTX TITAN Black major: 3 minor: 5 memoryClockRate (GHz) 0.98 pciBusID 0000:01:00.0 Total memory: 5.94GiB Free memory: 5.31GiB I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN Black, pci bus id: 0000:01:00.0)

    And when I check my GPU memory usage, around 90% of it gets consumed.
    Tensorflow documentation does not say anything about this. Does it take control of the gpu ? Why does it consume most of the memory ?
      September 21, 2021 6:54 PM IST
    0
  • TensorFlow sessions allocate ~all GPU memory on startup, so they can bypass the cuda allocator.

    Do not run more than one cuda-using library in the same process or weird things (like this stream executor error) will happen.

      September 22, 2021 2:34 PM IST
    0
  • Session in TensorFlow. ... A session allows to execute graphs or part of graphs. It allocates resources (on one or more machines) for that and holds the actual values of intermediate results and variables.
      September 22, 2021 11:03 PM IST
    0
  • Session in TensorFlow. ... A session allows to execute graphs or part of graphs. It allocates resources (on one or more machines) for that and holds the actual values of intermediate results and variables.
      November 8, 2021 2:57 PM IST
    0
  • This encapsulation has nothing to do with OOP encapsulation. A slightly better (in terms of understanding for a new-comer) definition is in session documentation.

    A Session object encapsulates the environment in which Operation objects are executed, and Tensor objects are evaluated.

    Which means that none the operators and variables defined in the graph-definition part are being executed. For example nothing is being executed/calculated here

    a = tf.Variable(tf.random_normal([3, 3], stddev=1.)
    b = tf.Variable(tf.random_normal([3, 3], stddev=1.)
    c = a + b

     

    You will not get the values of a tensors a/b/c now. There values will be evaluated only inside of the Session.

     
      November 15, 2021 12:37 PM IST
    0