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

Fix transformers version checking for Python < 3.8 #1363

Merged
merged 1 commit into from
Feb 27, 2024
Merged
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
13 changes: 10 additions & 3 deletions trl/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ def is_accelerate_greater_20_0() -> bool:
return accelerate_version >= "0.20.0"


def is_transformers_greater_than(version: str) -> bool:
_transformers_version = importlib.metadata.version("transformers")
return _transformers_version > version
def is_transformers_greater_than(current_version: str) -> bool:
if _is_python_greater_3_8:
from importlib.metadata import version

_transformers_version = version("transformers")
else:
import pkg_resources

_transformers_version = pkg_resources.get_distribution("transformers").version
return _transformers_version > current_version


def is_torch_greater_2_0() -> bool:
Expand Down
Loading