File python-accelerate.spec of Package python-accelerate

#
# spec file for package python-accelerate
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-accelerate
Version:        0.33.0
Release:        0
Summary:        abstracts exactly and only the boilerplate code related to multi-GPUs/TPU/fp16
License:        Apache-2.0
URL:            https://github.com/huggingface/accelerate
Source:         https://github.com/huggingface/accelerate/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module setuptools}
BuildRequires:  %{python_module huggingface_hub >= 0.21.0}
BuildRequires:  %{python_module numpy >= 1.17}
BuildRequires:  %{python_module packaging >= 20.0}
BuildRequires:  %{python_module psutil}
BuildRequires:  %{python_module PyYAML}
BuildRequires:  %{python_module safetensors >= 0.3.1}
BuildRequires:  %{python_module torch >= 1.10.0}
BuildRequires:  fdupes
Requires:       python-huggingface_hub >= 0.21.0
Requires:       python-numpy >= 1.17
Requires:       python-packaging >= 20.0
Requires:       python-psutil
Requires:       python-pyyaml
Requires:       python-safetensors >= 0.3.1
Requires:       python-torch >= 1.10.0
BuildArch:      noarch
%python_subpackages

%description
Accelerate was created for PyTorch users who like to write the training loop of
PyTorch models but are reluctant to write and maintain the boilerplate code
needed to use multi-GPUs/TPU/fp16.

Accelerate abstracts exactly and only the boilerplate code related to
multi-GPUs/TPU/fp16 and leaves the rest of your code unchanged.
%prep
%setup -q -n accelerate-%{version}

%build
%python_build

%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/accelerate
%python_clone -a %{buildroot}%{_bindir}/accelerate-config
%python_clone -a %{buildroot}%{_bindir}/accelerate-estimate-memory
%python_clone -a %{buildroot}%{_bindir}/accelerate-launch
%python_clone -a %{buildroot}%{_bindir}/accelerate-merge-weights
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%check

%post
%python_install_alternative accelerate accelerate-config accelerate-estimate-memory accelerate-launch accelerate-merge-weights

%postun
%python_uninstall_alternative accelerate

%files %{python_files}
%doc README.md
%license LICENSE
%python_alternative %{_bindir}/accelerate
%python_alternative %{_bindir}/accelerate-config
%python_alternative %{_bindir}/accelerate-estimate-memory
%python_alternative %{_bindir}/accelerate-launch
%python_alternative %{_bindir}/accelerate-merge-weights
%{python_sitelib}/*

%changelog
openSUSE Build Service is sponsored by