15 #ifdef BUILD_CUDA_MODULE
16 #include <cuda_runtime.h>
23 int minComputeCapabilityMinor,
24 int minTotalDeviceMemory) {
25 #ifdef BUILD_CUDA_MODULE
28 success = cudaGetDeviceCount(&nbDevices);
29 if (success != cudaSuccess) {
31 cudaGetErrorString(success));
36 for (
int i = 0; i < nbDevices; ++i) {
37 cudaDeviceProp deviceProperties;
39 if (cudaGetDeviceProperties(&deviceProperties, i) != cudaSuccess) {
41 "Cannot get properties for CUDA gpu device {}", i);
45 if ((deviceProperties.major > minComputeCapabilityMajor ||
46 (deviceProperties.major == minComputeCapabilityMajor &&
47 deviceProperties.minor >= minComputeCapabilityMinor)) &&
48 deviceProperties.totalGlobalMem >=
49 static_cast<std::size_t
>(minTotalDeviceMemory * 1024 *
55 "CUDA-Enabled GPU detected, but the compute "
56 "capabilities is not enough.\n - Device {} : {}.{}, "
57 "global memory: {} MB\n - Requirements: {}.{}, global "
59 i, deviceProperties.major, deviceProperties.minor,
60 int(deviceProperties.totalGlobalMem / (1024 * 1024)),
61 minComputeCapabilityMajor, minComputeCapabilityMinor,
62 minTotalDeviceMemory);
74 std::string information;
75 #ifdef BUILD_CUDA_MODULE
77 if (cudaGetDeviceCount(&nbDevices) != cudaSuccess) {
79 "Could not determine number of CUDA cards in this system");
84 information =
"CUDA-Enabled GPU.\n";
85 for (
int i = 0; i < nbDevices; ++i) {
86 cudaDeviceProp deviceProperties;
87 if (cudaGetDeviceProperties(&deviceProperties, i) != cudaSuccess) {
89 "Cannot get properties for CUDA gpu device {}", i);
93 if (cudaSetDevice(i) != cudaSuccess) {
100 if (cudaMemGetInfo(&avail, &total) != cudaSuccess) {
105 "Cannot get available memory information for CUDA gpu "
109 std::stringstream deviceSS;
111 deviceSS <<
"Device information:" <<
std::endl
113 <<
"\t- name: " << deviceProperties.name
115 <<
"\t- compute capability: "
116 << deviceProperties.major <<
"." << deviceProperties.minor
118 <<
"\t- total device memory: "
119 << deviceProperties.totalGlobalMem / (1024 * 1024)
121 <<
"\t- device memory available: " << avail / (1024 * 1024)
123 <<
"\t- per-block shared memory: "
124 << deviceProperties.sharedMemPerBlock <<
std::endl
126 << deviceProperties.warpSize <<
std::endl
127 <<
"\t- max threads per block: "
128 << deviceProperties.maxThreadsPerBlock <<
std::endl
129 <<
"\t- max threads per SM(X): "
130 << deviceProperties.maxThreadsPerMultiProcessor
132 <<
"\t- max block sizes: "
133 <<
"{" << deviceProperties.maxThreadsDim[0] <<
","
134 << deviceProperties.maxThreadsDim[1] <<
","
135 << deviceProperties.maxThreadsDim[2] <<
"}" <<
std::endl
136 <<
"\t- max grid sizes: "
137 <<
"{" << deviceProperties.maxGridSize[0] <<
","
138 << deviceProperties.maxGridSize[1] <<
","
139 << deviceProperties.maxGridSize[2] <<
"}" <<
std::endl
140 <<
"\t- max 2D array texture: "
141 <<
"{" << deviceProperties.maxTexture2D[0] <<
","
142 << deviceProperties.maxTexture2D[1] <<
"}" <<
std::endl
143 <<
"\t- max 3D array texture: "
144 <<
"{" << deviceProperties.maxTexture3D[0] <<
","
145 << deviceProperties.maxTexture3D[1] <<
","
146 << deviceProperties.maxTexture3D[2] <<
"}" <<
std::endl
147 <<
"\t- max 2D linear texture: "
148 <<
"{" << deviceProperties.maxTexture2DLinear[0] <<
","
149 << deviceProperties.maxTexture2DLinear[1] <<
","
150 << deviceProperties.maxTexture2DLinear[2] <<
"}"
152 <<
"\t- max 2D layered texture: "
153 <<
"{" << deviceProperties.maxTexture2DLayered[0] <<
","
154 << deviceProperties.maxTexture2DLayered[1] <<
","
155 << deviceProperties.maxTexture2DLayered[2] <<
"}"
157 <<
"\t- number of SM(x)s: "
158 << deviceProperties.multiProcessorCount <<
std::endl
159 <<
"\t- registers per SM(x): "
160 << deviceProperties.regsPerMultiprocessor <<
std::endl
161 <<
"\t- registers per block: "
162 << deviceProperties.regsPerBlock <<
std::endl
163 <<
"\t- concurrent kernels: "
164 << (deviceProperties.concurrentKernels ?
"yes" :
"no")
166 <<
"\t- mapping host memory: "
167 << (deviceProperties.canMapHostMemory ?
"yes" :
"no")
169 <<
"\t- unified addressing: "
170 << (deviceProperties.unifiedAddressing ?
"yes" :
"no")
172 <<
"\t- texture alignment: "
173 << deviceProperties.textureAlignment <<
" byte"
175 <<
"\t- pitch alignment: "
176 << deviceProperties.texturePitchAlignment <<
" byte"
179 information += deviceSS.str();
182 information =
"No CUDA-Enabled GPU.";
185 information =
"AliceVision built without CUDA support.";
QTextStream & endl(QTextStream &stream)
bool gpuSupportCUDA(int minComputeCapabilityMajor, int minComputeCapabilityMinor, int minTotalDeviceMemory)
Check if the system support CUDA with the given parameters.
std::string gpuInformationCUDA()
gpuInformationCUDA
Generic file read and write utility for python interface.