# GPU Quickstart

*This page shows how to load the GPU module, move data to and from the GPU, and run queries.*

## Setup

To use the GPU module, you need:

1. A GPU-enabled environment with CUDA 13.1. Refer to [GPU Setup](./gpu-env.md).
2. KDB-X installed with a GPU-enabled license. Refer to [KDB-X Setup](./kdb-env.md).

## Basic usage

The following example moves a table to the GPU, runs a VWAP, and retrieves the result.

1. Run the following in your KDB-X session to load the module and move a table to the GPU:
    ```q
    q).gpu:use`kx.gpu  / load the module
    q)N:10000000
    q)trade:([]time:.z.d+N?0D;sym:N?`3;price:N?1f;size:1+N?100)
    q)Trade:.gpu.to trade
    q)Trade
    +`time`sym`price`size!(foreign;foreign;foreign;foreign)
    ```

2. Run a VWAP calculation on CPU vs GPU. The times shown are in milliseconds - the GPU is approximately 4.5x faster in this example:
    ```q
    q)\t:100 r:?[trade;();([sym:`sym]);enlist[`vwap]!enlist (%;(sum;(*;`size;`price));(sum;`size))]
    4405
    q)\t:100 R:.gpu.select[Trade;();([sym:`sym]);enlist[`vwap]!enlist (%;(sum;(*;`size;`price));(sum;`size))]
    981
    ```

3. Move a table to the CPU (from device to host):
    ```q
    q)r~`sym xasc .gpu.from R
    1b
    ```

## Next steps

- Explore the [GPU Examples](../examples.md) page for more detailed usage.
- Refer to the [GPU Reference](../reference.md) page for a full API reference.
- Visit the [Troubleshooting Errors](../troubleshooting-errors.md) page if you encounter issues.
