The code is running fine for me:
# main.cpp
#include <ATen/Functions.h>
#include <iostream>
#include <cmath>

void debug_memory_issue() {
  int FHW = 3;
  int padding = 1;
  auto N = 1;
  auto C = 1;
  auto HW = 16;
  at::Tensor imgs = at::rand({N, C, HW, HW}).to(at::kCUDA);
  at::Tensor fils = at::rand({C, C, FHW, FHW}).to(at::kCUDA);
  std::cout << "running conv" << std::endl;
  at::conv2d(imgs, fils, /* bias */ {}, /* stride */ 1, padding);
  std::cout << "done running conv" << std::endl;
}

int main() {
  debug_memory_issue();
}

# CMakeLists.txt
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)

find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")

add_executable(example-app main.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)

# in ./builds
$ cmake -DCMAKE_PREFIX_PATH=PATH_TO_LIBTORCH ..
$ cmake --build . --config Release
$ ./example-app
$ running conv
$ done running conv

I’ve tested it using libtorch 1.5.0 with CUDA10.2.
Maybe your CUDA installation is too old for your GPU or incompatible with the driver you are using?
Have you used the local CUDA installation before or did you use the PyTorch binaries, which ship with CUDA?