<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/framework/ops.py#L4409-L4442) |

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
    ) -> ContextManager[None]

See [`tf.Graph.device`](https://www.tensorflow.org/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 />