# tf.device

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/device) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/framework/ops.py#L5108-L5141) |

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

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.device(
        device_name_or_function
    )

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