环境情况:
CUDA版本: 11.3
python=3.9
visdom=0.2.4
pytorch=1.12.1
torchvision=0.13.1
问题一:运行demo出现错误KeyError: ((1, 1, 64), '|u1')
修改CDFA_model中代码
self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离
self.feat_A = self.feat_A.permute(0, 2, 3, 1)
self.feat_B = self.feat_B.permute(0, 2, 3, 1)
self.dist = F.pairwise_distance(self.feat_A, self.feat_B, keepdim=True) # 特征距离
self.dist = self.dist.permute(0,3, 1, 2)
问题二:运行train.py出现错误[WinError 10061] 由于目标计算机积极拒绝,无法连接。
并且Could not connect to Visdom server.
错误原因是没有启动visdom。进入Anaconda相应环境,输入python -m visdom.server 或visdom 。问题即可解决
然后在浏览器打开 ‘http://localhost:8097’实现可视化
问题三:运行完第五个epoch后出现IndexError: boolean index did not match indexed array along dimension 0; dimension is 4194304 but corresponding boolean dimension is 65536
或RuntimeError: CUDA out of memory. Tried to allocate 2.00 GiB (GPU 0; 4.00 GiB total capacity; 2.98 GiB already allocated; 0 bytes free; 3.39 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
不要直接运行train.py。用终端运行,python ./train.py --save_epoch_freq 1 --angle 15 --dataroot ./LEVIR-CD/train --val_dataroot ./LEVIR-CD/val --name LEVIR-CDFAp0 --lr 0.001 --model CDFA --SA_mode PAM --batch_size 8 --load_size 256 --crop_size 256 --preprocess rotate_and_crop --ds 4
(在开源代码给出的命令行后添加--ds 4)