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
ox696c
ktransformers
Commits
7549ff33
Commit
7549ff33
authored
Apr 01, 2025
by
fishingfly
Browse files
fix: refine backend error message to include ROCM_HOME
Signed-off-by:
fishingfly
<
zhoyuzf@163.com
>
parent
f142f4df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
setup.py
setup.py
+9
-9
No files found.
setup.py
View file @
7549ff33
...
@@ -67,17 +67,17 @@ class VersionInfo:
...
@@ -67,17 +67,17 @@ class VersionInfo:
def
get_rocm_bare_metal_version
(
self
,
rocm_dir
):
def
get_rocm_bare_metal_version
(
self
,
rocm_dir
):
"""
"""
Get the ROCm version from the ROCm installation directory.
Get the ROCm version from the ROCm installation directory.
Args:
Args:
rocm_dir: Path to the ROCm installation directory
rocm_dir: Path to the ROCm installation directory
Returns:
Returns:
A string representation of the ROCm version (e.g., "63" for ROCm 6.3)
A string representation of the ROCm version (e.g., "63" for ROCm 6.3)
"""
"""
try
:
try
:
# Try using rocm_agent_enumerator to get version info
# Try using rocm_agent_enumerator to get version info
raw_output
=
subprocess
.
check_output
(
raw_output
=
subprocess
.
check_output
(
[
rocm_dir
+
"/bin/rocminfo"
,
"--version"
],
[
rocm_dir
+
"/bin/rocminfo"
,
"--version"
],
universal_newlines
=
True
,
universal_newlines
=
True
,
stderr
=
subprocess
.
STDOUT
)
stderr
=
subprocess
.
STDOUT
)
# Extract version number from output
# Extract version number from output
...
@@ -90,7 +90,7 @@ class VersionInfo:
...
@@ -90,7 +90,7 @@ class VersionInfo:
except
(
subprocess
.
CalledProcessError
,
FileNotFoundError
):
except
(
subprocess
.
CalledProcessError
,
FileNotFoundError
):
# If rocminfo --version fails, try alternative methods
# If rocminfo --version fails, try alternative methods
pass
pass
try
:
try
:
# Try reading version from release file
# Try reading version from release file
with
open
(
os
.
path
.
join
(
rocm_dir
,
"share/doc/hip/version.txt"
),
"r"
)
as
f
:
with
open
(
os
.
path
.
join
(
rocm_dir
,
"share/doc/hip/version.txt"
),
"r"
)
as
f
:
...
@@ -100,7 +100,7 @@ class VersionInfo:
...
@@ -100,7 +100,7 @@ class VersionInfo:
return
rocm_version
return
rocm_version
except
(
FileNotFoundError
,
IOError
):
except
(
FileNotFoundError
,
IOError
):
pass
pass
# If all else fails, try to extract from directory name
# If all else fails, try to extract from directory name
dir_name
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
rocm_dir
))
dir_name
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
rocm_dir
))
match
=
re
.
search
(
r
'rocm-(\d+\.\d+)'
,
dir_name
)
match
=
re
.
search
(
r
'rocm-(\d+\.\d+)'
,
dir_name
)
...
@@ -109,7 +109,7 @@ class VersionInfo:
...
@@ -109,7 +109,7 @@ class VersionInfo:
version
=
parse
(
version_str
)
version
=
parse
(
version_str
)
rocm_version
=
f
"
{
version
.
major
}{
version
.
minor
}
"
rocm_version
=
f
"
{
version
.
major
}{
version
.
minor
}
"
return
rocm_version
return
rocm_version
# Fallback to extracting from hipcc version
# Fallback to extracting from hipcc version
try
:
try
:
raw_output
=
subprocess
.
check_output
(
raw_output
=
subprocess
.
check_output
(
...
@@ -124,7 +124,7 @@ class VersionInfo:
...
@@ -124,7 +124,7 @@ class VersionInfo:
return
rocm_version
return
rocm_version
except
(
subprocess
.
CalledProcessError
,
FileNotFoundError
):
except
(
subprocess
.
CalledProcessError
,
FileNotFoundError
):
pass
pass
# If we still can't determine the version, raise an error
# If we still can't determine the version, raise an error
raise
ValueError
(
f
"Could not determine ROCm version from directory:
{
rocm_dir
}
"
)
raise
ValueError
(
f
"Could not determine ROCm version from directory:
{
rocm_dir
}
"
)
...
@@ -316,10 +316,10 @@ class CMakeBuild(BuildExtension):
...
@@ -316,10 +316,10 @@ class CMakeBuild(BuildExtension):
elif
ROCM_HOME
is
not
None
:
elif
ROCM_HOME
is
not
None
:
cmake_args
+=
[
"-DKTRANSFORMERS_USE_ROCM=ON"
]
cmake_args
+=
[
"-DKTRANSFORMERS_USE_ROCM=ON"
]
else
:
else
:
raise
ValueError
(
"Unsupported backend: CUDA_HOME and
MUSA
_HOME are not set."
)
raise
ValueError
(
"Unsupported backend: CUDA_HOME
, MUSA_HOME,
and
ROCM
_HOME are not set."
)
# log cmake_args
# log cmake_args
print
(
"CMake args:"
,
cmake_args
)
print
(
"CMake args:"
,
cmake_args
)
build_args
=
[]
build_args
=
[]
if
"CMAKE_ARGS"
in
os
.
environ
:
if
"CMAKE_ARGS"
in
os
.
environ
:
cmake_args
+=
[
cmake_args
+=
[
...
...
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