<a id="exp-gpu-interface"></a>

# GPU interface

<!-- @artefact GPU interface -->

The GPU interface
enables GPU pass-through
(direct access to the host system’s GPUs)
inside the workshop
to improve the performance of GPU-intensive applications.

By using the interface,
the SDK publisher allows the workshop to directly access the host’s GPU devices,
which may be required for various GPU-intensive workloads.

<a id="exp-gpu-plug"></a>

## GPU interface plug

An essential element here is the GPU interface plug,
which is declared in the SDK definition.

Its structure includes just the name of the plug and the interface;
both must be set to `gpu`.

Defining the plug in an SDK
allows the workshops using this SDK to directly access the host’s GPU devices,
which may be required for various GPU-intensive workloads.

<a id="exp-gpu-slot"></a>

## GPU interface slot

To let SDKs in a workshop access the host’s GPUs,
**Workshop** provides a GPU interface slot
that multiple GPU interface plugs can access.

When the SDK is installed at runtime during launch and refresh operations,
**Workshop** checks that the plug targeting the slot
passes [validation](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interfaces-validation);
if it does,
it can be connected.

## Connection

The interface is connected automatically at launch or refresh,
provided that the plug can be matched to the slot by its name
or via a `connections` entry in the [definition](https://ubuntu.com/workshop/docs//explanation/workshops/concepts.md#exp-workshop-definition),
both subject to **Workshop**’s
[validation rules](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interfaces-validation).

After the workshop has started,
the **workshop connect** and **workshop disconnect** commands
can be used to manage the connection manually.

Establishing a connection means
the host’s GPUs are directly available inside the workshop
via the GPU pass-through mechanism.

To check if the interface is connected:

<!-- @artefact workshop connections -->
```console
$ workshop connections --all

  INTERFACE  PLUG            SLOT           NOTES
  ...
  gpu        ws/gpu-sdk:gpu  ws/system:gpu  -
```

This means the host’s GPUs are directly available inside the workshop:

<!-- @artefact workshop shell -->
```console
$ workshop shell ws
workshop@ws-8584e571$ ls -h /dev/dri/

  card0  renderD128

workshop@ws-8584e571$ nvidia-smi
```

## See also

Explanation:

- [Interface concepts](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-interface-concepts)
- [Plugs and slots](https://ubuntu.com/workshop/docs//explanation/interfaces/concepts.md#exp-plugs-slots)
- [SDK definition](https://ubuntu.com/workshop/docs//explanation/sdks/concepts.md#exp-sdk-definition)
- [Workshop definition](https://ubuntu.com/workshop/docs//explanation/workshops/concepts.md#exp-workshop-definition)

Reference:

- [workshop connect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connect)
- [workshop connections](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-connections)
- [workshop disconnect](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-disconnect)
- [workshop launch](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-launch)
- [workshop refresh](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-refresh)
- [workshop shell](https://ubuntu.com/workshop/docs//reference/cli/workshop.md#ref-workshop-shell)
