All Products
Search
Document Center

PolarDB:Enable GPU-accelerated computing

Last Updated:Feb 20, 2024

Due to the special hardware architecture, a GPU has great advantages over a CPU in processing computing-intensive and embarrassingly parallel workloads.

How the acceleration works

In a database, GPU-based parallel acceleration is performed at the object level. Ganos converts a field object to a model suitable for parallel computing, and uses the multiple cores of the GPU for parallel computing.

Usage notes

A single GPU has limited resources. To process highly concurrent workloads, we recommend that you disable GPU-accelerated computing at the session level.

Procedure

When Ganos detects a GPU, Ganos automatically enables GPU-accelerated computing. You do not need to configure any parameters. GPU-accelerated computing is transparent and imperceptible to you. In addition, Ganos allows you to enable or disable GPU-accelerated computing at the session level.
  1. Check whether a GPU is available in the current environment.
    1. Execute the create extension ganos_raster cascade statement to create a ganos_raster extension.
    2. Execute the select st_checkgpu() statement.
      • If Ganos detects a GPU in the current environment, Ganos returns the GPU information.
        rasterdb=# select st_checkgpu();
                            st_checkgpu                                                                                       
        ------------------------------------------------------------------------------------------------------------------------------
         [GPU(0) prop]multiProcessorCount=20; sharedMemPerBlock=49152; totalGlobalMem=-608239616; maxThreadsPerBlock=1024; maxThreadsPerMultiProcessor=2048; cudaThreadGetLimit=1024 .
        (1 row)
      • If Ganos does not detect a GPU in the current environment, Ganos 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)
      Note GPU-accelerated computing can be enabled only in an environment where a GPU is available.
  2. Enable or disable GPU-accelerated computing at the session level.
    • In an environment where a GPU is available, Ganos enables GPU-accelerated computing by default. If you want to use the original CPU computing mode, run the set ganos.raster.use_cuda=off command in a session.

      rasterdb=# set ganos.raster.use_cuda=off;
      SET
      rasterdb=# show ganos.raster.use_cuda;
       ganos.raster.use_cuda 
      -----------------------
       off
      (1 row)
    • To enable GPU-accelerated computing again, run the set ganos.raster.use_cuda=on command.
      rasterdb=# set ganos.raster.use_cuda=on;
      SET
      rasterdb=# show ganos.raster.use_cuda;
       ganos.raster.use_cuda 
      -----------------------
       on
      (1 row)
  3. Implement GPU-accelerated computing in a Ganos module.
    Note You can implement GPU-accelerated computing only in the Ganos Raster module. GPU-accelerated computing will be supported by the Ganos Trajectory and Ganos Geometry modules in the future.