Solved by a_d in post #2 
              
              
                The answer is quite simple, you have to reassign the variable in the to method. For example 
input = input.to(torch::kCUDA) and it will work.