[arch-commits] Commit in python-pytorch/repos (3 files)

Konstantin Gizdov kgizdov at archlinux.org
Fri Sep 6 09:17:40 UTC 2019


    Date: Friday, September 6, 2019 @ 09:17:40
  Author: kgizdov
Revision: 508270

archrelease: copy trunk to community-testing-x86_64

Added:
  python-pytorch/repos/community-testing-x86_64/
  python-pytorch/repos/community-testing-x86_64/24143.patch
    (from rev 508269, python-pytorch/trunk/24143.patch)
  python-pytorch/repos/community-testing-x86_64/PKGBUILD
    (from rev 508269, python-pytorch/trunk/PKGBUILD)

-------------+
 24143.patch |   38 +++++++++++++
 PKGBUILD    |  165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 203 insertions(+)

Copied: python-pytorch/repos/community-testing-x86_64/24143.patch (from rev 508269, python-pytorch/trunk/24143.patch)
===================================================================
--- community-testing-x86_64/24143.patch	                        (rev 0)
+++ community-testing-x86_64/24143.patch	2019-09-06 09:17:40 UTC (rev 508270)
@@ -0,0 +1,38 @@
+From 16d00e3e701b18124166d8a26c592e1d24e33737 Mon Sep 17 00:00:00 2001
+From: Leo Mao <leomaoyw at gmail.com>
+Date: Sat, 10 Aug 2019 13:11:12 +0800
+Subject: [PATCH] opencv 4 compatibility fix for caffe2/video
+
+---
+ caffe2/video/video_input_op.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/caffe2/video/video_input_op.h b/caffe2/video/video_input_op.h
+index b047eb68326a..850462761156 100644
+--- a/caffe2/video/video_input_op.h
++++ b/caffe2/video/video_input_op.h
+@@ -573,7 +573,7 @@ bool VideoInputOp<Context>::GetImageAndLabelsFromDBValue(
+             &encoded_size,
+             CV_8UC1,
+             const_cast<char*>(encoded_image_str.data())),
+-        CV_LOAD_IMAGE_COLOR);
++        cv::IMREAD_COLOR);
+     if (src.rows == 0 or src.cols == 0) {
+       throw std::runtime_error("Both rows and cols are 0 for image");
+     }
+@@ -606,13 +606,13 @@ bool VideoInputOp<Context>::GetImageAndLabelsFromDBValue(
+     img = scaled_img;
+   } else {
+     cv::cvtColor(
+-        scaled_img, img, (channels_rgb_ == 1) ? CV_BGR2GRAY : CV_GRAY2BGR);
++        scaled_img, img, (channels_rgb_ == 1) ? cv::COLOR_BGR2GRAY : cv::COLOR_GRAY2BGR);
+   }
+ 
+   cv::Mat rgb_img;
+ 
+   if (channels_rgb_ == 1) {
+-    cv::cvtColor(img, rgb_img, CV_BGR2RGB);
++    cv::cvtColor(img, rgb_img, cv::COLOR_BGR2RGB);
+   } else {
+     rgb_img = img;
+   }

Copied: python-pytorch/repos/community-testing-x86_64/PKGBUILD (from rev 508269, python-pytorch/trunk/PKGBUILD)
===================================================================
--- community-testing-x86_64/PKGBUILD	                        (rev 0)
+++ community-testing-x86_64/PKGBUILD	2019-09-06 09:17:40 UTC (rev 508270)
@@ -0,0 +1,165 @@
+# Maintainer: Sven-Hendrik Haase <sh at lutzhaase.com>
+# Contributor: Stephen Zhang <zsrkmyn at gmail dot com>
+
+pkgbase="python-pytorch"
+pkgname=("python-pytorch" "python-pytorch-opt" "python-pytorch-cuda" "python-pytorch-opt-cuda")
+_pkgname="pytorch"
+pkgver=1.2.0
+pkgrel=1
+pkgdesc="Tensors and Dynamic neural networks in Python with strong GPU acceleration"
+arch=('x86_64')
+url="https://pytorch.org"
+license=('BSD')
+depends=('google-glog' 'gflags' 'opencv-gcc8' 'openmp' 'nccl' 'pybind11' 'python' 'python-yaml' 'python-numpy' 'protobuf' 'ffmpeg' 'python-future')
+makedepends=('python' 'python-setuptools' 'python-yaml' 'python-numpy' 'cmake' 'cuda' 'cudnn' 'git')
+source=("${_pkgname}-${pkgver}::git+https://github.com/pytorch/pytorch.git#tag=v$pkgver"
+        24143.patch)
+sha256sums=('SKIP'
+            '773971a391e2d517630b37150ec20bd4ba06181c5c9767d51cd7358729b4aa5a')
+
+get_pyver () {
+    python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))'
+}
+
+prepare() {
+  cd "${_pkgname}-${pkgver}"
+
+  patch -Np1 -i "$srcdir"/24143.patch
+
+  # This is the lazy way since pytorch has sooo many submodules and they keep
+  # changing them around but we've run into more problems so far doing it the
+  # manual than the lazy way. This lazy way (not explicitly specifying all
+  # submodules) will make building inefficient but for now I'll take it.
+  # It will result in the same package, don't worry.
+  git submodule update --init --recursive
+
+  cd ..
+
+  cp -a "${_pkgname}-${pkgver}" "${_pkgname}-${pkgver}-opt"
+  cp -a "${_pkgname}-${pkgver}" "${_pkgname}-${pkgver}-cuda"
+  cp -a "${_pkgname}-${pkgver}" "${_pkgname}-${pkgver}-opt-cuda"
+
+  export CC=gcc-8
+  export CXX=g++-8
+  export VERBOSE=1
+  export PYTORCH_BUILD_VERSION="${pkgver}"
+  export PYTORCH_BUILD_NUMBER=1
+
+  # Check tools/setup_helpers/cmake.py, setup.py and CMakeLists.txt for a list of flags that can be set via env vars.
+  export USE_MKLDNN=OFF
+  # export BUILD_CUSTOM_PROTOBUF=OFF
+  # export BUILD_SHARED_LIBS=OFF
+  export USE_FFMPEG=ON
+  export USE_GFLAGS=ON
+  export USE_GLOG=ON
+  export BUILD_BINARY=ON
+  export USE_OPENCV=ON
+  export USE_SYSTEM_NCCL=ON
+  export CUDAHOSTCXX=g++-8
+  export CUDA_HOME=/opt/cuda
+  export CUDNN_LIB_DIR=/usr/lib
+  export CUDNN_INCLUDE_DIR=/usr/include
+  export CUDNN_LIBRARY="/usr/lib/libcudnn.so"
+  export TORCH_NVCC_FLAGS="-Xfatbin -compress-all"
+  export TORCH_CUDA_ARCH_LIST="3.5;3.7;5.0;5.2;5.3;6.0;6.1;6.2;7.0;7.2;7.5"
+  export NCCL_INCLUDE_DIR=/usr/include
+  export NCCL_VERSION_CODE=$(sed -n 's/^#define NCCL_VERSION_CODE\s*\(.*\).*/\1/p' /usr/include/nccl.h)
+}
+
+build() {
+  echo "Building without cuda and without non-x86-64 optimizations"
+  export USE_CUDA=0
+  export USE_CUDNN=0
+  cd "${srcdir}/${_pkgname}-${pkgver}"
+  python setup.py build
+
+
+  echo "Building without cuda and with non-x86-64 optimizations"
+  export USE_CUDA=0
+  export USE_CUDNN=0
+  cd "${srcdir}/${_pkgname}-${pkgver}-opt"
+  echo "add_definitions(-march=haswell)" >> cmake/MiscCheck.cmake
+  python setup.py build
+
+
+  echo "Building with cuda and without non-x86-64 optimizations"
+  export USE_CUDA=1
+  export USE_CUDNN=1
+  cd "${srcdir}/${_pkgname}-${pkgver}-cuda"
+  python setup.py build
+
+
+  echo "Building with cuda and with non-x86-64 optimizations"
+  export USE_CUDA=1
+  export USE_CUDNN=1
+  cd "${srcdir}/${_pkgname}-${pkgver}-opt-cuda"
+  echo "add_definitions(-march=haswell)" >> cmake/MiscCheck.cmake
+  python setup.py build
+}
+
+_package() {
+  # Prevent setup.py from re-running CMake and rebuilding
+  sed -e 's/RUN_BUILD_DEPS = True/RUN_BUILD_DEPS = False/g' -i setup.py
+
+  python setup.py install --root="${pkgdir}"/ --optimize=1 --skip-build
+
+  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+
+  pytorchpath="usr/lib/python$(get_pyver)/site-packages/torch"
+  install -d "${pkgdir}/usr/lib"
+
+  # put CMake files in correct place
+  mv "${pkgdir}/${pytorchpath}/share/cmake" "${pkgdir}/usr/lib/cmake"
+
+  # put C++ API in correct place
+  mv "${pkgdir}/${pytorchpath}/include" "${pkgdir}/usr/include"
+  mv "${pkgdir}/${pytorchpath}/lib"/*.so* "${pkgdir}/usr/lib/"
+
+  # clean up duplicates
+  # TODO: move towards direct shared library dependecy of:
+  #   c10, caffe2, libcpuinfo, CUDA RT, gloo, GTest, Intel MKL,
+  #   NVRTC, ONNX, protobuf, libthreadpool, QNNPACK
+  rm -rf "${pkgdir}/usr/include/pybind11"
+
+  # python module is hardcoded to look there at runtime
+  ln -s /usr/include "${pkgdir}/${pytorchpath}/include"
+  find "${pkgdir}"/usr/lib -type f -name "*.so*" -print0 | while read -rd $'\0' _lib; do
+    ln -s ${_lib#"$pkgdir"} "${pkgdir}/${pytorchpath}/lib/"
+  done
+}
+
+package_python-pytorch() {
+  cd "${srcdir}/${_pkgname}-${pkgver}"
+  _package
+}
+
+package_python-pytorch-opt() {
+  pkgdesc="Tensors and Dynamic neural networks in Python with strong GPU acceleration (with CPU optimizations)"
+  conflicts=(python-pytorch)
+  provides=(python-pytorch)
+
+  cd "${srcdir}/${_pkgname}-${pkgver}-opt"
+  _package
+}
+
+package_python-pytorch-cuda() {
+  pkgdesc="Tensors and Dynamic neural networks in Python with strong GPU acceleration (with CUDA)"
+  depends+=(cuda cudnn)
+  conflicts=(python-pytorch)
+  provides=(python-pytorch)
+
+  cd "${srcdir}/${_pkgname}-${pkgver}-cuda"
+  _package
+}
+
+package_python-pytorch-opt-cuda() {
+  pkgdesc="Tensors and Dynamic neural networks in Python with strong GPU acceleration (with CUDA and CPU optimizations)"
+  depends+=(cuda cudnn)
+  conflicts=(python-pytorch)
+  provides=(python-pytorch python-pytorch-cuda)
+
+  cd "${srcdir}/${_pkgname}-${pkgver}-opt-cuda"
+  _package
+}
+
+# vim:set ts=2 sw=2 et:


More information about the arch-commits mailing list