capstone2019-neuralsearch / AC297r_2019_NAS

Harvard IACS Data Science Capstone: Neural Architecture Search (NAS) with Google
5 stars 1 forks source link

Convert DARTS to CPU #8

Open JiaweiZhuang opened 4 years ago

JiaweiZhuang commented 4 years ago

The original DARTS code (https://github.com/quark0/darts) has .cuda() hard-coded everywhere. At development & debugging stage, we don't really need a GPU. For example to assert the input shape (#7), it is much more convenient to use the local laptop CPU.

A better way is

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

and use .to(device) instead of .cuda()

However, .cuda() appears at too many places, so I am not sure if this refactor is worthwhile.