2019-08-28 13:58:32 +02:00
#
2020-02-21 16:50:33 +01:00
# spec file for package python-torch
2019-08-28 13:58:32 +02:00
#
2020-02-21 16:50:33 +01:00
# Copyright (c) 2020 SUSE LLC
2019-08-28 13:58:32 +02:00
#
# 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/
2020-02-21 16:50:33 +01:00
#
2019-08-28 13:58:32 +02:00
#
%define srcname pytorch
%define skip_python2 1
2020-01-14 15:16:39 +01:00
%define pname torch
2019-08-28 13:58:32 +02:00
2019-11-04 15:27:49 +01:00
Name : python-torch
2020-02-21 16:50:33 +01:00
Version : 1.4.0
2019-08-28 13:58:32 +02:00
Release : 0
Summary : Deep learning framework aka pytorch/Caffe2
2020-02-21 16:50:33 +01:00
License : BSD-2-Clause AND BSD-3-Clause AND MIT AND Zlib AND BSL-1.0 AND Apache-2.0
2019-08-28 13:58:32 +02:00
Group : Development/Languages/Python
2020-02-21 16:50:33 +01:00
URL : https://pytorch.org
2019-08-28 13:58:32 +02:00
Source0 : https://github.com/pytorch/pytorch/archive/v%{version} .tar.gz#/%{srcname}-%{version}.tar.gz
2020-02-25 13:33:19 +01:00
Source1 : https://github.com/pytorch/pytorch/releases/tag/v1.4.0#/releases
2019-08-28 13:58:32 +02:00
#License10: BSD-3-Clause
2020-02-21 16:50:33 +01:00
Source10 : https://github.com/facebookincubator/gloo/archive/7c541247a6fa49e5938e304ab93b6da661823d0f.tar.gz#/gloo-7c541247a6fa49e5938e304ab93b6da661823d0f.tar.gz
2019-08-28 13:58:32 +02:00
#License12: BSD-2-Clause
Source12 : https://github.com/pytorch/cpuinfo/archive/89fe1695edf9ee14c22f815f24bac45577a4f135.tar.gz#/cpuinfo-89fe1695edf9ee14c22f815f24bac45577a4f135.tar.gz
#License13: BSL-1.0
2020-02-21 16:50:33 +01:00
Source13 : https://github.com/zdevito/sleef/archive/7f523de651585fe25cade462efccca647dcc8d02.tar.gz#/sleef-7f523de651585fe25cade462efccca647dcc8d02.tar.gz
2019-08-28 13:58:32 +02:00
#License14: BSD-3-Clause
Source14 : https://github.com/pybind/pybind11/archive/25abf7efba0b2990f5a6dfb0a31bc65c0f2f4d17.tar.gz#/pybind11-25abf7efba0b2990f5a6dfb0a31bc65c0f2f4d17.tar.gz
# License15: MIT
2020-02-21 16:50:33 +01:00
Source15 : https://github.com/onnx/onnx/archive/fea8568cac61a482ed208748fdc0e1a8e47f62f5.tar.gz#/onnx-fea8568cac61a482ed208748fdc0e1a8e47f62f5.tar.gz
2019-08-28 13:58:32 +02:00
#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
2020-02-21 16:50:33 +01:00
Source20 : https://github.com/google/gemmlowp/archive/3fb5c176c17c765a3492cd2f0321b0dab712f350.tar.gz#/gemmlowp-3fb5c176c17c765a3492cd2f0321b0dab712f350.tar.gz
2019-08-28 13:58:32 +02:00
#License21: MIT
2020-02-21 16:50:33 +01:00
Source21 : https://github.com/houseroad/foxi/archive/97fe555430a857581b9b826ecd955e4f0a3653f0.tar.gz#/foxi-97fe555430a857581b9b826ecd955e4f0a3653f0.tar.gz
# License22: MIT
Source22 : https://github.com/pytorch/QNNPACK/archive/7d2a4e9931a82adc3814275b6219a03e24e36b4c.tar.gz#/QNNPACK-7d2a4e9931a82adc3814275b6219a03e24e36b4c.tar.gz
Patch0 : removed-peachpy-depedency.patch
Patch1 : skip-third-party-check.patch
BuildRequires : %{python_module Gloo}
2020-01-14 15:16:11 +01:00
%ifarch x86_64
2019-08-28 13:58:32 +02:00
BuildRequires : %{python_module PeachPy}
2020-01-14 15:16:11 +01:00
%endif
2019-08-28 13:58:32 +02:00
BuildRequires : %{python_module PyYAML}
2020-02-21 16:50:33 +01:00
BuildRequires : %{python_module devel}
BuildRequires : %{python_module future}
BuildRequires : %{python_module hypothesis}
BuildRequires : %{python_module leveldb}
BuildRequires : %{python_module numpy-devel}
BuildRequires : %{python_module opcodes}
BuildRequires : %{python_module protobuf}
BuildRequires : %{python_module psutil}
BuildRequires : %{python_module rpm-macros}
2019-08-28 13:58:32 +02:00
BuildRequires : %{python_module setuptools}
2019-09-04 10:17:31 +02:00
BuildRequires : %{python_module typing_extensions}
2019-08-28 13:58:32 +02:00
BuildRequires : %{python_module typing}
2020-02-21 16:50:33 +01:00
BuildRequires : %{pythons}
2019-08-28 13:58:32 +02:00
BuildRequires : cmake
BuildRequires : eigen3-devel
BuildRequires : fdupes
BuildRequires : gcc-c++
BuildRequires : glog-devel
BuildRequires : gtest
2020-02-21 16:50:33 +01:00
BuildRequires : leveldb-devel
2019-08-28 13:58:32 +02:00
BuildRequires : libnuma-devel
2020-02-21 16:50:33 +01:00
BuildRequires : libopenblas_pthreads-devel
2019-08-28 13:58:32 +02:00
BuildRequires : lmdb-devel
BuildRequires : memory-constraints
2020-02-21 16:50:33 +01:00
BuildRequires : ninja
2019-08-28 13:58:32 +02:00
BuildRequires : openblas-devel
2020-02-21 16:50:33 +01:00
BuildRequires : openssl-devel
2019-08-28 13:58:32 +02:00
BuildRequires : protobuf-c
BuildRequires : protobuf-devel
2020-02-21 16:50:33 +01:00
BuildRequires : python-py-cpuinfo
BuildRequires : python-pybind11-devel
2019-08-28 13:58:32 +02:00
BuildRequires : snappy-devel
BuildRoot : %{_tmppath} /%{name} -%{version} -build
Requires : python-future
Requires : python-leveldb
2020-02-21 16:50:33 +01:00
Requires : python-numpy
Requires : python-protobuf
Requires : python-six
2019-08-28 13:58:32 +02:00
2020-01-14 15:16:39 +01:00
Provides : python-caffe2 = %version
Provides : python-pytorch = %version
2019-08-28 13:58:32 +02:00
%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.
2020-01-14 15:16:39 +01:00
%package -n pytorch-converters
2019-08-28 13:58:32 +02:00
Summary : Converters for onnx and caffe2
Group : Development/Languages/Python
2020-01-14 15:16:39 +01:00
BuildArch : noarch
Requires : python3-click
2020-02-21 16:50:33 +01:00
Requires : python3-onnx
Requires : python3-pip
2020-01-14 15:16:39 +01:00
Requires : python3-pname
2019-08-28 13:58:32 +02:00
2020-01-14 15:16:39 +01:00
%description -n pytorch-converters
2019-08-28 13:58:32 +02:00
Converter from caffe2 to onnx and from caffe2 to onnx formated files.
2020-01-14 15:16:39 +01:00
%package -n pytorch-examples
2019-08-28 13:58:32 +02:00
Summary : Examples which can be used for testing
Group : Development/Languages/Python
BuildArch : noarch
2020-01-14 15:16:39 +01:00
Recommends: python3-lmdb
Recommends: python3-networkx
2019-08-28 13:58:32 +02:00
2020-01-14 15:16:39 +01:00
%description -n pytorch-examples
2019-08-28 13:58:32 +02:00
This example files can be used to start an own pytorch/caffe2 project.
%package -n libtorch
2020-02-21 16:50:33 +01:00
Summary : Library which used by %{name}
Group : Development/Libraries/Python
2019-08-28 13:58:32 +02:00
%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}
2020-02-21 16:50:33 +01:00
cp %{S:1} releases.html
%autopatch -p 1
2019-08-28 13:58:32 +02:00
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}
2020-02-21 16:50:33 +01:00
%make_depend_src %{SOURCE22}
# link system eigen to right place
rmdir eigen
ln -s /usr/include/eigen3 eigen
cd ..
2019-08-28 13:58:32 +02:00
%build
2020-02-21 16:50:33 +01:00
#export CC=gcc-7
#export CXX=g++-7
export USE_NNPACK=0
export USE_CUDNN=0
export USE_TEST=0
2019-08-28 13:58:32 +02:00
export USE_LEVELDB=ON
export USE_LMDB=ON
export USE_FBGEMM=0
2020-02-21 16:50:33 +01:00
export USE_SYSTEM_LIB=" t b b , f b g e m m , f b g e m m / t h i r d _ p a r t y / a s m j i t , o n n x / t h i r d _ p a r t y / b e n c h m a r k "
export BUILD_CUSTOM_PROTOBUF=OFF
export BUILD_TEST=0
2019-08-28 13:58:32 +02:00
%limit_build -m 2000
export MAX_JOBS=%{?jobs}
%python_build
%install
2020-02-21 16:50:33 +01:00
export USE_NNPACK=0
export USE_CUDNN=0
export USE_TEST=0
export USE_LEVELDB=ON
export USE_LMDB=ON
export USE_FBGEMM=0
export USE_SYSTEM_LIB=" t b b , f b g e m m , f b g e m m / t h i r d _ p a r t y / a s m j i t , o n n x / t h i r d _ p a r t y / b e n c h m a r k "
export BUILD_CUSTOM_PROTOBUF=OFF
export BUILD_TEST=1
%limit_build -m 2000
export MAX_JOBS=%{?jobs}
2019-08-28 13:58:32 +02:00
%python_install
%python_expand %fdupes %{buildroot} %{$python_sitearch}
2020-01-14 15:16:39 +01:00
install -m 755 -D caffe2/python/examples/* -t %{buildroot} %{_docdir} /%{name} /
2019-08-28 13:58:32 +02:00
install -m 644 -D %{buildroot} %{python_sitearch} /torch/lib/* %{buildroot} /%{_libdir}
2020-02-21 16:50:33 +01:00
#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} '/usr/bin/env ' $file && sed -i 's@/usr/bin/env python@/usr/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
2019-08-28 13:58:32 +02:00
%post -n libtorch -p /sbin/ldconfig
%postun -n libtorch -p /sbin/ldconfig
%files %{python_files}
%defattr (-,root,root)
2020-02-21 16:50:33 +01:00
%doc README.md NOTICE releases.html
2019-08-28 13:58:32 +02:00
%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
2020-01-14 15:16:39 +01:00
%files -n pytorch-converters
2019-08-28 13:58:32 +02:00
%{_bindir} /convert-caffe2-to-onnx
%{_bindir} /convert-onnx-to-caffe2
2020-01-14 15:16:39 +01:00
%files -n pytorch-examples
2019-08-28 13:58:32 +02:00
%{_docdir} /%{name}
%files -n libtorch
%{_libdir} /*.so*
2020-02-21 16:50:33 +01:00
2019-08-28 13:58:32 +02:00
%changelog