Platform detection fix

If there was a device with no gpu before a device with gpus the program would exit prematurely.