Solved by jb892 in post #3 
              
              
                After some research and debugging work, I just figure out what’s wrong. Basically I forgot to make my network cuda enable. Just add one line of code and it works fine now. Source code: 
#include <torch/torch.h>

using namespace torch;

struct ConvNet : nn::Module
{
    ConvNet()
        :conv1(nn::C…