Skip to content

Forcing CUDNN_VERSION variable set#22385

Closed
jaskirat8 wants to merge 1 commit intoopencv:4.xfrom
jaskirat8:cudnn_version_var_force
Closed

Forcing CUDNN_VERSION variable set#22385
jaskirat8 wants to merge 1 commit intoopencv:4.xfrom
jaskirat8:cudnn_version_var_force

Conversation

@jaskirat8
Copy link
Copy Markdown

CUDNN_VERSION variable setting needs to be forced as often re-running the make file causes the previous cache to give an invalid/old value, this is reproducible, especially with CUDNN 8.x as CUDA and CUDNN are decoupled and auto-detect doesn't work and a regular user might run without setting CUDNN_LIBRARY and CUDNN_INCLUDE_DIR which leads to the value of CUDNN_VERSION being set to ".." and in the cache.

Hence when the user finally figures out the path setting, the cache prevents the version detection as keeps on giving ".." even if it's able to derive the actual version, as due to the cache not overriding it keeps on giving the value ".." thereby confusing the user, thus FORCE will refresh this value ensuring successful pre-build if correct CUDNN_LIBRARY and CUDNN_INCLUDE_DIR are giving in next run of CMake.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [ .] I agree to contribute to the project under Apache 2 License.
  • [ .] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • [ .] The PR is proposed to the proper branch
  • [ X] There is a reference to the original bug report and related work
  • [ X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [ .] The feature is well documented and sample code can be built with the project CMake

CUDNN_VERSION variable setting needs to be forced as often re-running the make file causes the previous cache to give an invalid/old value, this is reproducible, especially with CUDNN 8.x as CUDA and CUDNN are decoupled and auto-detect doesn't work and a regular user might run without setting CUDNN_LIBRARY and CUDNN_INCLUDE_DIR which leads to value of CUDNN_VERSION being set to ".." and in cache. 

Hence when the user finally figures out the path setting, the cache prevents the version detection as keeps on giving ".." even if its able to derive the actual version, as due to the cache not overriding it keeps on giving the value ".." thereby confusing the user, thus FORCE will refresh this value ensuring successful pre-build if correct CUDNN_LIBRARY and CUDNN_INCLUDE_DIR are giving in next run of cmake.
STRING
FORCE
"cuDNN version"
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to CMake documentation FORCE is the last option.

set(<variable> <value>... CACHE <type> <docstring> [FORCE])

https://cmake.org/cmake/help/latest/command/set.html


To avoid mess - it makes sense to replace STRING->INTERNAL (similar to CUDNN_VERSION_MAJOR/MINOR/PATCH versions).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also this comment: #19452 (comment)

Based on standard:
CUDNN_VERSION should be moved out of the cache

@asmorkalov
Copy link
Copy Markdown
Contributor

Replaced by #22521

@asmorkalov asmorkalov closed this Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants