commit:     1c2af9aa14e6a116c72cc0722948988ccffc65cb
Author:     James Beddek <telans <AT> posteo <DOT> de>
AuthorDate: Sun Jul  3 07:38:50 2022 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sun Jul  3 10:44:38 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c2af9aa

sci-libs/caffe2: add support for cuda

add missing dev-libs/FXdiv dependency
use gflags
use glog <0.5.0 https://github.com/pytorch/pytorch/issues/58054
add myself as a maintainer

Signed-off-by: James Beddek <telans <AT> posteo.de>
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 sci-libs/caffe2/caffe2-1.11.0-r2.ebuild | 37 ++++++++++++++++++++++++++-------
 sci-libs/caffe2/caffe2-1.12.0.ebuild    | 37 ++++++++++++++++++++++++++-------
 sci-libs/caffe2/metadata.xml            |  5 +++++
 3 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/sci-libs/caffe2/caffe2-1.11.0-r2.ebuild 
b/sci-libs/caffe2/caffe2-1.11.0-r2.ebuild
index d45e26d90d6d..6ae8a8dc9187 100644
--- a/sci-libs/caffe2/caffe2-1.11.0-r2.ebuild
+++ b/sci-libs/caffe2/caffe2-1.11.0-r2.ebuild
@@ -17,15 +17,17 @@ 
SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="ffmpeg nnpack +numpy opencl opencv openmp qnnpack xnnpack"
+IUSE="cuda ffmpeg nnpack +numpy opencl opencv openmp qnnpack xnnpack"
 RESTRICT="test"
 REQUIRED_USE="
        ${PYTHON_REQUIRED_USE}
        ffmpeg? ( opencv )
-"
+" # ?? ( cuda rocm )
 
 RDEPEND="
        ${PYTHON_DEPS}
+       dev-cpp/gflags:=
+       <dev-cpp/glog-0.5.0
        dev-libs/cpuinfo
        dev-libs/libfmt
        dev-libs/protobuf
@@ -34,6 +36,11 @@ RDEPEND="
        sci-libs/lapack
        sci-libs/onnx
        sci-libs/foxi
+       cuda? (
+               =dev-libs/cudnn-8*
+               dev-libs/cudnn-frontend:0/8
+               dev-util/nvidia-cuda-toolkit:=[profiler]
+       )
        ffmpeg? ( media-video/ffmpeg:= )
        nnpack? ( sci-libs/NNPACK )
        numpy? ( dev-python/numpy[${PYTHON_USEDEP}] )
@@ -47,6 +54,7 @@ DEPEND="
        dev-cpp/eigen
        dev-libs/psimd
        dev-libs/FP16
+       dev-libs/FXdiv
        dev-libs/pocketfft
        dev-libs/flatbuffers
        dev-python/pyyaml[${PYTHON_USEDEP}]
@@ -68,22 +76,35 @@ src_prepare() {
 }
 
 src_configure() {
+       if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+               ewarn "WARNING: caffe2 is being built with its default CUDA 
compute capabilities: 3.5 and 7.0."
+               ewarn "These may not be optimal for your GPU."
+               ewarn ""
+               ewarn "To configure caffe2 with the CUDA compute capability 
that is optimal for your GPU,"
+               ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and 
re-emerge caffe2."
+               ewarn "For example, to use CUDA capability 7.5 & 3.5, add: 
TORCH_CUDA_ARCH_LIST=7.5,3.5"
+               ewarn "For a Maxwell model GPU, an example value would be: 
TORCH_CUDA_ARCH_LIST=Maxwell"
+               ewarn ""
+               ewarn "You can look up your GPU's CUDA compute capability at 
https://developer.nvidia.com/cuda-gpus";
+               ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | 
grep 'CUDA Capability'"
+       fi
+
        python_setup
        local mycmakeargs=(
                -DBUILD_CUSTOM_PROTOBUF=OFF
                -DBUILD_SHARED_LIBS=ON
 
                -DUSE_CCACHE=OFF
-               -DUSE_CUDA=OFF # TODO
-               -DUSE_CUDNN=OFF # TODO
-               -DUSE_FAST_NVCC=OFF # TODO
-               #-DCUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-Auto}"
+               -DUSE_CUDA=$(usex cuda)
+               -DUSE_CUDNN=$(usex cuda)
+               -DUSE_FAST_NVCC=$(usex cuda)
+               -DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
                -DUSE_DISTRIBUTED=OFF
                -DUSE_FAKELOWP=OFF
                -DUSE_FBGEMM=OFF # TODO
                -DUSE_FFMPEG=$(usex ffmpeg)
-               -DUSE_GFLAGS=OFF # TODO
-               -DUSE_GLOG=OFF # TODO
+               -DUSE_GFLAGS=ON
+               -DUSE_GLOG=ON
                -DUSE_GLOO=OFF
                -DUSE_KINETO=OFF # TODO
                -DUSE_LEVELDB=OFF

diff --git a/sci-libs/caffe2/caffe2-1.12.0.ebuild 
b/sci-libs/caffe2/caffe2-1.12.0.ebuild
index c1e033bbfc7b..a7bc65b359da 100644
--- a/sci-libs/caffe2/caffe2-1.12.0.ebuild
+++ b/sci-libs/caffe2/caffe2-1.12.0.ebuild
@@ -17,15 +17,17 @@ 
SRC_URI="https://github.com/pytorch/${MYPN}/archive/refs/tags/v${PV}.tar.gz
 LICENSE="BSD"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="ffmpeg nnpack +numpy opencl opencv openmp qnnpack xnnpack"
+IUSE="cuda ffmpeg nnpack +numpy opencl opencv openmp qnnpack xnnpack"
 RESTRICT="test"
 REQUIRED_USE="
        ${PYTHON_REQUIRED_USE}
        ffmpeg? ( opencv )
-"
+" # ?? ( cuda rocm )
 
 RDEPEND="
        ${PYTHON_DEPS}
+       dev-cpp/gflags:=
+       <dev-cpp/glog-0.5.0
        dev-libs/cpuinfo
        dev-libs/libfmt
        dev-libs/protobuf
@@ -34,6 +36,11 @@ RDEPEND="
        sci-libs/lapack
        sci-libs/onnx
        sci-libs/foxi
+       cuda? (
+               =dev-libs/cudnn-8*
+               dev-libs/cudnn-frontend:0/8
+               dev-util/nvidia-cuda-toolkit:=[profiler]
+       )
        ffmpeg? ( media-video/ffmpeg:= )
        nnpack? ( sci-libs/NNPACK )
        numpy? ( dev-python/numpy[${PYTHON_USEDEP}] )
@@ -47,6 +54,7 @@ DEPEND="
        dev-cpp/eigen
        dev-libs/psimd
        dev-libs/FP16
+       dev-libs/FXdiv
        dev-libs/pocketfft
        dev-libs/flatbuffers
        dev-python/pyyaml[${PYTHON_USEDEP}]
@@ -68,22 +76,35 @@ src_prepare() {
 }
 
 src_configure() {
+       if use cuda && [[ -z ${TORCH_CUDA_ARCH_LIST} ]]; then
+               ewarn "WARNING: caffe2 is being built with its default CUDA 
compute capabilities: 3.5 and 7.0."
+               ewarn "These may not be optimal for your GPU."
+               ewarn ""
+               ewarn "To configure caffe2 with the CUDA compute capability 
that is optimal for your GPU,"
+               ewarn "set TORCH_CUDA_ARCH_LIST in your make.conf, and 
re-emerge caffe2."
+               ewarn "For example, to use CUDA capability 7.5 & 3.5, add: 
TORCH_CUDA_ARCH_LIST=7.5,3.5"
+               ewarn "For a Maxwell model GPU, an example value would be: 
TORCH_CUDA_ARCH_LIST=Maxwell"
+               ewarn ""
+               ewarn "You can look up your GPU's CUDA compute capability at 
https://developer.nvidia.com/cuda-gpus";
+               ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | 
grep 'CUDA Capability'"
+       fi
+
        python_setup
        local mycmakeargs=(
                -DBUILD_CUSTOM_PROTOBUF=OFF
                -DBUILD_SHARED_LIBS=ON
 
                -DUSE_CCACHE=OFF
-               -DUSE_CUDA=OFF # TODO
-               -DUSE_CUDNN=OFF # TODO
-               -DUSE_FAST_NVCC=OFF # TODO
-               #-DCUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-Auto}"
+               -DUSE_CUDA=$(usex cuda)
+               -DUSE_CUDNN=$(usex cuda)
+               -DUSE_FAST_NVCC=$(usex cuda)
+               -DTORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5 7.0}"
                -DUSE_DISTRIBUTED=OFF
                -DUSE_FAKELOWP=OFF
                -DUSE_FBGEMM=OFF # TODO
                -DUSE_FFMPEG=$(usex ffmpeg)
-               -DUSE_GFLAGS=OFF # TODO
-               -DUSE_GLOG=OFF # TODO
+               -DUSE_GFLAGS=ON
+               -DUSE_GLOG=ON
                -DUSE_GLOO=OFF
                -DUSE_KINETO=OFF # TODO
                -DUSE_LEVELDB=OFF

diff --git a/sci-libs/caffe2/metadata.xml b/sci-libs/caffe2/metadata.xml
index 48cf68b11224..25a171ff1680 100644
--- a/sci-libs/caffe2/metadata.xml
+++ b/sci-libs/caffe2/metadata.xml
@@ -5,7 +5,12 @@
                <email>tup...@gentoo.org</email>
                <name>Tupone Alfredo</name>
        </maintainer>
+       <maintainer type="person" proxied="yes">
+               <email>tel...@posteo.de</email>
+               <name>James Beddek</name>
+       </maintainer>
        <use>
+               <flag name="cuda">Add support for CUDA processing</flag>
                <flag name="ffmpeg">Add support for video processing 
operators</flag>
                <flag name="nnpack">Use NNPACK</flag>
                <flag name="numpy">Add support for math operations through 
numpy</flag>

Reply via email to