commit:     98ac6bd1abbfbb2ce9e988cff500046fa515674a
Author:     Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
AuthorDate: Wed Oct 30 06:09:19 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Wed Oct 30 07:51:02 2024 +0000
URL:        https://gitweb.gentoo.org/proj/sci.git/commit/?id=98ac6bd1

sci-libs/torchvision: add 0.19.1, drop olds

Enable tests.

torchvision should be rebuilt if caffe2 turns on/off cuda or rocm.
So adding cuda/rocm to USE flag and dependencies to handle this.

Reference: https://bugs.gentoo.org/680496
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
Closes: https://github.com/gentoo/sci/pull/1293
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../files/torchvision-0.17.1-ffmpeg-6.patch        | 36 -------------------
 sci-libs/torchvision/metadata.xml                  |  3 ++
 sci-libs/torchvision/torchvision-0.14.1.ebuild     | 40 ----------------------
 ...ion-0.17.1.ebuild => torchvision-0.19.1.ebuild} | 26 +++++++++++---
 4 files changed, 24 insertions(+), 81 deletions(-)

diff --git a/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch 
b/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch
deleted file mode 100644
index 7a3637f3a..000000000
--- a/sci-libs/torchvision/files/torchvision-0.17.1-ffmpeg-6.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From 86620bd84b872b76db0acafec167949dca03a29e Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?=
- <[email protected]>
-Date: Tue, 7 Nov 2023 10:43:11 +0100
-Subject: [PATCH] Fix build with ffmpeg 6.0
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Zoltán Böszörményi <[email protected]>
----
- torchvision/csrc/io/decoder/stream.cpp | 11 ++---------
- 1 file changed, 2 insertions(+), 9 deletions(-)
-
-diff --git a/torchvision/csrc/io/decoder/stream.cpp 
b/torchvision/csrc/io/decoder/stream.cpp
-index 0d625ef211c..8c914050587 100644
---- a/torchvision/csrc/io/decoder/stream.cpp
-+++ b/torchvision/csrc/io/decoder/stream.cpp
-@@ -63,15 +63,8 @@ int Stream::openCodec(std::vector<DecoderMetadata>* 
metadata, int num_threads) {
-     codecCtx_->thread_count = num_threads;
-   } else {
-     // otherwise set sensible defaults
--    // with the special case for the different MPEG4 codecs
--    // that don't have threading context functions
--    if (codecCtx_->codec->capabilities & AV_CODEC_CAP_INTRA_ONLY) {
--      codecCtx_->thread_type = FF_THREAD_FRAME;
--      codecCtx_->thread_count = 2;
--    } else {
--      codecCtx_->thread_count = 8;
--      codecCtx_->thread_type = FF_THREAD_SLICE;
--    }
-+    codecCtx_->thread_count = 8;
-+    codecCtx_->thread_type = FF_THREAD_SLICE;
-   }
- 
-   int ret;

diff --git a/sci-libs/torchvision/metadata.xml 
b/sci-libs/torchvision/metadata.xml
index 9c4ddaefd..3ba68fb09 100644
--- a/sci-libs/torchvision/metadata.xml
+++ b/sci-libs/torchvision/metadata.xml
@@ -5,6 +5,9 @@
                <email>[email protected]</email>
                <name>Jorge Pizarro Callejas</name>
        </maintainer>
+       <use>
+               <flag name="rocm">Enable ROCm gpu computing support</flag>
+       </use>
        <upstream>
                <remote-id type="github">pytorch/vision</remote-id>
        </upstream>

diff --git a/sci-libs/torchvision/torchvision-0.14.1.ebuild 
b/sci-libs/torchvision/torchvision-0.14.1.ebuild
deleted file mode 100644
index 7f40fe556..000000000
--- a/sci-libs/torchvision/torchvision-0.14.1.ebuild
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2020-2021 Gentoo Authors
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=8
-
-PYTHON_COMPAT=( python3_10 )
-DISTUTILS_SINGLE_IMPL=1
-DISTUTILS_USE_PEP517=setuptools
-inherit distutils-r1
-
-DESCRIPTION="Datasets, transforms and models to specific to computer vision"
-HOMEPAGE="https://github.com/pytorch/vision";
-SRC_URI="https://github.com/pytorch/vision/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
-S="${WORKDIR}/vision-${PV}"
-
-LICENSE="BSD"
-SLOT="0"
-KEYWORDS="~amd64"
-
-RDEPEND="
-       $(python_gen_cond_dep '
-               dev-python/numpy[${PYTHON_USEDEP}]
-               dev-python/typing-extensions[${PYTHON_USEDEP}]
-               dev-python/pillow[${PYTHON_USEDEP}]
-               dev-python/requests[${PYTHON_USEDEP}]
-               dev-python/scipy[${PYTHON_USEDEP}]
-       ')
-       sci-libs/pytorch[${PYTHON_SINGLE_USEDEP}]
-       media-video/ffmpeg
-       dev-qt/qtcore:5
-"
-DEPEND="${RDEPEND}"
-BDEPEND="
-       test? (
-               $(python_gen_cond_dep '
-               dev-python/mock[${PYTHON_USEDEP}]
-               ')
-       )"
-
-distutils_enable_tests pytest

diff --git a/sci-libs/torchvision/torchvision-0.17.1.ebuild 
b/sci-libs/torchvision/torchvision-0.19.1.ebuild
similarity index 66%
rename from sci-libs/torchvision/torchvision-0.17.1.ebuild
rename to sci-libs/torchvision/torchvision-0.19.1.ebuild
index e0c72684c..a8fc6f5f7 100644
--- a/sci-libs/torchvision/torchvision-0.17.1.ebuild
+++ b/sci-libs/torchvision/torchvision-0.19.1.ebuild
@@ -3,11 +3,12 @@
 
 EAPI=8
 
-PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_COMPAT=( python3_{11..12} )
 DISTUTILS_SINGLE_IMPL=1
 DISTUTILS_USE_PEP517=setuptools
 DISTUTILS_EXT=1
-inherit distutils-r1 multiprocessing
+ROCM_SKIP_GLOBALS=1
+inherit cuda distutils-r1 multiprocessing rocm
 
 DESCRIPTION="Datasets, transforms and models to specific to computer vision"
 HOMEPAGE="https://github.com/pytorch/vision";
@@ -17,7 +18,11 @@ S="${WORKDIR}/vision-${PV}"
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
-RESTRICT="test"
+IUSE="cuda rocm test"
+REQUIRED_USE="?? ( cuda rocm )"
+RESTRICT="!test? ( test )"
+
+distutils_enable_tests pytest
 
 RDEPEND="
        $(python_gen_cond_dep '
@@ -27,13 +32,12 @@ RDEPEND="
                dev-python/requests[${PYTHON_USEDEP}]
                dev-python/scipy[${PYTHON_USEDEP}]
        ')
+       sci-libs/caffe2[cuda?,rocm?]
        sci-libs/pytorch[${PYTHON_SINGLE_USEDEP}]
        media-video/ffmpeg:=
 "
 DEPEND="${RDEPEND}"
 
-PATCHES=( "${FILESDIR}/${PN}-0.17.1-ffmpeg-6.patch" )
-
 src_compile()
 {
        export MAX_JOBS="$(makeopts_jobs)" # Let ninja respect MAKEOPTS
@@ -41,5 +45,17 @@ src_compile()
        # Ensure some ext_module sources are compiled before linking
        export MAKEOPTS="-j1"
 
+       use cuda && export NVCC_FLAGS="$(cuda_gccdir -f | tr -d \")"
+       use rocm && addpredict /dev/kfd
+
        distutils-r1_src_compile
 }
+
+python_test() {
+       use rocm && check_amdgpu
+
+       # 
https://projects.gentoo.org/python/guide/test.html#importerrors-for-c-extensions
+       rm -rf torchvision || die
+
+       epytest
+}

Reply via email to