Christian Goll
17eb5a3288
OBS-URL: https://build.opensuse.org/package/show/science:machinelearning/python-torch?expand=0&rev=3
241 lines
9.4 KiB
RPMSpec
241 lines
9.4 KiB
RPMSpec
#
|
|
# spec file for package pytorch
|
|
#
|
|
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
|
#
|
|
# 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/
|
|
#
|
|
%define srcname pytorch
|
|
%define skip_python2 1
|
|
|
|
Name: python-torch
|
|
Version: 1.1.0
|
|
Release: 0
|
|
Summary: Deep learning framework aka pytorch/Caffe2
|
|
License: BSD-2-Clause and BSD-3-Clause and MIT and Zlib and BSL-1.0 and Apache-2.0
|
|
Group: Development/Languages/Python
|
|
Url: https://pytorch.org
|
|
Source0: https://github.com/pytorch/pytorch/archive/v%{version}.tar.gz#/%{srcname}-%{version}.tar.gz
|
|
#License10: BSD-3-Clause
|
|
Source10: https://github.com/facebookincubator/gloo/archive/670b4d4aa46886cc66874e2a4dc846f5cfc2a285.tar.gz#/gloo-670b4d4aa46886cc66874e2a4dc846f5cfc2a285.tar.gz
|
|
#License12: BSD-2-Clause
|
|
Source12: https://github.com/pytorch/cpuinfo/archive/89fe1695edf9ee14c22f815f24bac45577a4f135.tar.gz#/cpuinfo-89fe1695edf9ee14c22f815f24bac45577a4f135.tar.gz
|
|
#License13: BSL-1.0
|
|
Source13: https://github.com/zdevito/sleef/archive/191f655caa25526ae226cf88dd2529265176014a.tar.gz#/sleef-191f655caa25526ae226cf88dd2529265176014a.tar.gz
|
|
#License14: BSD-3-Clause
|
|
Source14: https://github.com/pybind/pybind11/archive/25abf7efba0b2990f5a6dfb0a31bc65c0f2f4d17.tar.gz#/pybind11-25abf7efba0b2990f5a6dfb0a31bc65c0f2f4d17.tar.gz
|
|
# License15: MIT
|
|
Source15: https://github.com/onnx/onnx/archive/22662bfd4dcc6baebf29e3b823a051676f991001.tar.gz#/onnx-22662bfd4dcc6baebf29e3b823a051676f991001.tar.gz
|
|
#License16: BSD-2-Clause
|
|
Source16: https://github.com/Maratyszcza/pthreadpool/archive/13da0b4c21d17f94150713366420baaf1b5a46f4.tar.gz#/pthreadpool-13da0b4c21d17f94150713366420baaf1b5a46f4.tar.gz
|
|
# License17: MIT
|
|
Source17: https://github.com/Maratyszcza/FXdiv/archive/b742d1143724d646cd0f914646f1240eacf5bd73.tar.gz#/FXdiv-b742d1143724d646cd0f914646f1240eacf5bd73.tar.gz
|
|
# License18: MIT
|
|
Source18: https://github.com/Maratyszcza/psimd/archive/90a938f30ba414ada2f4b00674ee9631d7d85e19.tar.gz#/psimd-90a938f30ba414ada2f4b00674ee9631d7d85e19.tar.gz
|
|
# License19: MIT
|
|
Source19: https://github.com/Maratyszcza/FP16/archive/febbb1c163726b5db24bed55cc9dc42529068997.tar.gz#/FP16-febbb1c163726b5db24bed55cc9dc42529068997.tar.gz
|
|
#License20: Apache-2.0
|
|
Source20: https://github.com/google/gemmlowp/archive/8416bab644641a5c0a81ecf91a5cda804af0aee1.tar.gz#/gemmlowp-8416bab644641a5c0a81ecf91a5cda804af0aee1.tar.gz
|
|
#License21: MIT
|
|
Source21: https://github.com/houseroad/foxi/archive/8f74bc4df3a4cfc69b1a3eadf62aa29d9961c72d.tar.gz#/foxi-8f74bc4df3a4cfc69b1a3eadf62aa29d9961c72d.tar.gz
|
|
Patch0: fix-build-options.patch
|
|
Patch1: removed-peachpy-depedency.patch
|
|
Patch2: honor-PSIMD-env.patch
|
|
Patch3: removed-some-tests.patch
|
|
BuildRequires: %{python_module devel}
|
|
BuildRequires: %{pythons}
|
|
BuildRequires: python-py-cpuinfo
|
|
BuildRequires: python-pybind11-devel
|
|
BuildRequires: %{python_module PeachPy}
|
|
BuildRequires: %{python_module opcodes}
|
|
BuildRequires: %{python_module PyYAML}
|
|
BuildRequires: %{python_module setuptools}
|
|
BuildRequires: %{python_module typing_extensions}
|
|
BuildRequires: %{python_module typing}
|
|
BuildRequires: %{python_module numpy-devel}
|
|
BuildRequires: cmake
|
|
BuildRequires: eigen3-devel
|
|
BuildRequires: fdupes
|
|
BuildRequires: gcc-c++
|
|
BuildRequires: glog-devel
|
|
BuildRequires: gtest
|
|
BuildRequires: libopenblas_pthreads-devel
|
|
BuildRequires: libnuma-devel
|
|
BuildRequires: lmdb-devel
|
|
BuildRequires: leveldb-devel
|
|
BuildRequires: ninja
|
|
BuildRequires: memory-constraints
|
|
BuildRequires: openblas-devel
|
|
BuildRequires: protobuf-c
|
|
BuildRequires: protobuf-devel
|
|
BuildRequires: snappy-devel
|
|
BuildRequires: %{python_module future}
|
|
BuildRequires: %{python_module hypothesis}
|
|
BuildRequires: %{python_module protobuf}
|
|
BuildRequires: %{python_module psutil}
|
|
BuildRequires: %{python_module rpm-macros}
|
|
BuildRequires: %{python_module leveldb}
|
|
BuildRequires: %{python_module Gloo}
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
Requires: python-protobuf
|
|
Requires: python-six
|
|
Requires: python-future
|
|
Requires: python-numpy
|
|
Requires: python-leveldb
|
|
|
|
Provides: %{python_module caffe2 = %version}
|
|
Provides: %{python_module pytorch = %version}
|
|
|
|
%python_subpackages
|
|
|
|
%description
|
|
PyTorch enables fast, flexible experimentation and efficient production through
|
|
a hybrid front-end, distributed training, and ecosystem of tools and libraries.
|
|
The library is developed by Facebook and other groups.
|
|
PyTorch provides two high-level features:
|
|
* Tensor computing (like NumPy) with strong acceleration via graphics
|
|
* processing units (GPU) Deep neural networks built on a tape-based autodiff
|
|
system
|
|
|
|
%package devel
|
|
Summary: Headers for C/C++, cmake build description and libraries needed for development
|
|
Group: Development/Languages/Python
|
|
Requires: %{name} = %{version}
|
|
|
|
%description devel
|
|
Although the Python interface is more polished and the primary focus of
|
|
development, PyTorch also has a C++ frontend. This package contains the header
|
|
to access the C/C++ interface.
|
|
|
|
%package -n %{name}-converters
|
|
Summary: Converters for onnx and caffe2
|
|
Group: Development/Languages/Python
|
|
|
|
%description -n %{name}-converters
|
|
Converter from caffe2 to onnx and from caffe2 to onnx formated files.
|
|
|
|
%package -n %{name}-examples
|
|
Summary: Examples which can be used for testing
|
|
Group: Development/Languages/Python
|
|
BuildArch: noarch
|
|
|
|
%description -n %{name}-examples
|
|
This example files can be used to start an own pytorch/caffe2 project.
|
|
|
|
%package -n libtorch
|
|
Summary: Library which used by %{name}
|
|
Group: Development/Libraries/Python
|
|
%description -n libtorch
|
|
Library which is used by %{name}
|
|
|
|
%prep
|
|
%define make_depend_src() test -e $(basename %1| sed 's/-.*//') && rmdir %{?2}%{!?2:$(basename %1| sed 's/-.*//')}; tar xzf %1; mv $(basename %1 | sed 's/\.tar\.gz//' ) %{?2}%{!?2:$(basename %1| sed 's/-.*//')}
|
|
%define make_depend_src_uppercase() rmdir -p $(basename %1| sed 's/-.*//'| tr '[:upper:]' '[:lower:]'); tar xzf %1; mv $(basename %1 | cut -f 1 -d '.' ) $(basename %1| sed 's/-.*//'| tr '[:upper:]' '[:lower:]')
|
|
%setup -q -n %{srcname}-%{version}
|
|
%patch0 -p 1
|
|
%patch1 -p 1
|
|
%patch2 -p 1
|
|
%patch3 -p 1
|
|
cd third_party
|
|
rmdir python-peachpy/
|
|
%make_depend_src %{SOURCE10}
|
|
%make_depend_src %{SOURCE12}
|
|
%make_depend_src %{SOURCE13}
|
|
%make_depend_src %{SOURCE14}
|
|
%make_depend_src %{SOURCE15}
|
|
%make_depend_src %{SOURCE16}
|
|
%make_depend_src %{SOURCE17}
|
|
%make_depend_src %{SOURCE18}
|
|
%make_depend_src %{SOURCE19}
|
|
%make_depend_src %{SOURCE20} gemmlowp/gemmlowp
|
|
%make_depend_src %{SOURCE21}
|
|
|
|
%build
|
|
export NO_NNPACK=1
|
|
export NO_QNNPACK=1
|
|
export NO_CUDNN=1
|
|
#export NO_DISTRIBUTED=1
|
|
export NO_MKLDNN=1
|
|
export NO_TEST=1
|
|
export USE_LEVELDB=ON
|
|
export USE_LMDB=ON
|
|
export BUILD_CUSTOM_PROTOBUF=OFF
|
|
export USE_FBGEMM=0
|
|
export PSIMD_SOURCE_DIR=%{_topdir}/BUILD/%{srcname}-%{version}/third_party/psimd/
|
|
%limit_build -m 2000
|
|
export MAX_JOBS=%{?jobs}
|
|
%python_build
|
|
|
|
%install
|
|
%python_install
|
|
|
|
%python_expand %fdupes %{buildroot}%{$python_sitearch}
|
|
|
|
install -m 644 -D caffe2/python/examples/* -t %{buildroot}%{_docdir}/%{name}/
|
|
install -m 644 -D %{buildroot}%{python_sitearch}/torch/lib/* %{buildroot}/%{_libdir}
|
|
rm -r %{buildroot}%{python_sitearch}/torch/lib
|
|
cd %{buildroot}/%{_libdir}
|
|
rm libtorch.so
|
|
ln -s libtorch.so.1 libtorch.so
|
|
cd -
|
|
for file in $(find %{buildroot}%{python_sitearch} -type f -name \*.py -perm 644 -size +1b); do
|
|
%{__grep} '/bin/env ' $file && sed -i 's@/bin/env python@/bin/python@' $file && chmod 755 $file
|
|
done
|
|
|
|
%check
|
|
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
|
|
%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python test/run_test.py
|
|
|
|
%post -n libtorch -p /sbin/ldconfig
|
|
%postun -n libtorch -p /sbin/ldconfig
|
|
|
|
%files %{python_files}
|
|
%defattr(-,root,root)
|
|
%doc README.md NOTICE
|
|
%license LICENSE
|
|
%{python_sitearch}/torch/
|
|
%{python_sitearch}/caffe2/
|
|
%{python_sitearch}/torch-*.egg-info/
|
|
# excluding nearly all headersm except THNN.h and THCUNN.h as they
|
|
# are read in by the python init
|
|
%exclude %{python_sitearch}/torch/share
|
|
%exclude %{python_sitearch}/torch/include/TH
|
|
%exclude %{python_sitearch}/torch/include/c10
|
|
%exclude %{python_sitearch}/torch/include/ATen
|
|
%exclude %{python_sitearch}/torch/include/pybind11
|
|
%exclude %{python_sitearch}/torch/include/caffe2
|
|
%exclude %{python_sitearch}/torch/include/torch/csrc
|
|
%exclude %{python_sitearch}/torch/include/torch/*.h
|
|
|
|
|
|
|
|
%files %{python_files devel}
|
|
%{python_sitearch}/torch/share
|
|
%{python_sitearch}/torch/include/TH/
|
|
%{python_sitearch}/torch/include/c10
|
|
%{python_sitearch}/torch/include/ATen
|
|
%{python_sitearch}/torch/include/pybind11
|
|
%{python_sitearch}/torch/include/caffe2
|
|
%{python_sitearch}/torch/include/torch/csrc
|
|
%{python_sitearch}/torch/include/torch/*.h
|
|
|
|
%files -n %{name}-converters
|
|
%{_bindir}/convert-caffe2-to-onnx
|
|
%{_bindir}/convert-onnx-to-caffe2
|
|
|
|
%files -n %{name}-examples
|
|
%{_docdir}/%{name}
|
|
|
|
%files -n libtorch
|
|
%{_libdir}/*.so*
|
|
%changelog
|