diff --git a/paddle/phi/backends/gpu/gpu_resources.cc b/paddle/phi/backends/gpu/gpu_resources.cc index 4d2621cb6a049436d2650e22e5cf7bb902aab2fd..4a16480101a7034388529a78f3b0baf822602bef 100644 --- a/paddle/phi/backends/gpu/gpu_resources.cc +++ b/paddle/phi/backends/gpu/gpu_resources.cc @@ -97,6 +97,22 @@ void InitGpuProperties(Place place, (*driver_version / 1000) * 10 + (*driver_version % 100) / 10; auto compile_cuda_version = (CUDA_VERSION / 1000) * 10 + (CUDA_VERSION % 100) / 10; +#if defined(__linux__) + PADDLE_ENFORCE_EQ( + (local_cuda_version / 10 < compile_cuda_version / 10) && + (cudnn_dso_ver / 1000 < CUDNN_VERSION / 1000), + false, + phi::errors::InvalidArgument( + "The installed Paddle is compiled with CUDA%d/cuDNN%d," + "but CUDA/cuDNN version in your machine is CUDA%d/cuDNN%d. " + "which will cause serious incompatible bug. " + "Please recompile or reinstall Paddle with compatible CUDA/cuDNN " + "version.", + compile_cuda_version / 10, + CUDNN_VERSION / 1000, + local_cuda_version / 10, + cudnn_dso_ver / 1000)); +#endif if (local_cuda_version < compile_cuda_version) { LOG_FIRST_N(WARNING, 1) << "WARNING: device: " << static_cast(place.device) @@ -108,20 +124,6 @@ void InitGpuProperties(Place place, << "Please recompile or reinstall Paddle with compatible CUDA " "version."; } - - auto local_cudnn_version = cudnn_dso_ver / 1000; - auto compile_cudnn_version = CUDNN_VERSION / 1000; - PADDLE_ENFORCE_EQ( - compile_cudnn_version, - local_cudnn_version, - phi::errors::InvalidArgument( - "The installed Paddle is compiled with CUDNN " - "%d, but CUDNN version in your machine is %d. " - "which will cause serious incompatible bug. " - "Please recompile or reinstall Paddle with compatible CUDNN " - "version.", - compile_cudnn_version, - local_cudnn_version)); #endif }