Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
6840a7bb
Unverified
Commit
6840a7bb
authored
Jul 04, 2025
by
JieXin Liang
Committed by
GitHub
Jul 03, 2025
Browse files
[fix] put cpu in the first priority in get_device() (#7752)
parent
c01a1df5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
python/sglang/srt/utils.py
python/sglang/srt/utils.py
+9
-9
No files found.
python/sglang/srt/utils.py
View file @
6840a7bb
...
...
@@ -1443,6 +1443,15 @@ def is_habana_available() -> bool:
@
lru_cache
(
maxsize
=
8
)
def
get_device
(
device_id
:
Optional
[
int
]
=
None
)
->
str
:
if
is_cpu
():
if
cpu_has_amx_support
():
logger
.
info
(
"Intel AMX is detected, using CPU with Intel AMX support."
)
else
:
logger
.
warning
(
"CPU device enabled, using torch native backend, low performance expected."
)
return
"cpu"
if
hasattr
(
torch
,
"cuda"
)
and
torch
.
cuda
.
is_available
():
if
device_id
is
None
:
return
"cuda"
...
...
@@ -1471,15 +1480,6 @@ def get_device(device_id: Optional[int] = None) -> str:
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
)
if
is_cpu
():
if
cpu_has_amx_support
():
logger
.
info
(
"Intel AMX is detected, using CPU with Intel AMX support."
)
else
:
logger
.
warning
(
"CPU device enabled, using torch native backend, low performance expected."
)
return
"cpu"
raise
RuntimeError
(
"No accelerator (CUDA, XPU, HPU) is available."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment