Commit e3a4ae49 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

MPI: fixed bug due to std::getenv returning a null pointer

parent ce5f476b
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -28,9 +28,14 @@ inline void selectGPU()

   const int local_rank = getRankOnNode();
   const int gpuNumber = local_rank % gpuCount;

   // write debug output before calling cudaSetDevice
   const char* cuda_visible_devices = std::getenv("CUDA_VISIBLE_DEVICES");
   if( !cuda_visible_devices )
      cuda_visible_devices = "";
   std::cout << "Rank " << GetRank() << ": rank on node is " << local_rank
             << ", using GPU id " << gpuNumber << " of " << gpuCount
             << ", CUDA_VISIBLE_DEVICES=" << std::getenv("CUDA_VISIBLE_DEVICES")
             << ", CUDA_VISIBLE_DEVICES=" << cuda_visible_devices
             << std::endl;

   cudaSetDevice(gpuNumber);