# tf.compat.v1.device

<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/ops.py#L5031-L5064) |

Wrapper for [`Graph.device()`](https://www.tensorflow.org/api_docs/python/tf/Graph#device) using the default graph.

    tf.compat.v1.device(
        device_name_or_function
    )

See [`tf.Graph.device`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Graph#device) for more details.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `device_name_or_function` | The device name or function to use in the context. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A context manager that specifies the default device to use for newly created ops. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `RuntimeError` | If eager execution is enabled and a function is passed in. |

<br />