mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-22 15:33:29 -06:00
Merge pull request #5705 from akva2/fix_div_by_zero_no_gpus
fixed: division by zero if no gpu device was found
This commit is contained in:
commit
fadc96da44
@ -37,7 +37,7 @@ namespace Opm::gpuistl {
|
|||||||
into problems with this code when using multiple MPI ranks.
|
into problems with this code when using multiple MPI ranks.
|
||||||
The simulation might hang because the integrated GPU in the CPU
|
The simulation might hang because the integrated GPU in the CPU
|
||||||
is detected has Radeon compute units, but it does not support ROCM.
|
is detected has Radeon compute units, but it does not support ROCM.
|
||||||
This is fixable my making only the GPUS on your system visible with
|
This is fixable by making only the GPUS on your system visible with
|
||||||
ROCR_VISIBLE_DEVICES environment variable.
|
ROCR_VISIBLE_DEVICES environment variable.
|
||||||
*/
|
*/
|
||||||
void printDevice()
|
void printDevice()
|
||||||
@ -51,6 +51,8 @@ namespace Opm::gpuistl {
|
|||||||
int deviceCount = -1;
|
int deviceCount = -1;
|
||||||
OPM_GPU_WARN_IF_ERROR(cudaGetDeviceCount(&deviceCount));
|
OPM_GPU_WARN_IF_ERROR(cudaGetDeviceCount(&deviceCount));
|
||||||
|
|
||||||
|
auto deferred_logger = ::Opm::DeferredLogger();
|
||||||
|
if (deviceCount > 0) {
|
||||||
const auto deviceId = mpiRank % deviceCount;
|
const auto deviceId = mpiRank % deviceCount;
|
||||||
|
|
||||||
struct cudaDeviceProp props;
|
struct cudaDeviceProp props;
|
||||||
@ -59,14 +61,13 @@ namespace Opm::gpuistl {
|
|||||||
std::string out;
|
std::string out;
|
||||||
out = fmt::format("rank: {}, GPU: {}, Compute Capability: {}.{} (device {} out of {})\n",
|
out = fmt::format("rank: {}, GPU: {}, Compute Capability: {}.{} (device {} out of {})\n",
|
||||||
mpiRank, props.name, props.major, props.minor, deviceId, deviceCount);
|
mpiRank, props.name, props.major, props.minor, deviceId, deviceCount);
|
||||||
auto deferred_logger = ::Opm::DeferredLogger();
|
|
||||||
deferred_logger.info(out);
|
deferred_logger.info(out);
|
||||||
|
}
|
||||||
|
|
||||||
DeferredLogger global = gatherDeferredLogger(deferred_logger, FlowGenericVanguard::comm());
|
DeferredLogger global = gatherDeferredLogger(deferred_logger, FlowGenericVanguard::comm());
|
||||||
if (mpiRank == 0) {
|
if (mpiRank == 0) {
|
||||||
global.logMessages();
|
global.logMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user