Skip to content

Commit 5766da5

Browse files
malfetfacebook-github-bot
authored andcommitted
Device name should be a string, not bytes (#40322)
Summary: I.e. do not accept `bytes` as possible type of `device` argument in `torch.cuda._get_device_index` Pull Request resolved: #40322 Differential Revision: D22176885 Pulled By: malfet fbshipit-source-id: 2f3a46174161f1cdcf6a6ad94a31e54b18ad6186
1 parent 0d24ed0 commit 5766da5

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

torch/cuda/_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import torch
2-
import torch._six
32
from typing import Optional, Union
43
from torch.types import Device
54

@@ -18,7 +17,7 @@ def _get_device_index(device: Union[Device, int], optional=False) -> int:
1817
If :attr:`device` is ``None``, this will return the current default CUDA
1918
device if :attr:`optional` is ``True``.
2019
"""
21-
if isinstance(device, torch._six.string_classes):
20+
if isinstance(device, str):
2221
device = torch.device(device)
2322
device_idx: Optional[int]
2423
if isinstance(device, torch.device):

0 commit comments

Comments
 (0)