Search code examples
cudagpusift

Why am I getting this cuda out of memory error on my new computer and not on the old one?


I'm currently trying to extract SIFT Features with the following package: https://github.com/Celebrandil/CudaSift

It comes with a CMakeLists.txt, which I modified, here it is:

cmake_minimum_required(VERSION 2.6)

project(cudaSift)
set(cudaSift_VERSION_MAJOR 2)
set(cudaSift_VERSION_MINOR 0)
set(cudaSift_VERSION_PATCH 0)

set(CPACK_PACKAGE_VERSION_MAJOR "${cudaSift_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${cudaSift_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${cudaSift_VERSION_PATCH}")
set(CPACK_GENERATOR "ZIP")
include(CPack)

find_package(OpenCV REQUIRED)
find_package(CUDA)
if (NOT CUDA_FOUND)
  message(STATUS "CUDA not found. Project will not be built.")
endif(NOT CUDA_FOUND)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -msse2 ")
list(APPEND CUDA_NVCC_FLAGS "-lineinfo;-ccbin;/usr/bin/gcc-7;--compiler-options;-O2;-D_FORCE_INLINES;-DVERBOSE_NOT; -arch=sm_75") 

cuda_add_library(cudaSift SHARED
  src/cudaImage.cu  
  src/cudaSiftH.cu  
  src/matching.cu
  src/geomFuncs.cpp  
  src/mainSift.cpp
)

target_link_libraries(cudaSift ${CUDA_cudadevrt_LIBRARY} ${OpenCV_LIBS})

set(PUBLIC_HEADERS include/cudaImage.h include/cudaSift.h)

set_target_properties(cudaSift PROPERTIES PUBLIC_HEADER 
"${PUBLIC_HEADERS}"
)

include(GNUInstallDirs)
install(TARGETS cudaSift
  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

configure_file(cudaSift.pc.in cudaSift.pc @ONLY)

install(FILES ${CMAKE_BINARY_DIR}/cudaSift.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)


My GPU is a GeForce RTX 2060, driver version 430.5, and after running:

mkdir build && cd build
cmake ..
sudo make -j
sudo make install
sudo ldconfig

-in order to build the package, I try to run my code and get the following error:

safeCall() Runtime API error in file </path/to/CudaSift/src/cudaImage.cu>, line 24 : out of memory.

Precisions:

  • I run the exact same code on another computer which has a GeForce GTX 1050, only changing in CMakeLists.txt -arch=sm_75 to arch=sm_61 and it executes just fine.

  • From previous questions, I think this is a compilation problem, linked to the arch=sm_** value, but I changed it and it still doesn't work.

  • The objects i'm passing to my GPU are images, which I'm sure aren't too big, since it works on my other computer which GPU has less memory


Solution

  • UPDATE: I found the problem, the package was actually compiled properly. Actually A tensorflow model was loaded in the code, but after deleting it, the error didn't happen again. I don't know why though, maybe it reserved a lot of GPU memory ?