Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Commit charge (Private bytes) high with cudafilters

Hello,

I have issues with a very high Commit charge (as it is displayed in Windows by Resource Monitor) as soon as I start using CUDA filters in my application.

Here is a simple code to replicate the issue:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/cudafilters.hpp>
#include <iostream>

int main(int argc, char** argv)
{
  std::cout << cv::getBuildInformation() << std::endl;

  cv::Mat image = cv::Mat::ones(cv::Size(32, 32), CV_8UC1) * 128;
  cv::Ptr<cv::cuda::Filter> pFilter;
  //pFilter = cv::cuda::createBoxFilter(CV_8UC1, CV_8UC1, cv::Size(5, 5)); //(!!!)

  cv::namedWindow("Input", cv::WINDOW_AUTOSIZE);
  cv::imshow("Input", image);
  cv::waitKey(0);

  return 0;
}

With the line marked with (!!!) commented, the Commit is at 8136 KB. When I uncomment it, it jumps to 609952 KB.

I am using OpenCV 3.4.2 on Windows 10 64-bit, built with VS 2013 and CUDA v8.0 (more details about the build at the end of the message).

I've been struggling with this issue for several days, here's what I've been able to find out:

  1. Normally, the Commit size isn't so important, because the program will never actually use that insane amount. It's memory that's just reserved, but never used, so if other programs need resources, the unused but reserved memory pages can be transferred into the pagefile, where they will comfortably sit until my program ends.
  2. HOWEVER, if the sum of RAM + max page file size is insufficient, the program won't start! This is a problem with which I have to deal, as the software on which I'm working will have several instances of an exe running on different data at the same time, and I cannot change this.
  3. On a PC with insufficient RAM for all my exes but with more than enough Page file, all the instances of my program take a long time to start and to do the first image processing, because Windows is rearranging what pages it keeps in RAM and what in the Page File. Subsequent commands that call image processing routines are processed quickly, as there is never any need to re-transfer stuff back from the Page File (I always do more or less the same image processing operations).
  4. The issue is not so much related to opencv_world: whether you build OpenCV to get separate dlls or one big dll, I still get a large Commit size, although the amount is different.

Does anyone have any ideas as to how I can correct this issue? Am I doing something wrong, or is this a bug, or is this something unavoidable and I have to find a way to live with it? Any help will be much appreciated!

Note: my applications need to run on Maxwell and Pascal GPUs, no need for anything older.

Details about the build:

General configuration for OpenCV 3.4.2 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2018-07-16T12:39:40Z
    Host:                        Windows 10.0.16299 AMD64
    CMake:                       3.7.2
    CMake generator:             Visual Studio 12 2013 Win64
    CMake build tool:            C:/Program Files (x86)/MSBuild/12.0/bin/MSBuild.exe
    MSVC:                        1800

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (3 files):          + SSSE3 SSE4_1
      SSE4_2 (1 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (9 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++11:                       YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe  (ver 18.0.40629.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi      /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8   /MD /O2 /Ob2 /DNDEBUG
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi      /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8   /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_amd64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi        /MP8    /MD /O2 /Ob2 /DNDEBUG
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi        /MP8  /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:          cudart.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn features2d flann highgui imgcodecs imgproc ml objdetect photo shape stitching superres ts video videoio videostab
    Disabled:                    java_bindings_generator js python3 python_bindings_generator world
    Disabled by dependency:      -
    Unavailable:                 java python2 viz
    Applications:                apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI:
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 1.5.3-62)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (ver 1.6.34)
    TIFF:                        build (ver 42 - 4.0.9)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES

  Video I/O:
    Video for Windows:           YES
    DC1394:                      NO
    DirectShow:                  YES
    Media Foundation:            YES

  Parallel framework:            TBB (ver 2018.0 interface 10000)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2017.0.3 [2017.0.3]
           at:                   C:/OpenCV/opencv-3.4.2/build_separateDLLs/3rdparty/ippicv/ippicv_win
    Intel IPP IW:                sources (2017.0.3)
              at:                C:/OpenCV/opencv-3.4.2/build_separateDLLs/3rdparty/ippicv/ippiw_win
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 8.0, CUFFT CUBLAS NVCUVID FAST_MATH)
    NVIDIA GPU arch:             50 52 60 61
    NVIDIA PTX archs:

  OpenCL:                        YES (no extra features)
    Include path:                C:/OpenCV/opencv-3.4.2/sources/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            C:/ProgramData/Anaconda3/python.exe

  Java:
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Matlab:                        NO

  Install to:                    C:/OpenCV/opencv-3.4.2/build_separateDLLs/install
-----------------------------------------------------------------