Enable GPU-accelerated computing

更新时间:
复制 MD 格式

GanosBase automatically enables GPU-accelerated computing when it detects a GPU — no configuration required. For Raster workloads that are compute-intensive or embarrassingly parallel, GPU acceleration delivers significantly higher throughput than CPU-based processing for the same operations.

How it works

GPU acceleration in GanosBase operates at the field object level. GanosBase converts a field object into a model suited for parallel computing, then distributes the workload across the GPU's multiple cores.

GPU acceleration is transparent — existing queries run unchanged and benefit automatically when a GPU is present.

Prerequisites

Before you begin, ensure that you have:

  • A PolarDB for PostgreSQL cluster with a GPU-equipped node

  • The ganos_raster extension installed, or access to create it

  • Access to a database session (for example, rasterdb)

Check GPU availability

  1. Create the ganos_raster extension:

    CREATE EXTENSION ganos_raster CASCADE;
  2. Run st_checkgpu() to verify whether a GPU is available:

    SELECT st_checkgpu();
    • GPU detected — GanosBase returns the GPU device properties:

      rasterdb=# SELECT st_checkgpu();
                                      st_checkgpu
      ------------------------------------------------------------------------------------------------------------------------------
       [GPU(0) prop]multiProcessorCount=20; sharedMemPerBlock=49152; totalGlobalMem=-608239616; maxThreadsPerBlock=1024; maxThreadsPerMultiProcessor=2048; cudaThreadGetLimit=1024 .
      (1 row)
    • No GPU detected — GanosBase returns an error message:

      rasterdb=# SELECT st_checkgpu();
                                 st_checkgpu
      ------------------------------------------------------------------------------------------------------------------------------------------
      There is not gpu device on current environment, cuda_errorcode=35, errormsg=CUDA driver version is insufficient for CUDA runtime version.
      (1 row)
GPU-accelerated computing can be enabled only in an environment where a GPU is available.

Control GPU acceleration at the session level

In a GPU environment, GanosBase enables GPU acceleration by default. The ganos.raster.use_cuda parameter controls this behavior per session.

ParameterTypeDefaultDescription
ganos.raster.use_cudaBooleanonEnables (on) or disables (off) GPU acceleration for the current session.

When to disable GPU acceleration: A single GPU has limited resources. When many sessions compete for GPU resources simultaneously, we recommend that you disable GPU acceleration at the session level for highly concurrent workloads.

Disable GPU acceleration:

SET ganos.raster.use_cuda = off;

Verify the change:

rasterdb=# SET ganos.raster.use_cuda = off;
SET
rasterdb=# SHOW ganos.raster.use_cuda;
 ganos.raster.use_cuda
-----------------------
 off
(1 row)

Re-enable GPU acceleration:

SET ganos.raster.use_cuda = on;

Verify:

rasterdb=# SET ganos.raster.use_cuda = on;
SET
rasterdb=# SHOW ganos.raster.use_cuda;
 ganos.raster.use_cuda
-----------------------
 on
(1 row)

Supported modules

GPU acceleration is currently available in the GanosBase Raster module. Support for the GanosBase Trajectory and GanosBase Geometry modules is planned for a future release.

Troubleshooting

GPU acceleration is not taking effect

If you suspect GPU acceleration is not active despite a GPU being present:

  1. Confirm the session parameter is set to on:

    SHOW ganos.raster.use_cuda;
  2. Confirm the ganos_raster extension is installed:

    SELECT * FROM pg_extension WHERE extname = 'ganos_raster';
  3. Confirm the GPU is still detected in the current environment:

    SELECT st_checkgpu();

If st_checkgpu() returns an error, the GPU is unavailable. Check that the CUDA driver version is compatible with the CUDA runtime version on the node.