Skip to content

Commit 2c9839c

Browse files
author
chengduo
authored
add cuda version display (#13885)
test=develop
1 parent 8e2fdc5 commit 2c9839c

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

paddle/fluid/platform/device_context.cc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ class CudnnHolder {
198198
CUDADeviceContext::CUDADeviceContext(CUDAPlace place)
199199
: place_(place), cudnn_holder_(nullptr) {
200200
SetDeviceId(place_.device);
201-
compute_capability = GetCUDAComputeCapability(place_.device);
202-
multi_process = GetCUDAMultiProcessors(place_.device);
203-
max_threads_per_mp = GetCUDAMaxThreadsPerMultiProcessor(place_.device);
201+
compute_capability_ = GetCUDAComputeCapability(place_.device);
202+
multi_process_ = GetCUDAMultiProcessors(place_.device);
203+
max_threads_per_mp_ = GetCUDAMaxThreadsPerMultiProcessor(place_.device);
204204
PADDLE_ENFORCE(cudaStreamCreate(&stream_));
205205
eigen_stream_.reset(new EigenCudaStreamDevice());
206206
eigen_stream_->Reinitialize(&stream_, place);
@@ -211,6 +211,16 @@ CUDADeviceContext::CUDADeviceContext(CUDAPlace place)
211211
cudnn_holder_.reset(new CudnnHolder(&stream_, place));
212212
}
213213

214+
driver_version_ = GetCUDADriverVersion(place_.device);
215+
runtime_version_ = GetCUDARuntimeVersion(place_.device);
216+
217+
LOG(INFO) << "device: " << place_.device
218+
<< ", CUDA Capability: " << compute_capability_
219+
<< ", Driver Version: " << driver_version_ / 1000 << "."
220+
<< (driver_version_ % 100) / 10
221+
<< ", Runtime Version: " << runtime_version_ / 1000 << "."
222+
<< (runtime_version_ % 100) / 10;
223+
214224
callback_manager_.reset(new StreamCallbackManager(stream_));
215225
}
216226

@@ -232,11 +242,11 @@ void CUDADeviceContext::Wait() const {
232242
}
233243

234244
int CUDADeviceContext::GetComputeCapability() const {
235-
return compute_capability;
245+
return compute_capability_;
236246
}
237247

238248
int CUDADeviceContext::GetMaxPhysicalThreadCount() const {
239-
return multi_process * max_threads_per_mp;
249+
return multi_process_ * max_threads_per_mp_;
240250
}
241251

242252
Eigen::GpuDevice* CUDADeviceContext::eigen_device() const {

paddle/fluid/platform/device_context.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ class CUDADeviceContext : public DeviceContext {
135135
cudaStream_t stream_;
136136
cublasHandle_t cublas_handle_;
137137

138-
int compute_capability;
139-
int multi_process;
140-
int max_threads_per_mp;
138+
int compute_capability_;
139+
int runtime_version_;
140+
int driver_version_;
141+
int multi_process_;
142+
int max_threads_per_mp_;
141143

142144
mutable std::mutex mtx_;
143145

paddle/fluid/platform/gpu_info.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ int GetCUDAComputeCapability(int id) {
4646
return device_prop.major * 10 + device_prop.minor;
4747
}
4848

49+
int GetCUDARuntimeVersion(int id) {
50+
PADDLE_ENFORCE_LT(id, GetCUDADeviceCount(), "id must less than GPU count");
51+
int runtime_version = 0;
52+
PADDLE_ENFORCE(cudaRuntimeGetVersion(&runtime_version),
53+
"cudaRuntimeGetVersion failed in "
54+
"paddle::platform::cudaRuntimeGetVersion");
55+
return runtime_version;
56+
}
57+
58+
int GetCUDADriverVersion(int id) {
59+
PADDLE_ENFORCE_LT(id, GetCUDADeviceCount(), "id must less than GPU count");
60+
int driver_version = 0;
61+
PADDLE_ENFORCE(cudaDriverGetVersion(&driver_version),
62+
"cudaDriverGetVersion failed in "
63+
"paddle::platform::GetCUDADriverVersion");
64+
return driver_version;
65+
}
66+
4967
int GetCUDAMultiProcessors(int id) {
5068
PADDLE_ENFORCE_LT(id, GetCUDADeviceCount(), "id must less than GPU count");
5169
int count;

paddle/fluid/platform/gpu_info.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ int GetCUDADeviceCount();
2929
//! Get the compute capability of the ith GPU (format: major * 10 + minor)
3030
int GetCUDAComputeCapability(int i);
3131

32+
//! Get the runtime version of the ith GPU
33+
int GetCUDARuntimeVersion(int id);
34+
35+
//! Get the driver version of the ith GPU
36+
int GetCUDADriverVersion(int id);
37+
3238
//! Get the MultiProcessors of the ith GPU.
3339
int GetCUDAMultiProcessors(int i);
3440

0 commit comments

Comments
 (0)