Skip to content

Commit 76b883c

Browse files
authored
【Cherry-pick PR47743】change cudnn error to cuda error if compiled cuda version is incompatible with installed cuda version (#47744)
* cherry-pick pr47743 * fix * fix * fix
1 parent 51248f8 commit 76b883c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

paddle/phi/backends/gpu/gpu_resources.cc

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ void InitGpuProperties(Place place,
9797
(*driver_version / 1000) * 10 + (*driver_version % 100) / 10;
9898
auto compile_cuda_version =
9999
(CUDA_VERSION / 1000) * 10 + (CUDA_VERSION % 100) / 10;
100+
#if defined(__linux__)
101+
PADDLE_ENFORCE_EQ(
102+
(local_cuda_version / 10 < compile_cuda_version / 10) &&
103+
(cudnn_dso_ver / 1000 < CUDNN_VERSION / 1000),
104+
false,
105+
phi::errors::InvalidArgument(
106+
"The installed Paddle is compiled with CUDA%d/cuDNN%d,"
107+
"but CUDA/cuDNN version in your machine is CUDA%d/cuDNN%d. "
108+
"which will cause serious incompatible bug. "
109+
"Please recompile or reinstall Paddle with compatible CUDA/cuDNN "
110+
"version.",
111+
compile_cuda_version / 10,
112+
CUDNN_VERSION / 1000,
113+
local_cuda_version / 10,
114+
cudnn_dso_ver / 1000));
115+
#endif
100116
if (local_cuda_version < compile_cuda_version) {
101117
LOG_FIRST_N(WARNING, 1)
102118
<< "WARNING: device: " << static_cast<int>(place.device)
@@ -108,20 +124,6 @@ void InitGpuProperties(Place place,
108124
<< "Please recompile or reinstall Paddle with compatible CUDA "
109125
"version.";
110126
}
111-
112-
auto local_cudnn_version = cudnn_dso_ver / 1000;
113-
auto compile_cudnn_version = CUDNN_VERSION / 1000;
114-
PADDLE_ENFORCE_EQ(
115-
compile_cudnn_version,
116-
local_cudnn_version,
117-
phi::errors::InvalidArgument(
118-
"The installed Paddle is compiled with CUDNN "
119-
"%d, but CUDNN version in your machine is %d. "
120-
"which will cause serious incompatible bug. "
121-
"Please recompile or reinstall Paddle with compatible CUDNN "
122-
"version.",
123-
compile_cudnn_version,
124-
local_cudnn_version));
125127
#endif
126128
}
127129

0 commit comments

Comments
 (0)