Skip to content

Commit b8e97fb

Browse files
Tsumugii24MekkCyber
authored andcommitted
fix: resolve triton version check compatibility on windows (#39986)
* fix: resolve triton version check compatibility on windows * style: remove trailing space * fix: fix typo --------- Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
1 parent 586b6e6 commit b8e97fb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/transformers/utils/import_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,14 @@ def _is_package_available(pkg_name: str, return_version: bool = False) -> Union[
7878
package_exists = False
7979
elif pkg_name == "triton":
8080
try:
81-
package_version = importlib.metadata.version("pytorch-triton")
81+
# import triton works for both linux and windows
82+
package = importlib.import_module(pkg_name)
83+
package_version = getattr(package, "__version__", "N/A")
8284
except Exception:
83-
package_exists = False
85+
try:
86+
package_version = importlib.metadata.version("pytorch-triton") # pytorch-triton
87+
except Exception:
88+
package_exists = False
8489
else:
8590
# For packages other than "torch", don't attempt the fallback and set as not available
8691
package_exists = False

0 commit comments

Comments
 (0)