How to use fix randomGenerator in multithread?

my code like:

#include <iostream>
#include "torch/torch.h"
int main() {
    torch::Tensor mu=torch::zeros(1);
    torch::Tensor std=torch::ones(1);
    std::vector<double> vc;
    vc.reserve(8);
#pragma omp parallel for num_threads(8) default(shared)
    for(int i=0;i<8;++i){
        int tdidx=omp_get_thread_num();
        torch::manual_seed(1);
        c10::optional<at::Generator> generator;
        generator->set_current_seed(tdidx);// leads to the error
        vc[tdidx]=at::normal(mu,std,generator).item<float>();
        std::cout<<at::normal(mu,std).item<float>() <<""<<tdidx<<std::endl;
    }
    std::cout<<"!!!!!!!!!!!!!" <<std::endl;
    std::cout<< vc[0]<<std::endl;
    std::cout<< vc[1]<<std::endl;
    std::cout<< vc[2]<<std::endl;
    return 0;
}

and I got:“Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)”
any idea?