Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for torch version larger than 2.1.0 #3247

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
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