Skip to content

Update FindCUDNN.cmake#17238

Closed
AaronWebster wants to merge 2 commits intoopencv:masterfrom
AaronWebster:patch-1
Closed

Update FindCUDNN.cmake#17238
AaronWebster wants to merge 2 commits intoopencv:masterfrom
AaronWebster:patch-1

Conversation

@AaronWebster
Copy link
Copy Markdown

@AaronWebster AaronWebster commented May 8, 2020

As of at least CUDA 10.2, the definitions of CUDNN_MAJOR, CUDNN_MINOR, and CUDNN_PATCHLEVEL are in cudnn_version.h rather than cudnn.h. The proposed change adds the contents of cudnn_version.h to the regex search text if it exists.

### 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 OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • 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
force_builders=Custom
buildworker:Custom=linux-4
build_image:Custom=ubuntu-cuda:18.04

As of at least CUDA 10.2, the definitions of CUDNN_MAJOR, CUDNN_MINOR, and CUDNN_PATCHLEVEL are in cudnn_version.h rather than cudnn.h.  The proposed change adds the contents of cudnn_version.h to the regex search text if it exists.
@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster Please pay attention on CI bot status. It reports trailing whitespace issue: https://pullrequest.opencv.org/buildbot/builders/precommit_docs/builds/24941/steps/whitespace%20opencv/logs/stdio

@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster CuDNN is not part of CUDA distribution and installed separatelly. Could you also point CuDNN version that you use? I checked the latest CuDNN 7.6.5 distribution for Ubuntu 18.04 and it does not provide cudnn_version.h. Versioning is done as usual and OpenCV works with it.

Remove trailing whitespace.
@AaronWebster
Copy link
Copy Markdown
Author

I encountered this issue on an NVIDIA Jetson TX2 dev board running L4T 32.4 (JetPack 4.4). The alternative version file comes from libcudnn8-dev_8.0.0.145-1+cuda10.2_arm64.deb.

Unfortunately I do not see this version on the CuDNN downloads page; I'm guessing it's only available when cross-compiling using the NVIDIA SDK Manager. I recognize this might be tedious for you to verify independently, can I provide additional information?

@YashasSamaga
Copy link
Copy Markdown
Contributor

YashasSamaga commented May 9, 2020

@AaronWebster cuDNN 8 seems to have split cuDNN into multiple packages (inference and training, and further subdivisions amongst them). Hence, there is probably a need for a new version header. The cuDNN 8 was an early access release which they seem to have removed now (at least from the release notes). So I am not sure if things from preview release should be incorporated.

Secondly, the current cuDNN CMake setup cannot handle multiple binaries yet. So even if this versioning scheme was supported, I think it will still fail to compile/run.

@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster could you work on linkage fix for new CuDNN version as @YashasSamaga reported?

@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster friendly reminder.

@CarloSpadotto
Copy link
Copy Markdown

hi, i'm working on a Jetson nano dev kit. and i was trying to compile opencv with CUDNN, i have encountered the same problem, as a workaround i have modified the file FindCUDNN.cmake at line 68, i have replaced this line file(READ "${CUDNN_INCLUDE_DIR}/cudnn.h" CUDNN_H_CONTENTS) with this code file(READ "${CUDNN_INCLUDE_DIR}/cudnn_version.h" CUDNN_H_CONTENTS) and now everything is working fine. hopefully this can help someone because i spent 2 days recompiling opencv not understanding why cudnn was always missing from the build.

@YashasSamaga
Copy link
Copy Markdown
Contributor

YashasSamaga commented May 16, 2020

@carloSpa-ET Based on the old retracted release notes, they have split cudnn into multiple binaries. Can you please confirm if they have retained one big cudnn.so binary for backward compatibility?

locate cudnn.so

Does your application work with cuDNN? Does your application load correctly and uses GPU for inference?

@asmorkalov
Copy link
Copy Markdown
Contributor

@carloSpa-ET @AaronWebster could you check for cudnn.so and report if it's really used in run-time.

@CarloSpadotto
Copy link
Copy Markdown

Hi, sorry for the late reply, it isn't working, I think that as @YashasSamaga said, Nvidia splitted cudnn.so file in multiple files, I haven't find a way to make it work, so I just gave up, and roll back to jetpack 4.3, using cudnn 7.6. I'm sorry of not being of any help.

@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster could you handle libraries linkage too?

@YashasSamaga
Copy link
Copy Markdown
Contributor

YashasSamaga commented May 20, 2020

Linking all six binaries might be an easy workaround. But based on my memory of what I had read in the retracted release notes, I think OpenCV requires only two or three of the six. I can't find an archived version of the release notes page to confirm.

I am going to take a guess that we need all the inference binaries except the adv_infer (I think it has the RNN stuff which isn't used by OpenCV) + cnn_train binary (required for forward pass of transpose convolution). I have a feeling that cnn_infer includes convolution backward pass just for the sake of transpose convolution.

One of these combinations will mostly work:

  • cnn_infer + basic_infer (not sure about the names)
  • cnn_infer + basic_infer + cnn_train

Or maybe it's best to wait for the official release of cuDNN 8.

@asmorkalov
Copy link
Copy Markdown
Contributor

@AaronWebster do you have a chance to finish linkage step?

@asmorkalov
Copy link
Copy Markdown
Contributor

@alalek I propose to close PR till official release of CuDNN 8 as it does not solve build issue, but just hides the problem.

@YashasSamaga
Copy link
Copy Markdown
Contributor

YashasSamaga commented Jun 6, 2020

NVIDIA has released the release notes and documentation for cuDNN 8.0 preview version.

https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#api-changes

cudnnGetConvolutionForwardAlgorithm has been removed but it's currently in use:

CUDA4DNN_CHECK_CUDNN(
cudnnGetConvolutionForwardAlgorithm(
handle.get(),
input.get(), filter.get(), conv.get(), output.get(),
CUDNN_CONVOLUTION_FWD_PREFER_FASTEST,
0, /* no memory limit */
&algo
)
);

If the documentation is correct, changes are required in the code too.

@asmorkalov
Copy link
Copy Markdown
Contributor

It looks like the PR is abandoned. I created ticket to track all changes and continue discussion: #17496

@asmorkalov asmorkalov closed this Jun 8, 2020
@asmorkalov asmorkalov mentioned this pull request Jun 8, 2020
@AaronWebster AaronWebster deleted the patch-1 branch September 21, 2020 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants