ImFusion C++ SDK 4.5.0
ImFusion::ML::CudaDeviceManager Class Referencefinal

#include <ImFusion/ML/CudaUtils.h>

Singleton class that helps getting a compatible CUDA device. More...

Detailed Description

Singleton class that helps getting a compatible CUDA device.

Classes

struct  CudaDeviceProp
 Abstracted and stripped down version of cudaDeviceProp. More...

Public Member Functions

std::optional< int > getCompatibleCudaDevice (std::optional< std::vector< std::string > > supportedArchitectures, std::optional< std::vector< int > > deviceIndices=std::nullopt)
 Returns the index of the first compatible CUDA device if there is one (otherwise returns std::nullopt).
int getDeviceCount () const
 Wrapper around the cudaGetDeviceCount function.
std::optional< CudaDevicePropgetDeviceProperties (int deviceIndex) const
 Wrapper around the cudaGetDeviceProperties function.
bool supportsFP16 (int deviceIndex) const
 Checks if the specified CUDA device supports FP16 (half-precision) computation.
bool supportsBFloat16 (int deviceIndex) const
 Checks if the specified CUDA device supports BFloat16 computation.
std::optional< int > getCudaRuntimeVersion () const
 Wrapper around the cudaRuntimeGetVersion function.

Static Public Member Functions

static CudaDeviceManager & instance ()
 Get the singleton instance.

Member Function Documentation

◆ getCompatibleCudaDevice()

std::optional< int > ImFusion::ML::CudaDeviceManager::getCompatibleCudaDevice ( std::optional< std::vector< std::string > > supportedArchitectures,
std::optional< std::vector< int > > deviceIndices = std::nullopt )

Returns the index of the first compatible CUDA device if there is one (otherwise returns std::nullopt).

If supportedArchitectures is provided (e.g. {"7.0", "8.0"}), the function will only consider CUDA devices that are supported. If deviceIndices is provided, the function will only check the specified devices (assumed to be ordered by preference) and return the first index which corresponds to a CUDA compatible device.

◆ getDeviceCount()

int ImFusion::ML::CudaDeviceManager::getDeviceCount ( ) const

Wrapper around the cudaGetDeviceCount function.

Can be replaced by a mock for testing purposes.

◆ getDeviceProperties()

std::optional< CudaDeviceProp > ImFusion::ML::CudaDeviceManager::getDeviceProperties ( int deviceIndex) const

Wrapper around the cudaGetDeviceProperties function.

Can be replaced by a mock for testing purposes.

◆ supportsFP16()

bool ImFusion::ML::CudaDeviceManager::supportsFP16 ( int deviceIndex) const

Checks if the specified CUDA device supports FP16 (half-precision) computation.

FP16 is supported on compute capability 5.3 and higher, but certain more recent GPU models are blacklisted due to other issues.

Parameters
deviceIndexThe index of the CUDA device to check
Returns
true if the device supports effective FP16 computation, false otherwise or if device properties cannot be retrieved

◆ supportsBFloat16()

bool ImFusion::ML::CudaDeviceManager::supportsBFloat16 ( int deviceIndex) const

Checks if the specified CUDA device supports BFloat16 computation.

BFloat16 requires Ampere (compute capability >= 8.0) and CUDA >= 11.

Parameters
deviceIndexThe index of the CUDA device to check
Returns
true if the device supports BFloat16 computation, false otherwise or if device properties cannot be retrieved

◆ getCudaRuntimeVersion()

std::optional< int > ImFusion::ML::CudaDeviceManager::getCudaRuntimeVersion ( ) const

Wrapper around the cudaRuntimeGetVersion function.

Can be replaced by a mock for testing purposes.


The documentation for this class was generated from the following file:
  • ImFusion/ML/CudaUtils.h
Search Tab / S to search, Esc to close