You can try my module:

  
      
      GitHub
  
  
    

QuantScientist/PngTorch 7

An integration of the libpng /png++ libraries with the Libtorch C++ Deep Learning Library.  - QuantScientist/PngTorch


  
  
    
    
  
  


It will download libtorch automatically.
All you have to do is to change https://github.com/QuantScientist/PngTorch/blob/master/cmake_find/download_libtorch.cmake: 11
set(CUDA_V "cpu")
set(LIBTORCH_DEVICE "cpu")

#set(CUDA_V "10.2")
#set(LIBTORCH_DEVICE "cu102")

This is based on code from https://github.com/prabhuomkar/pytorch-cpp/ 6
Best,