Repository: pytorch
Issue: torch compile error with SyncBatchNorm
Labels: oncall: distributed,good first issue,triaged,module: c10d,oncall: pt2,module: dynamo,pt2d-triage-nov2024

### 🐛 Describe the bug

The error was triggered during training using torch.compile with DDP and SyncBatchNorm.

DDP + SyncBatchNorm, working normally
torch.compile + DDP, working normally
torch.compile + single gpu, working normally
torch.compile + DDP + SyncBatchNorm, not working and raised error below

I do 2 exercise, and all they get error, but error has some differece. 
The first one appear on my work code, the error is bellow:
 
the second appear on my test code.

my code:
```
import time
import torch
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import torch.nn as nn
from tqdm import tqdm
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
import argparse
import os
from torch import _dynamo 

# torch._dynamo.config.verbose = True
# torch._dynamo.config.suppress_errors = True

#卷积模块，由卷积核和激活函数组成
class conv_block(nn.Module):
    def __init__(self,ks,ch_in,ch_out):
        super(conv_block,self).__init__()
        self.conv = nn.Sequential(
            nn.Conv2d(ch_in, ch_out, kernel_size=ks,stride=1,padding=1,bias=True),  #二维卷积核，用于提取局部的图像信息
            nn.BatchNorm2d(ch_out),
            nn.ReLU(inplace=True), #这里用ReLU作为激活函数
            nn.Conv2d(ch_out, ch_out, kernel_size=ks,stride=1,padding=1,bias=True),
            nn.BatchNorm2d(ch_out),
            nn.ReLU(inplace=True),
        )
    def forward(self,x):
        return self.conv(x)

class CNN(nn.Module):
    def __init__(self,kernel_size,in_ch,out_ch):
        super(CNN, self).__init__()
        feature_list = [16,32,64,128,256]   #代表每一层网络的特征数，扩大特征空间有助于挖掘更多的局部信息
        self.conv1 = conv_block(kernel_size,in_ch,feature_list[0])
        self.conv2 = conv_block(kernel_size,feature_list[0],feature_list[1])
        self.conv3 = conv_block(kernel_size,feature_list[1],feature_list[2])
        self.conv4 = conv_block(kernel_size,feature_list[2],feature_list[3])
        self.conv5 = conv_block(kernel_size,feature_list[3],feature_list[4])
        self.fc =  nn.Sequential(           #全连接层主要用来进行分类，整合采集的局部信息以及全局信息
            nn.Linear(feature_list[4] * 28 * 28, 1024),  #此处28为MINST一张图片的维度
            nn.ReLU(),
            nn.Linear(1024, 512),
            nn.ReLU(),
            nn.Linear(512, 10)
        )
 
    def forward(self,x):
        device = x.device
        x1 = self.conv1(x )
        x2 = self.conv2(x1)
        x3 = self.conv3(x2)
        x4 = self.conv4(x3)
        x5 = self.conv5(x4)
        x5 = x5.view(x5.size()[0], -1)  #全连接层相当于做了矩阵乘法，所以这里需要将维度降维来实现矩阵的运算
        out = self.fc(x5)
        return out



parser = argparse.ArgumentParser()
if (torch.__version__).startswith('2.0'):
    parser.add_argument("--local-rank", type=int, required=False)
else:
    parser.add_argument("--local_rank", type=int, required=False)
parser.add_argument("--gpus", type=str, required=True)
parser.add_argument("--ngpus", default=1, type=int)
args = parser.parse_args()
# local_rank = os.environ['LOCAL_RANK']
local_rank = args.local_rank
if args.gpus == "all":
    gpus = [str(i) for i in range(args.ngpus)]
else:
    gpus = args.gpus.split(",")
# os.environ["CUDA_VISIBLE_DEVIECES"]=str(gpus[local_rank])
torch.cuda.set_device(local_rank)  # 等价？
## DDP 初始化
dist.init_process_group(backend='nccl')


# 检查GPU是否可用
# device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu")

# 定义数据预处理和加载器
transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize((0.5,), (0.5,))
])
train_dataset = datasets.MNIST('data', train=True, download=True, transform=transform)
# train_loader = DataLoader(train_dataset, batch_size=64, shuffle=True)
ddp_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)
train_loader = DataLoader(train_dataset, 
                          batch_size=64, 
                          num_workers=2, 
                          pin_memory=True,
                          drop_last= True,
                        sampler=ddp_sampler)


# 准备模型
input_size = 28*28
output_size = 10
model = CNN(3,1,1).cuda()
# model = torch.nn.Linear(input_size, output_size).to(device)
# model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet18', pretrained=True).to(device)

ckpt_path = None
if dist.get_rank() == 0 and ckpt_path is not None:
    model.load_state_dict(torch.load(ckpt_path))


process_group = torch.distributed.new_group(range(dist.get_world_size()))


# DDP: 构造DDP model
# model = DDP(model, device_ids=[local_rank], output_device=local_rank) 
# model = DDP(model, find_unused_parameters=True) 
model = DDP(model)

model = nn.SyncBatchNorm.convert_sync_batchnorm(
    model, process_group
)

# pytorch2 compile
model = torch.compile(model, backend="inductor")


# 定义损失函数和优化器
criterion = torch.nn.CrossEntropyLoss().cuda() #?? 需要GPU??
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)


# 记录处理的图片数量和总时间
total_images = 0
epoch_time =  0.0
total_time = 0.0

# 迭代训练
model.train()
num_epochs = 10
for epoch in tqdm(range(num_epochs)):
    start = time.time()
    #DistributeSample 通过set_epoch来shuffle
    train_loader.sampler.set_epoch(epoch)
    for step,(images, labels) in tqdm(enumerate(train_loader)):
        # 将数据传输到GPU
        images = images.cuda()
        labels = labels.cuda()
        # 前向传播
        output = model(images)
        loss = criterion(output, labels)
        # 反向传播和参数更新
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

        # 更新统计数据
        total_images += len(images)
    print(f'loss:{loss.cpu():.4f}')
    end = time.time()
    epoch_time = end - start
    total_time += epoch_time
    print(f"epoch {epoch} time:{epoch_time:2f} seconds")
    
    if dist.get_rank() == 0:
        torch.save(model.module.state_dict(),"%d.ckpt"%epoch)

# 输出结果
print(f"Total images processed: {total_images}")
print(f"Total time taken: {total_time:.2f} seconds")

```

### Error logs

the first one:
```
[2023-08-16 04:02:30,771 init_dataloaders.py] [INIT_DATALOADERS] Initializing train dataloaders...
trainScanning '/mnt/share-gpuserver-1-disk2-nfs/datasets/xfy_detection_50/json_list/test_sample.cache' images and 
[2023-08-16 04:02:37,087 init_evaluators.py] [INIT_EVALUATORS] Initializing evaluators...
[2023-08-16 04:02:37,089 init_visualizers.py] [INIT_VISUALIZERS] Initializing visualizers...
trainScanning '/mnt/share-gpuserver-1-disk2-nfs/datasets/xfy_detection_50/json_list/test_sample.cache' images and 
[2023-08-16 04:02:37,246 regnet_legacy.py] Restoring ImageNet pretrained weights for backbone...
[2023-08-16 04:02:37,247 model_utils.py] [MODEL_RESTORE] Restoring weights from /home/victorzeng/code/exeggutor_dev/assets/pretrained_weights/regnetx_008_imagenet.pth
[2023-08-16 04:02:37,323 model_utils.py] =========================================
[2023-08-16 04:02:37,323 model_utils.py] [MODEL_RESTORE] missing key model: fc.bias
[2023-08-16 04:02:37,324 model_utils.py] [MODEL_RESTORE] missing key model: fc.weight
[2023-08-16 04:02:37,324 model_utils.py] =========================================
[2023-08-16 04:02:37,326 model_utils.py] [MODEL_RESTORE] Trying to restore 318 keys...
WARNING:exeggutor:[MODEL_RESTORE] missing key model: fc.bias
WARNING:exeggutor:[MODEL_RESTORE] missing key model: fc.weight
[2023-08-16 04:02:38,558 model_utils.py] [MODEL_RESTORE] Restoring weights from /home/victorzeng/code/exeggutor_dev/train_dir/mtl_ft_50_single_0528_xfy_try1/latest.pth
[2023-08-16 04:02:39,065 model_utils.py] [MODEL_RESTORE] Best epoch: 100
[2023-08-16 04:02:39,103 model_utils.py] =========================================
[2023-08-16 04:02:39,104 model_utils.py] =========================================
[2023-08-16 04:02:39,112 model_utils.py] [MODEL_RESTORE] Trying to restore 534 keys...
[2023-08-16 04:02:42,034 general.py] running command bash -c 'git config --get remote.origin.url'...
[2023-08-16 04:02:42,047 general.py] running command bash -c 'git rev-parse --verify HEAD'...
[2023-08-16 04:02:42,060 general.py] running command bash -c 'git diff > /mnt/gpuserver-1-disk0-nfs/victorzeng/exeggutor_workspace/models/mtl_ft_50_single_20230618_regnet_xyf_test/code_diff.patch'...
[2023-08-16 04:02:42,088 save_version_metas.py] Version metas saved at /mnt/gpuserver-1-disk0-nfs/victorzeng/exeggutor_workspace/models/mtl_ft_50_single_20230618_regnet_xyf_test/version_metas.yaml
[2023-08-16 04:02:42,088 check_anchors.py] Analyzing anchors for xfy_detection_50
[2023-08-16 04:02:42,100 autoanchor.py] [AUTOANCHOR] anchors/target = 4.33, Best Possible Recall (BPR) = 1.0000
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 244, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 291, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 259, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 92, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 203, in call_function
    return wrap_fx_proxy(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 754, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 789, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1143, in get_fake_value
    nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in deepcopy_to_fake_tensor
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 808, in wrap_fake_exception
    return fn()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in <lambda>
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'torch._C._distributed_c10d.ProcessGroup' object

from user code:
   File "/home/victorzeng/code/exeggutor_core/exeggutor_core/model/backbones/regnet_legacy.py", line 233, in forward
    return self._forward_impl(x)
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/model/backbones/regnet_legacy.py", line 221, in _forward_impl
    x = self.bn1(x)


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 150, in <module>
    main()
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 146, in main
    train()
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 135, in train
    trainer.train()
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/trainers/base_trainer.py", line 115, in train
    self.train_epoch()
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/trainers/base_trainer.py", line 142, in train_epoch
    net_outputs = self.model(all_imgs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 82, in forward
    return self.dynamo_ctx(self._orig_mod.forward)(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1156, in forward
    output = self._run_ddp_forward(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1113, in _run_ddp_forward
    return module_to_run(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 334, in catch_errors
    return hijacked_callback(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 394, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError
Exception in thread Thread-2 (_pin_memory_loop):
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 244, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 291, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 259, in call_function
    return super().call_function(tx, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/functions.py", line 92, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 203, in call_function
    return wrap_fx_proxy(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 754, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 789, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1143, in get_fake_value
    nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in deepcopy_to_fake_tensor
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 808, in wrap_fake_exception
    return fn()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in <lambda>
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'torch._C._distributed_c10d.ProcessGroup' object

from user code:
   File "/home/victorzeng/code/exeggutor_core/exeggutor_core/model/backbones/regnet_legacy.py", line 233, in forward
    return self._forward_impl(x)
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/model/backbones/regnet_legacy.py", line 221, in _forward_impl
    x = self.bn1(x)


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 150, in <module>
    main()
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 146, in main
    train()
  File "/home/victorzeng/code/exeggutor_dev/train.py", line 135, in train
    trainer.train()
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/trainers/base_trainer.py", line 115, in train
    self.train_epoch()
  File "/home/victorzeng/code/exeggutor_core/exeggutor_core/trainers/base_trainer.py", line 142, in train_epoch
    net_outputs = self.model(all_imgs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 82, in forward
    return self.dynamo_ctx(self._orig_mod.forward)(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1156, in forward
    output = self._run_ddp_forward(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1113, in _run_ddp_forward
    return module_to_run(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 334, in catch_errors
    return hijacked_callback(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 394, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError
Exception in thread Thread-3 (_pin_memory_loop):
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 51, in _pin_memory_loop
    do_one_step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/utils/data/_utils/pin_memory.py", line 28, in do_one_step
    r = in_queue.get(timeout=MP_STATUS_CHECK_INTERVAL)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/multiprocessing/queues.py", line 122, in get
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 2472590) of binary: /home/victorzeng/anaconda3/envs/exeggutor_pytorch2/bin/python
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/bin/torchrun", line 8, in <module>
    sys.exit(main())
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 346, in wrapper
    return f(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/run.py", line 794, in main
    run(args)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/run.py", line 785, in run
    elastic_launch(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 134, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 250, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
train.py FAILED
------------------------------------------------------------
Failures:
[1]:
  time      : 2023-08-16_04:02:51
  host      : gaussian-SYS-4029GP-TRT
  rank      : 1 (local_rank: 1)
  exitcode  : 1 (pid: 2472591)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2023-08-16_04:02:51
  host      : gaussian-SYS-4029GP-TRT
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 2472590)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
============================================================


the second one:
```
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 244, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 184, in call_function
    tx.call_function(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 203, in call_function
    return wrap_fx_proxy(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 754, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 789, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1143, in get_fake_value
    nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in deepcopy_to_fake_tensor
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 808, in wrap_fake_exception
    return fn()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in <lambda>
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'torch._C._distributed_c10d.ProcessGroup' object

from user code:
   File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 50, in forward
    x1 = self.conv1(x )
  File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 29, in forward
    return self.conv(x)

Set torch._dynamo.config.verbose=True for more information


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 153, in <module>
    output = model(images)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 82, in forward
    return self.dynamo_ctx(self._orig_mod.forward)(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1156, in forward
    output = self._run_ddp_forward(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1113, in _run_ddp_forward
    return module_to_run(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 334, in catch_errors
    return hijacked_callback(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 394, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError
  0%|                                                                                                  | 0/10 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 324, in _compile
    out_code = transform_code_object(code, transform)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 445, in transform_code_object
    transformations(instructions, code_options)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 311, in transform
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1726, in run
    super().run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 244, in call_function
    return tx.inline_user_function_return(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 510, in inline_user_function_return
    result = InliningInstructionTranslator.inline_call(self, fn, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1806, in inline_call
    return cls.inline_call_(parent, func, args, kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1862, in inline_call_
    tracer.run()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 576, in run
    and self.step()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 540, in step
    getattr(self, inst.opname)(inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 342, in wrapper
    return inner_fn(self, inst)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 965, in CALL_FUNCTION
    self.call_function(fn, args, {})
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 184, in call_function
    tx.call_function(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 474, in call_function
    self.push(fn.call_function(self, args, kwargs))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/nn_module.py", line 203, in call_function
    return wrap_fx_proxy(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 754, in wrap_fx_proxy
    return wrap_fx_proxy_cls(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/variables/builder.py", line 789, in wrap_fx_proxy_cls
    example_value = get_fake_value(proxy.node, tx)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 1143, in get_fake_value
    nnmodule = deepcopy_to_fake_tensor(nnmodule, tx.fake_mode)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in deepcopy_to_fake_tensor
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 808, in wrap_fake_exception
    return fn()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 819, in <lambda>
    return wrap_fake_exception(lambda: copy.deepcopy(obj))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'torch._C._distributed_c10d.ProcessGroup' object

from user code:
   File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 50, in forward
    x1 = self.conv1(x )
  File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 29, in forward
    return self.conv(x)

Set torch._dynamo.config.verbose=True for more information


You can suppress this exception and fall back to eager by setting:
    torch._dynamo.config.suppress_errors = True


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/victorzeng/code/exeggutor_dev/script/mnist_cnn_gpu_ddp.py", line 153, in <module>
    output = model(images)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 82, in forward
    return self.dynamo_ctx(self._orig_mod.forward)(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 209, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1156, in forward
    output = self._run_ddp_forward(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/parallel/distributed.py", line 1113, in _run_ddp_forward
    return module_to_run(*inputs, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 334, in catch_errors
    return hijacked_callback(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 404, in _convert_frame
    result = inner_convert(frame, cache_size, hooks)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 104, in _fn
    return fn(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 262, in _convert_frame_assert
    return _compile(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/utils.py", line 163, in time_wrapper
    r = func(*args, **kwargs)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 394, in _compile
    raise InternalTorchDynamoError() from e
torch._dynamo.exc.InternalTorchDynamoError
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 272795) of binary: /home/victorzeng/anaconda3/envs/exeggutor_pytorch2/bin/python
Traceback (most recent call last):
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launch.py", line 196, in <module>
    main()
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launch.py", line 192, in main
    launch(args)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launch.py", line 177, in launch
    run(args)
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/run.py", line 785, in run
    elastic_launch(
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 134, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/home/victorzeng/anaconda3/envs/exeggutor_pytorch2/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 250, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
mnist_cnn_gpu_ddp.py FAILED
------------------------------------------------------------
Failures:
[1]:
  time      : 2023-08-17_05:29:33
  host      : gaussian-SYS-4029GP-TRT
  rank      : 1 (local_rank: 1)
  exitcode  : 1 (pid: 272796)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2023-08-17_05:29:33
  host      : gaussian-SYS-4029GP-TRT
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 272795)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
============================================================
```

### Minified repro

_No response_

### Versions

Collecting environment information...
PyTorch version: 2.0.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.25.0
Libc version: glibc-2.31

Python version: 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.8.0-41-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 2080 Ti
GPU 1: NVIDIA GeForce RTX 2080 Ti
GPU 2: NVIDIA GeForce RTX 2080 Ti
GPU 3: NVIDIA GeForce RTX 2080 Ti

Nvidia driver version: 525.125.06
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.2.4
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.2.4
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          96
On-line CPU(s) list:             0-95
Thread(s) per core:              2
Core(s) per socket:              24
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           85
Model name:                      Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz
Stepping:                        4
CPU MHz:                         2626.184
CPU max MHz:                     3700.0000
CPU min MHz:                     1200.0000
BogoMIPS:                        5400.00
Virtualization:                  VT-x
L1d cache:                       1.5 MiB
L1i cache:                       1.5 MiB
L2 cache:                        48 MiB
L3 cache:                        66 MiB
NUMA node0 CPU(s):               0-23,48-71
NUMA node1 CPU(s):               24-47,72-95
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; Clear CPU buffers; SMT vulnerable
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear flush_l1d

Versions of relevant libraries:
[pip3] numpy==1.24.1
[pip3] torch==2.0.1+cu118
[pip3] torchaudio==2.0.2+cu118
[pip3] torchvision==0.15.2+cu118
[pip3] triton==2.0.0
[conda] numpy                     1.24.1                   pypi_0    pypi
[conda] torch                     2.0.1+cu118              pypi_0    pypi
[conda] torchaudio                2.0.2+cu118              pypi_0    pypi
[conda] torchvision               0.15.2+cu118             pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi

cc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @amjames @ezyang @msaroufim @bdhirsh @anijain2305 @Xia-Weiwen @ipiszy @aakhundov