Ask Your Question

Error: Cannot find NvOf library.

asked 2019-10-16 12:47:09 -0600

eyshi gravatar image

updated 2019-10-16 12:59:11 -0600

Using Samples of cudaoptflow, I am trying to run Nvidia Optical Flow sdk.

code :

            Mat frame;
            cap >> frame; //read every frame
            Mat reference_image = Mat::zeros(frame.size(), frame.type());

            Ptr<NvidiaOpticalFlow_1_0> nvof = NvidiaOpticalFlow_1_0::create(
            frame.size().width, frame.size().height, perfPreset,
             true, false, false, gpuId);

            Mat flowx, flowy, flowxy, upsampledFlowXY, image;

            nvof->calc(frame, reference_image, flowxy);
            nvof->upSampler(flowxy, frame.size().width, frame.size().height,
                                        nvof->getGridSize(), upsampledFlowXY);

            Mat planes[] = { flowx, flowy };
        split(upsampledFlowXY, planes);
        flowx = planes[0]; flowy = planes[1];

        drawOpticalFlow(flowx, flowy, image, 10);
            char c = cv::waitKey(25);
            if (c ==27)

Error on running:

OpenCV(4.1.2) /docker/opencv_contrib-4.1.2/modules/cudaoptflow/src/nvidiaOpticalFlow.cpp:172: error: (-6:Unknown error code -6) Cannot find NvOF library. in function 'LoadNvidiaModules'

System :

OPENCV - 4.1.2
Installed it inside docker container with cuda 10.1 :
 Image : nvidia/cuda
 cuda_version : 10.1
 OS: ubuntu18.04

Please help in understanding why it shows this error

edit retag flag offensive close merge delete


Probably a stupid question but do you have the latest drivers installed (>=435.21) and are you using a Turing card?

cudawarped gravatar imagecudawarped ( 2019-10-16 13:01:34 -0600 )edit

well I have already check that and after that only I posted this question, because I couldn't find a solution and yes I have all the latest drivers installed.

| NVIDIA-SMI 418.56       Driver Version: 418.56       CUDA Version: 10.1     |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|   0  GeForce GTX 108...  Off  | 00000000:08:00.0 Off |                  N/A |
eyshi gravatar imageeyshi ( 2019-10-16 13:05:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-10-16 13:20:10 -0600

Hardware optical flow is new and only supported on Turing cards, your card is Volta which is not supported. I guess the error implies the driver for Volta doesn't have the required dll.

edit flag offensive delete link more


Thank You for your prompt response. So id I use Turing will it work with cuda 10.0 too ?

eyshi gravatar imageeyshi ( 2019-10-16 13:37:28 -0600 )edit

I am not 100% sure. On the basis that the required driver was released some time after CUDA 10.0 I would guess that you need CUDA 10.1.

cudawarped gravatar imagecudawarped ( 2019-10-16 14:01:01 -0600 )edit

As per you mentioned that it required turing graphic card with latest drivers, I am using that same system now, still I got same NvoF error : System

| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|   0  GeForce RTX 208...  Off  | 00000000:0A:00.0 Off |                  N/A |
| 41%   33C    P8    21W / 260W |      1MiB / 11019M
eyshi gravatar imageeyshi ( 2019-10-17 12:08:34 -0600 )edit

Unfortunately I can't help you as I only have a windows box to experiment on, unless it is an issue with the build, I am running the last stable release 4.1.1 so it is possible something has changed. All I can say is that the opticalflow regression test

opencv_test_cudaoptflowd.exe --gtest_filter=CUDA_OptFlow/NvidiaOpticalFlow_1_0.Regression/0

runs without any errors on my GTX 2080.

I take it that all the other standard cuda tests run without issues on your system?

cudawarped gravatar imagecudawarped ( 2019-10-17 14:43:20 -0600 )edit

I forgot to say, to rule out your system as the culprit I would try compiling and running the Nvidia Optical flow sample (Samples/AppOFCUDA) that comes with the SDK.

cudawarped gravatar imagecudawarped ( 2019-10-17 14:58:52 -0600 )edit

I tried that too >running the Nvidia Optical flow sample (Samples/AppOFCUDA) but it started throwing erro for FreeImage compilation.

Can you please tell me your steps to install the SDK and get all dependencies to sun samples ?

eyshi gravatar imageeyshi ( 2019-10-17 15:22:43 -0600 )edit

On windows I just built with Visual Studio after generating the solution files with CMake. It looks like the only external dependency is FreeImage which is used to load and save images in the samples.

The lib and shared lib for windows are both in the SDK Samples\External\FreeImage\x64 folder. I guess on ubuntu you should be able to apt-get install?

cudawarped gravatar imagecudawarped ( 2019-10-17 16:01:01 -0600 )edit

On using opencv 4.1.2 cudaoptflow samples file functions on 4k video, how long does it take for you to tun first 1000 frames? for me it is taking 25 mins which is insane.. though I used sam function from sample file

eyshi gravatar imageeyshi ( 2019-10-22 00:51:27 -0600 )edit

Whilst I have not tested cudaoptflow on video, I have checked its performance on the first two frames from 4k sample video's provided here using the OpenCV perfomance test opencv_perf_cudaoptflow.exe on an RTX 2080 with the following filter


The results for the first two frames are Fast: 7.99 ms Medium: 11.35 ms Slow: 21.49 ms CPU upscale: 50 ms (Release) Therefore I would estimate 1000 frames excluding decoding should take a maximum of 72 seconds.

cudawarped gravatar imagecudawarped ( 2019-10-23 06:13:24 -0600 )edit

Question Tools

1 follower


Asked: 2019-10-16 12:47:09 -0600

Seen: 582 times

Last updated: Oct 16 '19