服务器 PyTorch 报错 重装 PyTorch

时间:2022-02-07 12:21:58

两个代码,pix2pix + CycleGan ,  wgan-gp 都是 pytorch 写的, 在服务器端运行,均存在下列问题,故判定是 pytorch 的安装问题。

Traceback (most recent call last): File "train.py", line 13, in <module> model = create_model(opt) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/models.py", line 19, in create_model model.initialize(opt) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/cycle_gan_model.py", line 31, in initialize opt.ngf, opt.which_model_netG, opt.norm, not opt.no_dropout, self.gpu_ids) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/networks.py", line 38, in define_G norm_layer = get_norm_layer(norm_type=norm) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/networks.py", line 29, in get_norm_layer norm_layer = functools.partial(nn.InstanceNorm2d, affine=False) AttributeError: 'module' object has no attribute 'InstanceNorm2d' Traceback (most recent call last): File "train.py", line 13, in <module> model = create_model(opt) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/models.py", line 19, in create_model model.initialize(opt) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/cycle_gan_model.py", line 31, in initialize opt.ngf, opt.which_model_netG, opt.norm, not opt.no_dropout, self.gpu_ids) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/networks.py", line 38, in define_G norm_layer = get_norm_layer(norm_type=norm) File "/wlwsea/pytorch-CycleGAN-and-pix2pix-master/models/networks.py", line 29, in get_norm_layer norm_layer = functools.partial(nn.InstanceNorm2d, affine=False) AttributeError: 'module' object has no attribute 'InstanceNorm2d'

pytorch 安装十分便利,几秒钟大约,网址  http://pytorch.org/

服务器 PyTorch 报错  重装 PyTorch

pix2pix + CycleGan 运行时可能缺包,是关键包没有安装,

服务器 PyTorch 报错  重装 PyTorch

visdom这个包,主要是显示文字和图片,而在服务器端无法显示,所以,原始的命令后面要加 --display_id 0 。

python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan --no_dropout --display_id 0