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

Update metric.py,support multi-server training with Ascend 910B #1578

Open
wants to merge 1 commit into
base: main
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
10 changes: 9 additions & 1 deletion mmengine/evaluator/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@

from torch import Tensor

import torch
import torch_npu
from torch_npu.contrib import transfer_to_npu

from mmengine.dist import (broadcast_object_list, collect_results,
is_main_process)
from mmengine.fileio import dump
from mmengine.logging import print_log
from mmengine.registry import METRICS
from mmengine.structures import BaseDataElement
from mmengine.device import is_npu_available


class BaseMetric(metaclass=ABCMeta):
Expand Down Expand Up @@ -49,7 +54,10 @@ def __init__(self,
"`collect_device='cpu'`")

self._dataset_meta: Union[None, dict] = None
self.collect_device = collect_device
if is_npu_available():
self.collect_device = 'gpu'
else:
self.collect_device = collect_device
self.results: List[Any] = []
self.prefix = prefix or self.default_prefix
self.collect_dir = collect_dir
Expand Down