OpenCV Import Issue Since OTA Update

Since I got an OTA update I am unable to import cv2 without it throwing an error and failing
>>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/cv2/__init__.py", line 96, in <module> bootstrap() File "/usr/local/lib/python3.6/dist-packages/cv2/__init__.py", line 86, in bootstrap import cv2 ImportError: /usr/local/lib/libopencv_dnn.so.4.3: undefined symbol: cudnnGetConvolutionBackwardDataAlgorithm

I have tried reinstalling OpenCV from source to no avail.

Any suggestions?

Thanks

Not sure and not tried, but my guess would be that OTA upgraded CUDA and CUDNN, so you would have to reconfigure, rebuild and reinstall opencv (I’d advise to use a new configure/build folder).

Yep, it did update CUDA and CUDNN. I did do a total reinstall of OpenCV and that didn’t seem to fix it. During the install it recognized the correct versions of CUDA and CUDNN, so I am at a loss.

What gives:

ldd /usr/local/lib/libopencv_dnn.so.4.3

It gives:

linux-vdso.so.1 (0x0000007f905bb000) libgtk3-nocsd.so.0 => /usr/lib/aarch64-linux-gnu/libgtk3-nocsd.so.0 (0x0000007f8fb27000) libopencv_imgproc.so.4.3 => /usr/local/lib/libopencv_imgproc.so.4.3 (0x0000007f8f708000) libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f8f6f3000) librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007f8f6dc000) libcublas.so.10 => /usr/lib/aarch64-linux-gnu/libcublas.so.10 (0x0000007f8a9fe000) libcudnn.so.8 => /usr/lib/aarch64-linux-gnu/libcudnn.so.8 (0x0000007f8a9c0000) libopencv_core.so.4.3 => /usr/local/lib/libopencv_core.so.4.3 (0x0000007f8a237000) libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f8a17e000) libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f8a152000) libstdc++.so.6 => /usr/lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007f89fbe000) libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007f89f9a000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f89e40000) /lib/ld-linux-aarch64.so.1 (0x0000007f90590000) libcublasLt.so.10 => /usr/lib/aarch64-linux-gnu/libcublasLt.so.10 (0x0000007f87e7a000) libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007f87e4d000)

I have no idea how to interpret that but I don’t see any errors.

What build script (if any) did you use to build it from source, @ben.mcdonnell ?

I used the script mentioned in this thread: OpenCV Cuda: No Kernel Image is Available

Try the one linked here with master as an option (build_opencv.sh master) to build 4.4.0-pre or see this issue for why it’s not working.

Tl;dr: some cuDNN functions were deprecated in the GA release of JetPack 4.4 requiring patches to OpenCV. My understanding is that there were deprecation warnings before but they were ignored by the upstream OpenCV developers.

@ben.mcdonnell
I just realized I didn’t link to any script above. I was thinking about another thread. Sorry about that. I’ve updated the above post.

Thanks, I assume something like that happened.
It is currently building I will get back to you when it has finished.

So it appears that OpenCv build successfully, but when trying to import it on my system it still fails with the same issue. Am I missing an uninstall step somewhere?

Thanks in advance!

Thanks @ben.mcdonnell . I will try to replicate this morning from a fresh card image and get back to you. Can you provide this information on GitHub:

  • JetPack version
  • Any significant changes to the system after flash
  • Steps to replicate the error

Thanks again for testing!

Be sure you don’t have an environment variable PYTHONPATH with path to another opencv install.

echo $PYTHONPATH

You may also use cv2.getBuildInformation() for checking which version python runs:

import cv2
print(cv2.getBuildInformation())

If it shows a wrong version, probably the python install of opencv failed.
I have poor experience with python, and in such case I use a nasty hack linking respective dist-packages cv2 directories to my opencv install location of python2 and 3. I don’t advise to try that, someone with better python knowledge may advise a clean way.

From what I can tell my pythonpath looks fine. I can’t test the get build information because it fails to import. When I run the command $ opencv_version --verbose everything looks to be as I expect. But I understand that may not be what python thinks exists.