Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
49613414
Unverified
Commit
49613414
authored
1 year ago
by
CokeDong
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[Feature] Support dipu device (#1127)
parent
74512162
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmengine/device/__init__.py
+3
-3
3 additions, 3 deletions
mmengine/device/__init__.py
mmengine/device/utils.py
+12
-0
12 additions, 0 deletions
mmengine/device/utils.py
with
15 additions
and
3 deletions
mmengine/device/__init__.py
+
3
−
3
View file @
49613414
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from
.utils
import
(
get_device
,
get_max_cuda_memory
,
is_cuda_available
,
from
.utils
import
(
get_device
,
get_max_cuda_memory
,
is_cuda_available
,
is_mlu_available
,
is_mps_available
,
is_npu_available
,
is_dipu_available
,
is_mlu_available
,
is_mps_available
,
is_npu_support_full_precision
)
is_npu_available
,
is_npu_support_full_precision
)
__all__
=
[
__all__
=
[
'
get_max_cuda_memory
'
,
'
get_device
'
,
'
is_cuda_available
'
,
'
get_max_cuda_memory
'
,
'
get_device
'
,
'
is_cuda_available
'
,
'
is_mlu_available
'
,
'
is_mps_available
'
,
'
is_npu_available
'
,
'
is_mlu_available
'
,
'
is_mps_available
'
,
'
is_npu_available
'
,
'
is_npu_support_full_precision
'
'
is_dipu_available
'
,
'
is_npu_support_full_precision
'
]
]
This diff is collapsed.
Click to expand it.
mmengine/device/utils.py
+
12
−
0
View file @
49613414
...
@@ -16,6 +16,12 @@ try:
...
@@ -16,6 +16,12 @@ try:
except
Exception
:
except
Exception
:
IS_NPU_AVAILABLE
=
False
IS_NPU_AVAILABLE
=
False
try
:
import
torch_dipu
# noqa: F401
IS_DIPU_AVAILABLE
=
True
except
Exception
:
IS_DIPU_AVAILABLE
=
False
def
get_max_cuda_memory
(
device
:
Optional
[
torch
.
device
]
=
None
)
->
int
:
def
get_max_cuda_memory
(
device
:
Optional
[
torch
.
device
]
=
None
)
->
int
:
"""
Returns the maximum GPU memory occupied by tensors in megabytes (MB) for
"""
Returns the maximum GPU memory occupied by tensors in megabytes (MB) for
...
@@ -63,6 +69,10 @@ def is_mps_available() -> bool:
...
@@ -63,6 +69,10 @@ def is_mps_available() -> bool:
return
hasattr
(
torch
.
backends
,
'
mps
'
)
and
torch
.
backends
.
mps
.
is_available
()
return
hasattr
(
torch
.
backends
,
'
mps
'
)
and
torch
.
backends
.
mps
.
is_available
()
def
is_dipu_available
()
->
bool
:
return
IS_DIPU_AVAILABLE
def
is_npu_support_full_precision
()
->
bool
:
def
is_npu_support_full_precision
()
->
bool
:
"""
Returns True if npu devices support full precision training.
"""
"""
Returns True if npu devices support full precision training.
"""
version_of_support_full_precision
=
220
version_of_support_full_precision
=
220
...
@@ -79,6 +89,8 @@ elif is_mlu_available():
...
@@ -79,6 +89,8 @@ elif is_mlu_available():
DEVICE
=
'
mlu
'
DEVICE
=
'
mlu
'
elif
is_mps_available
():
elif
is_mps_available
():
DEVICE
=
'
mps
'
DEVICE
=
'
mps
'
elif
is_dipu_available
():
DEVICE
=
'
dipu
'
def
get_device
()
->
str
:
def
get_device
()
->
str
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment