Skip to content

[API] Add cudnn_available() function to check DNN library availability#77880

Open
YqGe585 wants to merge 2 commits intoPaddlePaddle:developfrom
YqGe585:fixcudnnversion
Open

[API] Add cudnn_available() function to check DNN library availability#77880
YqGe585 wants to merge 2 commits intoPaddlePaddle:developfrom
YqGe585:fixcudnnversion

Conversation

@YqGe585
Copy link
Member

@YqGe585 YqGe585 commented Feb 12, 2026

PR Category

Custom Device

PR Types

Bug fixes

Description

Add a new Python API paddle.device.cudnn_available() to check whether cuDNN or equivalent DNN library is available. This simplifies the code that previously used get_cudnn_version() just for availability checks.

Changes:

  1. C++ Layer (paddle/fluid/pybind/pybind.cc):

    • Add CudnnAvailable() function that:
      • Returns platform::DnnVersion() > 0 for CUDA/HIP builds
      • Checks custom devices via phi::DeviceManager::IsDnnAvailable(place) for custom device builds
      • Returns false otherwise
    • Add pybind binding m.def("cudnn_available", CudnnAvailable);
  2. Python Layer (python/paddle/device/__init__.py):

    • Add cudnn_available() function that calls core.cudnn_available()
    • Export in __all__ list
  3. Functional Conv (python/paddle/nn/functional/conv.py):

    • Replace 6 get_cudnn_version() usages with cudnn_available() in:
      • conv1d, conv2d, conv1d_transpose, conv2d_transpose, conv3d, conv3d_transpose
  4. Layer Conv (python/paddle/nn/layer/conv.py):

    • Replace get_cudnn_version() usage in _ConvNd class initialization

Benefits:

  • Cleaner code: use_cudnn = cudnn_available() instead of multi-line version checks
  • Better custom device support: Automatically handles custom device DNN libraries
  • Fixes undefined is_custom_device variable in conv1d_transpose

是否引起精度变化

Add a new Python API `paddle.device.cudnn_available()` to check whether
cuDNN or equivalent DNN library is available. This simplifies the code
that previously used `get_cudnn_version()` just for availability checks.

Changes:
- Add CudnnAvailable() function in pybind.cc for CUDA/HIP and custom devices
- Add cudnn_available() Python function in paddle/device/__init__.py
- Replace get_cudnn_version() usage in conv.py files with cudnn_available()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@paddle-bot
Copy link

paddle-bot bot commented Feb 12, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

When cudnn_version is None (e.g., on custom devices), also check
cudnn_available() to enable cuDNN usage if DNN library is available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@YqGe585
Copy link
Member Author

YqGe585 commented Feb 12, 2026

/re-run all-failed

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@06b60d2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/nn/functional/vision.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #77880   +/-   ##
==========================================
  Coverage           ?   92.30%           
==========================================
  Files              ?        4           
  Lines              ?       13           
  Branches           ?        0           
==========================================
  Hits               ?       12           
  Misses             ?        1           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@YqGe585
Copy link
Member Author

YqGe585 commented Feb 13, 2026

/re-run all-failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments