def get_device_name(self, device): """Returns a TF-style device identifier for the specified device. input: 'cpu' for CPU and 'gpuN' for the Nth GPU on the host""" if device == 'cpu': dev_num = 0 dev_type = 'cpu' elif device.startswith('gpu'): try: dev_num = int(device[3:]) dev_type = 'gpu' except ValueError: print ("GPU number could not be parsed from {}; using CPU".format(device)) dev_num = 0 dev_type = 'cpu' else: print ("Please specify 'cpu' or 'gpuN' for device name") dev_num = 0 dev_type = 'cpu' return get_device_name(dev_type, dev_num, backend='tensorflow')
def get_device_name(self, device): """Returns a TF-style device identifier for the specified device. input: 'cpu' for CPU and 'gpuN' for the Nth GPU on the host""" if device == 'cpu': dev_num = 0 dev_type = 'cpu' elif device.startswith('gpu'): try: dev_num = int(device[3:]) dev_type = 'gpu' except ValueError: print ("GPU number could not be parsed from {}; using CPU".format(device)) dev_num = 0 dev_type = 'cpu' else: print ("Please specify 'cpu' or 'gpuN' for device name") dev_num = 0 dev_type = 'cpu' return get_device_name(dev_type, dev_num, backend='tensorflow')