# Multiple GPU Utilization with API

## Initialization Through the C API

Initialization via the C API is performed using the VIDI_UNIT vidi_initialize(VIDI_INT gpu_mode, VIDI_STRING gpu_devices) argument.

GPU Mode gpu_mode | No GPU Support | Single Device per Tool
--- | --- | ---
Int value | -1 | 0
C Define | VIDI_GPU_MODE_NO_SUPPORT | VIDI_GPU_MODE_SINGLE_DEVICE_PER_TOOL

When processing with the following:

- vidi_runtime_process
- vidi_runtime_process_single_tool
- vidi_runtime_process_sample
- vidi_training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network._stream_process_sample
- vidi_training_tool_process_database
- vidi_training_process_sample

The GPU device selection is performed using the VIDI_STRING gpu_list argument.

GPU Device gpu_list | Default Value | Device List
--- | --- | ---
String value | " " | "0,1,2"
C Define | VIDI_AUTO_SELECT_GPU_DEVICE |
Description | Uses all of the available GPUs. | Only uses the specified GPUs (for example 0, 1 and 2).

## Initialization Through the .NET API

When creating a new control using one of the following:

- ViDi2.Runtime.Local.Control (ViDi2.GpuMode gpuMode, List<int> gpuDevice)
- ViDi2.Runtime.Local.Control (LibraryAccess libraryAccess, ViDi2.GpuMode gpuMode, List<int> gpuDevices, bool activateDebugLogging)
- ViDi2.Training.Local.Control (ViDi2.GpuMode gpuMode, List<int> gpuDevice)
- ViDi2.Training.Local.Control (LibraryAccess libraryAccess, ViDi2.GpuMode gpuMode, List<int> gpuDevices, bool activateDebugLogging)

GPU Mode | ViDi2.GpuMode gpuMode
--- | ---
Single Device per Tool (default) | GpuMode.SingleDevicePerTool
No GPU Support | Gpu.Mode.NoSupport

When processing with the following:

- ViDi2.Runtime.ITool.Process
- ViDi.Runtime.IStream.Process
- ViDi2.Training.ITool.Process
- ViDi.Training.IStream.Process
- ViDi2.IDatabase.Process

The device selection is performed through the List<int> gpuDevices argument.

List<int> gpuDevices | Default Value | Device List
--- | --- | ---
Value | null | new List<int> {0,1}
Description | Uses all of the available GPUs. | Only uses the specified GPUs (for example 0 and 1).