Add device checking when set_device.