MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / parse_devices

Function parse_devices

utils/pyt_utils.py:202–225  ·  view source on GitHub ↗
(input_devices)

Source from the content-addressed store, hash-verified

200
201
202def parse_devices(input_devices):
203 if input_devices.endswith("*"):
204 devices = list(range(torch.cuda.device_count()))
205 return devices
206
207 devices = []
208 for d in input_devices.split(","):
209 if "-" in d:
210 start_device, end_device = d.split("-")[0], d.split("-")[1]
211 assert start_device != ""
212 assert end_device != ""
213 start_device, end_device = int(start_device), int(end_device)
214 assert start_device < end_device
215 assert end_device < torch.cuda.device_count()
216 for sd in range(start_device, end_device + 1):
217 devices.append(sd)
218 else:
219 device = int(d)
220 assert device <= torch.cuda.device_count()
221 devices.append(device)
222
223 logger.info("using devices {}".format(", ".join([str(d) for d in devices])))
224
225 return devices
226
227
228def extant_file(x):

Callers

nothing calls this directly

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected