Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mmcv/parallel/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch
from torch import Tensor
from torch.nn.parallel._functions import _get_stream

from packaging import version

def scatter(input: Union[List, Tensor],
devices: List,
Expand Down Expand Up @@ -72,7 +72,10 @@ def forward(target_gpus: List[int], input: Union[List, Tensor]) -> tuple:
streams = None
if input_device == -1 and target_gpus != [-1]:
# Perform CPU to GPU copies in a background stream
streams = [_get_stream(device) for device in target_gpus]
if version.parse(torch.__version__) >= version.parse('2.1.0'):
streams = [_get_stream(torch.device("cuda", device)) for device in target_gpus]
else:
streams = [_get_stream(device) for device in target_gpus]

outputs = scatter(input, target_gpus, streams)
# Synchronize with the copy stream
Expand Down
Loading