torch_maml icon indicating copy to clipboard operation
torch_maml copied to clipboard

CPU环境训练

Open Chi20 opened this issue 1 year ago • 0 comments

以CPU模式运行的话,helper.py中

model = Classifier(1, args.n_way).cuda()

要把.cuda()调用改为.to(dev),其中dev是在args.py中设置的设备变量,确保dev被设置为'cpu'。 arg.py中需要:

  • 注释--gpu参数,因为在使用CPU进行训练时不需要指定GPU设备。
  • 注释设置环境变量CUDA_VISIBLE_DEVICES的代码,因为在使用CPU时不需要这一步骤。
  • 修改dev变量的赋值,直接将其设置为torch.device('cpu'),确保所有操作都在CPU上执行。

Chi20 avatar May 02 '24 05:05 Chi20