![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/ML/CudaUtils.h>
Singleton class that helps getting a compatible CUDA device. More...
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< CudaDeviceProp > | getDeviceProperties (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. | |
| 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.
| int ImFusion::ML::CudaDeviceManager::getDeviceCount | ( | ) | const |
Wrapper around the cudaGetDeviceCount function.
Can be replaced by a mock for testing purposes.
| std::optional< CudaDeviceProp > ImFusion::ML::CudaDeviceManager::getDeviceProperties | ( | int | deviceIndex | ) | const |
Wrapper around the cudaGetDeviceProperties function.
Can be replaced by a mock for testing purposes.
| 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.
| deviceIndex | The index of the CUDA device to check |
| 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.
| deviceIndex | The index of the CUDA device to check |
| std::optional< int > ImFusion::ML::CudaDeviceManager::getCudaRuntimeVersion | ( | ) | const |
Wrapper around the cudaRuntimeGetVersion function.
Can be replaced by a mock for testing purposes.