Yes, I am doing the same -
device_id = torch.cuda.device_count()
device = torch.cuda.get_device_name(range(device_id))

but it is throwing an error
Type Error: '<' not supported between instances of 'range' and 'int'