Using GPUs
Zigma use native webgpu to automatically perform calculation on GPU.
I tried to make it as simigless as possible but you will still need to keep some principals in mind.
Seting up GPU Tensor
This use as like for types.
a = 1 as gpu
b = 1 as i32 gpu
Work with area too.
as gpu:
a = 1
Gpu Limitation
Types
Currently GPU Tensors are limited to f32, f16, i32 and u32 types.
Default to f32.
No print, input or output
A GPU Tensor will only live on GPU. To print, input or output a GPU Tensor, you need to load it into CPU:
a = 1 as gpu
b = a as cpu
cpu_input = input "tensor_in"
gpu_tensor = cpu_input as gpu
cpu_read = gpu_tensor as cpu
output cpu_read "tensor_out"
No operation between CPU and GPU
Those are distinct, you need to load it to either GPU or CPU with as cpu and
as gpu.
VRAM Limits
By default VRAM usage is limited to 2GB.
It can be change with --vram-limits 10737418200 (number of bytes).
Or with proper naming --vram-limits 10GB.
TODO
- Add a CLI flag to chose device