Browse Source

!13010 Add device id log

From: @zpac
Reviewed-by: @cristoval,@wilfchen
Signed-off-by: @cristoval
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
a21c8e13b5
2 changed files with 3 additions and 2 deletions
  1. +1
    -1
      mindspore/ccsrc/backend/session/gpu_session.cc
  2. +2
    -1
      mindspore/ccsrc/runtime/device/gpu/cuda_driver.cc

+ 1
- 1
mindspore/ccsrc/backend/session/gpu_session.cc View File

@@ -95,7 +95,7 @@ void GPUSession::Init(uint32_t device_id) {
} }
bool ret = device::gpu::CudaDriver::set_current_device(UintToInt(device_id)); bool ret = device::gpu::CudaDriver::set_current_device(UintToInt(device_id));
if (!ret) { if (!ret) {
MS_LOG(EXCEPTION) << "GPUSession failed to set current device id.";
MS_LOG(EXCEPTION) << "GPUSession failed to set current device id:" << device_id;
} }
auto ms_context = MsContext::GetInstance(); auto ms_context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(ms_context); MS_EXCEPTION_IF_NULL(ms_context);


+ 2
- 1
mindspore/ccsrc/runtime/device/gpu/cuda_driver.cc View File

@@ -241,7 +241,8 @@ int CudaDriver::device_count() {
bool CudaDriver::set_current_device(int index) { bool CudaDriver::set_current_device(int index) {
auto ret = cudaSetDevice(index); auto ret = cudaSetDevice(index);
if (ret != cudaSuccess) { if (ret != cudaSuccess) {
MS_LOG(ERROR) << "cudaSetDevice failed, ret[" << static_cast<int>(ret) << "], " << cudaGetErrorString(ret);
MS_LOG(ERROR) << "cudaSetDevice " << index << " failed, ret[" << static_cast<int>(ret) << "], "
<< cudaGetErrorString(ret);
return false; return false;
} }
return true; return true;


Loading…
Cancel
Save