# tf.config.experimental.get_memory_usage

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/framework/config.py#L644-L680) |

Get the current memory usage, in bytes, for the chosen device. (deprecated)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.config.experimental.get_memory_usage`](https://www.tensorflow.org/api_docs/python/tf/config/experimental/get_memory_usage)

<br />

    tf.config.experimental.get_memory_usage(
        device
    )

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.config.experimental.get_memory_info(device)\['current'\] instead.

This function is deprecated in favor of
[`tf.config.experimental.get_memory_info`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/config/experimental/get_memory_info). Calling this function is equivalent
to calling `tf.config.experimental.get_memory_info()['current']`.

See <https://www.tensorflow.org/api_docs/python/tf/device> for specifying device
strings.

#### For example:

    gpu_devices = tf.config.list_physical_devices('GPU')
    if gpu_devices:
      tf.config.experimental.get_memory_usage('GPU:0')

Does not work for CPU.

For GPUs, TensorFlow will allocate all the memory by default, unless changed
with [`tf.config.experimental.set_memory_growth`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/config/experimental/set_memory_growth). This function only returns
the memory that TensorFlow is actually using, not the memory that TensorFlow
has allocated on the GPU.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `device` | Device string to get the bytes in use for, e.g. `"GPU:0"` |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Total memory usage in bytes. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | Non-existent or CPU device specified. |

<br />