Thanks @ptrblck here is the code
        th::Tensor L;
        try {
            L = th::cholesky(Xt.bmm(Xbtc));
        }
        catch (const std::exception & ex) {
            std::cout << "c++ exception: " << std::endl;
        }
        std::cout << L << std::endl;
        auto Gi = th::cholesky_solve(th::eye(p + 3, dtype_option.device(deviceifGPU)), L); // (X ^ T.X) ^ -1

It prints:
c++ exception:
[ Tensor (undefined) ]