From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B4E00158086 for ; Wed, 22 Dec 2021 14:33:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 03A4C2BC077; Wed, 22 Dec 2021 14:33:40 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CF6DA2BC077 for ; Wed, 22 Dec 2021 14:33:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EDF51342E32 for ; Wed, 22 Dec 2021 14:33:38 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 14EC0266 for ; Wed, 22 Dec 2021 14:33:36 +0000 (UTC) From: "Andrew Ammerlaan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Ammerlaan" Message-ID: <1640176943.65e0afb1b927e1da6d8e23565b7d0aa1eacfc013.andrewammerlaan@gentoo> Subject: [gentoo-commits] proj/sci:master commit in: sci-libs/pytorch/, sci-libs/pytorch/files/ X-VCS-Repository: proj/sci X-VCS-Files: sci-libs/pytorch/files/pytorch-1.9.0-Change-library-directory-according-to-CMake-build.patch sci-libs/pytorch/files/pytorch-1.9.1-fix-wrong-hipify.patch sci-libs/pytorch/pytorch-1.10.1.ebuild X-VCS-Directories: sci-libs/pytorch/ sci-libs/pytorch/files/ X-VCS-Committer: andrewammerlaan X-VCS-Committer-Name: Andrew Ammerlaan X-VCS-Revision: 65e0afb1b927e1da6d8e23565b7d0aa1eacfc013 X-VCS-Branch: master Date: Wed, 22 Dec 2021 14:33:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1bcde8a8-8670-468c-ba1d-6eed8ad1feb8 X-Archives-Hash: da9f833a799184abbcae574aa1b5d7d3 commit: 65e0afb1b927e1da6d8e23565b7d0aa1eacfc013 Author: YiyangWu gmail com> AuthorDate: Wed Dec 22 09:59:27 2021 +0000 Commit: Andrew Ammerlaan gentoo org> CommitDate: Wed Dec 22 12:42:23 2021 +0000 URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=65e0afb1 sci-libs/pytorch: fix python and update rocm support Other changes: 1. Pytorch seems to be work fine with different version of protobuf, so no need to specify 0/30; however when protobuf version changed torch should be rebuilt. 2. BUILD_NAMEDTENSOR is not an option now 3. Verbose mode for rm in src_install Package-Manager: Portage-3.0.22, Repoman-3.0.3 Signed-off-by: Yiyang Wu gmail.com> Closes: https://github.com/gentoo/sci/pull/1123 Signed-off-by: Andrew Ammerlaan gentoo.org> ...ibrary-directory-according-to-CMake-build.patch | 32 +++++++++++++++ .../files/pytorch-1.9.1-fix-wrong-hipify.patch | 13 ++++++ sci-libs/pytorch/pytorch-1.10.1.ebuild | 47 +++++++++++++--------- 3 files changed, 74 insertions(+), 18 deletions(-) diff --git a/sci-libs/pytorch/files/pytorch-1.9.0-Change-library-directory-according-to-CMake-build.patch b/sci-libs/pytorch/files/pytorch-1.9.0-Change-library-directory-according-to-CMake-build.patch new file mode 100644 index 000000000..214267487 --- /dev/null +++ b/sci-libs/pytorch/files/pytorch-1.9.0-Change-library-directory-according-to-CMake-build.patch @@ -0,0 +1,32 @@ +From 52019a3f395e5fa97b26d424152d91f73b400f8e Mon Sep 17 00:00:00 2001 +From: Alexey Chernov <4ernov@gmail.com> +Date: Wed, 13 Nov 2019 23:44:12 +0300 +Subject: [PATCH 5/5] Change library directory according to CMake build +Modified: Tue, 03 Aug 2021, fit for pytorch-1.9.0 + +Change `lib_path` in favour of out-of-tree CMake build +directory, so that all the C++ libraries be found. +--- + setup.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/setup.py b/setup.py +index 60502b6add..cbced52192 100644 +--- a/setup.py ++++ b/setup.py +@@ -268,9 +268,10 @@ else: + + # Constant known variables used throughout this file + cwd = os.path.dirname(os.path.abspath(__file__)) +-lib_path = os.path.join(cwd, "torch", "lib") ++cmake_build_dir = os.environ.get("CMAKE_BUILD_DIR", os.path.join(cwd, "build")) ++lib_path = os.path.join(cmake_build_dir, "lib") + third_party_path = os.path.join(cwd, "third_party") +-caffe2_build_dir = os.path.join(cwd, "build") ++caffe2_build_dir = cmake_build_dir + + # CMAKE: full path to python library + if IS_WINDOWS: +-- +2.23.0 + diff --git a/sci-libs/pytorch/files/pytorch-1.9.1-fix-wrong-hipify.patch b/sci-libs/pytorch/files/pytorch-1.9.1-fix-wrong-hipify.patch new file mode 100644 index 000000000..4e37acd3f --- /dev/null +++ b/sci-libs/pytorch/files/pytorch-1.9.1-fix-wrong-hipify.patch @@ -0,0 +1,13 @@ +The hipify misadd a ) and causes compilation error + +--- orig/aten/src/ATen/native/sparse/hip/SparseHIPTensor.hip ++++ pytorch-1.9.1/aten/src/ATen/native/sparse/hip/SparseHIPTensor.hip +@@ -282,7 +282,7 @@ Tensor sparse_mask_helper_cuda( + mask_indices_ti, + t_indices_pos_ti, + t_values_ti, +- r_values_ti); ++ r_values_ti; + C10_HIP_KERNEL_LAUNCH_CHECK(); + }); + } diff --git a/sci-libs/pytorch/pytorch-1.10.1.ebuild b/sci-libs/pytorch/pytorch-1.10.1.ebuild index 5a745c28f..1750f40c9 100644 --- a/sci-libs/pytorch/pytorch-1.10.1.ebuild +++ b/sci-libs/pytorch/pytorch-1.10.1.ebuild @@ -58,7 +58,8 @@ LICENSE="BSD" SLOT="0" KEYWORDS="~amd64" -IUSE="asan blas cuda +fbgemm ffmpeg gflags glog +gloo leveldb lmdb mkldnn mpi namedtensor +nnpack numa +observers opencl opencv +openmp +python +qnnpack redis rocm static tools zeromq" +IUSE="asan blas cuda +fbgemm ffmpeg gflags glog +gloo leveldb lmdb mkldnn mpi namedtensor +nnpack numa +observers opencl opencv +openmp +python +qnnpack redis rocm static test tools zeromq" +RESTRICT="!test? ( test )" REQUIRED_USE=" ?? ( cuda rocm ) " @@ -68,17 +69,17 @@ RDEPEND=" blas? ( virtual/blas ) cuda? ( dev-libs/cudnn dev-cpp/eigen[cuda] ) - rocm? ( >=dev-util/hip-4.0.0-r1 - >=dev-libs/rccl-4 - >=sci-libs/rocThrust-4 - >=sci-libs/hipCUB-4 - >=sci-libs/rocPRIM-4 - >=sci-libs/miopen-4 - >=sci-libs/rocBLAS-4 - >=sci-libs/rocRAND-4 - >=sci-libs/hipSPARSE-4 - >=sci-libs/rocFFT-4 - >=dev-util/roctracer-4 ) + rocm? ( >=dev-util/hip-4.3 + >=dev-libs/rccl-4.3 + >=sci-libs/rocThrust-4.3 + >=sci-libs/hipCUB-4.3 + >=sci-libs/rocPRIM-4.3 + >=sci-libs/miopen-4.3 + >=sci-libs/rocBLAS-4.3 + >=sci-libs/rocRAND-4.3 + >=sci-libs/hipSPARSE-4.3 + >=sci-libs/rocFFT-4.3 + >=dev-util/roctracer-4.3 ) ffmpeg? ( media-video/ffmpeg ) gflags? ( dev-cpp/gflags ) glog? ( dev-cpp/glog[gflags] ) @@ -90,12 +91,12 @@ RDEPEND=" python? ( ${PYTHON_DEPS} dev-python/pybind11[${PYTHON_USEDEP}] dev-python/numpy[${PYTHON_USEDEP}] - dev-python/protobuf-python:0/30 + dev-python/protobuf-python:= ) redis? ( dev-db/redis ) zeromq? ( net-libs/zeromq ) dev-cpp/eigen - dev-libs/protobuf:0/30 + dev-libs/protobuf:= dev-libs/libuv " @@ -103,6 +104,7 @@ RDEPEND=" BDEPEND="dev-python/pyyaml" DEPEND="${RDEPEND} + test? ( dev-python/pytest[${PYTHON_USEDEP}] ) dev-cpp/tbb app-arch/zstd dev-python/pybind11[${PYTHON_USEDEP}] @@ -112,7 +114,7 @@ DEPEND="${RDEPEND} " PATCHES=( - "${FILESDIR}"/${PN}-1.6.0-skip-tests.patch + "${FILESDIR}"/${PN}-1.9.0-Change-library-directory-according-to-CMake-build.patch "${FILESDIR}"/${PN}-1.6.0-global-dlopen.patch "${FILESDIR}"/0002-Don-t-build-libtorch-again-for-PyTorch-1.7.1.patch "${FILESDIR}"/${PN}-1.7.1-no-rpath.patch @@ -213,12 +215,21 @@ src_prepare() { ebegin "HIPifying cuda sources" ${EPYTHON} tools/amd_build/build_amd.py || die + eapply "${FILESDIR}"/${PN}-1.9.1-fix-wrong-hipify.patch eend $? - export PYTORCH_ROCM_ARCH=$(rocminfo | egrep -o "gfx[0-9]+" | uniq | awk -vORS=';' "{print $1}" | sed 's/;$/\n/') || die + local ROCM_VERSION="$(hipconfig -v)-" + export PYTORCH_ROCM_ARCH="${AMDGPU_TARGETS}" sed -e "/set(roctracer_INCLUDE_DIRS/s,\${ROCTRACER_PATH}/include,${EPREFIX}/usr/include/roctracer," \ + -e "/PYTORCH_HIP_HCC_LIBRARIES/s,\${HIP_PATH}/lib,${EPREFIX}/usr/lib/hip/lib," \ + -e "s,\${ROCTRACER_PATH}/lib,${EPREFIX}/usr/lib64/roctracer," \ + -e "/READ.*\.info\/version-dev/c\ set(ROCM_VERSION_DEV_RAW ${ROCM_VERSION})" \ -i cmake/public/LoadHIP.cmake || die + sed -r -e '/^if\(USE_ROCM/{:a;N;/\nendif/!ba; s,\{([^\{]*)_PATH\}(/include)?,\{\L\1_\UINCLUDE_DIRS\},g}' -i cmake/Dependencies.cmake || die fi + + # Set build dir for pytorch's setup + sed -e "/BUILD_DIR/s,build,${BUILD_DIR}," -i tools/setup_helpers/env.py || die } src_configure() { @@ -262,13 +273,12 @@ src_configure() { -DUSE_GLOO=$(usex gloo ON OFF) -DUSE_SYSTEM_EIGEN_INSTALL=ON -DUSE_SYSTEM_PYBIND11=ON - -DBUILD_NAMEDTENSOR=$(usex namedtensor ON OFF) -DBLAS=$(usex blas Generic Eigen) -DTP_BUILD_LIBUV=OFF -Wno-dev ) - cmake_src_configure + HIP_PATH="${EPREFIX}/usr/lib/hip" cmake_src_configure if use python; then CMAKE_BUILD_DIR="${BUILD_DIR}" distutils-r1_src_configure @@ -308,6 +318,7 @@ src_install() { rm -rfv "${ED}/usr/include/var" rm -r "${ED}/usr/${LIB}/cmake" || die + rm -rv "${ED}/usr/${LIB}/cmake" || die if use python; then scanelf -r --fix "${BUILD_DIR}/caffe2/python" || die