Print an error message to stderr when the initialization of the CUDA runtime fails. This helps debugging setup issues.

This commit is contained in:
Benoit Steiner 2016-02-19 13:44:22 -08:00
parent 670db7988d
commit 46fc23f91c

View File

@ -34,13 +34,24 @@ static void initializeDeviceProp() {
if (!m_devicePropInitialized) {
int num_devices;
cudaError_t status = cudaGetDeviceCount(&num_devices);
EIGEN_UNUSED_VARIABLE(status)
if (status != cudaSuccess) {
std::cerr << "Failed to get the number of CUDA devices: "
<< cudaGetErrorString(status)
<< std::endl;
assert(status == cudaSuccess);
}
m_deviceProperties = new cudaDeviceProp[num_devices];
for (int i = 0; i < num_devices; ++i) {
status = cudaGetDeviceProperties(&m_deviceProperties[i], i);
if (status != cudaSuccess) {
std::cerr << "Failed to initialize CUDA device #"
<< i
<< ": "
<< cudaGetErrorString(status)
<< std::endl;
assert(status == cudaSuccess);
}
}
m_devicePropInitialized = true;
}
}