summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen, Chih-Chia <pigfoot@gmail.com>2017-06-20 18:20:14 +0800
committerChen, Chih-Chia <pigfoot@gmail.com>2017-06-20 18:20:14 +0800
commit69bcf2b32d4099c4b2f69585090508a43b4ad383 (patch)
treede8ca46f45f1c0468d91ac26f5c5f76cb683230f /sci-libs
parent[app-admin/google-compute-engine] Version bump 2.3.6 (miss manifest) (diff)
downloadpigfoot-69bcf2b32d4099c4b2f69585090508a43b4ad383.tar.gz
pigfoot-69bcf2b32d4099c4b2f69585090508a43b4ad383.tar.bz2
pigfoot-69bcf2b32d4099c4b2f69585090508a43b4ad383.zip
Add sci-libs/mxnet
Diffstat (limited to 'sci-libs')
-rw-r--r--sci-libs/mxnet/files/mxnet-9999-build-fix.patch13
-rw-r--r--sci-libs/mxnet/files/mxnet-9999-fix-c++11.patch29
-rw-r--r--sci-libs/mxnet/files/mxnet-9999-fix-python-stupid.patch47
-rw-r--r--sci-libs/mxnet/files/mxnet-9999-link-shared-zmq.patch26
-rw-r--r--sci-libs/mxnet/mxnet-9999.ebuild131
5 files changed, 246 insertions, 0 deletions
diff --git a/sci-libs/mxnet/files/mxnet-9999-build-fix.patch b/sci-libs/mxnet/files/mxnet-9999-build-fix.patch
new file mode 100644
index 0000000..84d4c08
--- /dev/null
+++ b/sci-libs/mxnet/files/mxnet-9999-build-fix.patch
@@ -0,0 +1,13 @@
+diff --git a/cmake/Modules/FindOpenBLAS.cmake.BAK b/cmake/Modules/FindOpenBLAS.cmake
+index b63817a2..71da4d42 100644
+--- a/cmake/Modules/FindOpenBLAS.cmake.BAK
++++ b/cmake/Modules/FindOpenBLAS.cmake
+@@ -39,7 +39,7 @@ SET(Open_BLAS_LIB_SEARCH_PATHS
+ )
+
+ FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS})
+-FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
++FIND_LIBRARY(OpenBLAS_LIB NAMES openblas openblas_threads PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
+ IF(NOT OpenBLAS_LIB)
+ FIND_FILE(OpenBLAS_LIB NAMES libopenblas.dll.a PATHS ${Open_BLAS_LIB_SEARCH_PATHS})
+ ENDIF()
diff --git a/sci-libs/mxnet/files/mxnet-9999-fix-c++11.patch b/sci-libs/mxnet/files/mxnet-9999-fix-c++11.patch
new file mode 100644
index 0000000..65d7b1a
--- /dev/null
+++ b/sci-libs/mxnet/files/mxnet-9999-fix-c++11.patch
@@ -0,0 +1,29 @@
+From d3fc7753ad51966d53c00a57bf0899ddfd38d9a7 Mon Sep 17 00:00:00 2001
+From: "Daniel M. Weeks" <dan@danweeks.net>
+Date: Wed, 15 Mar 2017 17:52:48 -0400
+Subject: [PATCH] Partially revert "Fix warnings, build adjustments in CMake"
+
+This brings back the C++11 flag for nvcc.
+
+Signed-off-by: Daniel M. Weeks <dan@danweeks.net>
+---
+ cmake/Cuda.cmake | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/cmake/Cuda.cmake b/cmake/Cuda.cmake
+index 35eb7ad..f571efe 100644
+--- a/cmake/Cuda.cmake
++++ b/cmake/Cuda.cmake
+@@ -164,6 +164,9 @@ macro(mshadow_cuda_compile objlist_variable)
+ endforeach()
+ if(UNIX OR APPLE)
+ list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC)
++ if(SUPPORT_CXX11)
++ list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC --std=c++11)
++ endif()
+ endif()
+
+ if(APPLE)
+--
+Daniel M. Weeks
+
diff --git a/sci-libs/mxnet/files/mxnet-9999-fix-python-stupid.patch b/sci-libs/mxnet/files/mxnet-9999-fix-python-stupid.patch
new file mode 100644
index 0000000..7126b45
--- /dev/null
+++ b/sci-libs/mxnet/files/mxnet-9999-fix-python-stupid.patch
@@ -0,0 +1,47 @@
+From ade84995a6206d1ff507c972eda528b5e9bb70b7 Mon Sep 17 00:00:00 2001
+From: "Daniel M. Weeks" <dan@danweeks.net>
+Date: Thu, 2 Feb 2017 16:36:07 -0500
+Subject: [PATCH] Fix python stupid
+
+Signed-off-by: Daniel M. Weeks <dan@danweeks.net>
+---
+ python/mxnet/base.py | 3 +--
+ python/setup.py | 2 --
+ 2 files changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/python/mxnet/base.py b/python/mxnet/base.py
+index 2f67f90b..3a7ddf40 100644
+--- a/python/mxnet/base.py
++++ b/python/mxnet/base.py
+@@ -31,8 +31,7 @@ class MXNetError(Exception):
+
+ def _load_lib():
+ """Load libary by searching possible path."""
+- lib_path = libinfo.find_lib_path()
+- lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
++ lib = ctypes.CDLL("libmxnet.so", ctypes.RTLD_GLOBAL)
+ # DMatrix functions
+ lib.MXGetLastError.restype = ctypes.c_char_p
+ return lib
+diff --git a/python/setup.py b/python/setup.py
+index f52b123f..a1c97924 100644
+--- a/python/setup.py
++++ b/python/setup.py
+@@ -18,7 +18,6 @@ libinfo_py = os.path.join(CURRENT_DIR, 'mxnet/libinfo.py')
+ libinfo = {'__file__': libinfo_py}
+ exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
+
+-LIB_PATH = libinfo['find_lib_path']()
+ __version__ = libinfo['__version__']
+
+
+@@ -71,6 +70,5 @@ setup(name='mxnet',
+ 'mxnet', 'mxnet.module', 'mxnet._ctypes',
+ 'mxnet._cy2', 'mxnet._cy3', 'mxnet.notebook'
+ ],
+- data_files=[('mxnet', [LIB_PATH[0]])],
+ url='https://github.com/dmlc/mxnet',
+ ext_modules=config_cython())
+--
+Daniel M. Weeks
+
diff --git a/sci-libs/mxnet/files/mxnet-9999-link-shared-zmq.patch b/sci-libs/mxnet/files/mxnet-9999-link-shared-zmq.patch
new file mode 100644
index 0000000..f794323
--- /dev/null
+++ b/sci-libs/mxnet/files/mxnet-9999-link-shared-zmq.patch
@@ -0,0 +1,26 @@
+From 27dd06da1b3c8557406ad2f00752d9886f8eed56 Mon Sep 17 00:00:00 2001
+From: "Daniel M. Weeks" <dan@danweeks.net>
+Date: Mon, 20 Mar 2017 23:08:54 -0400
+Subject: [PATCH] Link shared zmq
+
+Signed-off-by: Daniel M. Weeks <dan@danweeks.net>
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ba011da8..dddf824c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -153,7 +153,7 @@ if(USE_DIST_KVSTORE)
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ps-lite/CMakeLists.txt)
+ add_subdirectory("ps-lite")
+ else()
+- set(pslite_LINKER_LIBS protobuf zmq-static pslite)
++ set(pslite_LINKER_LIBS protobuf zmq pslite)
+ endif()
+ endif()
+
+--
+Daniel M. Weeks
+
diff --git a/sci-libs/mxnet/mxnet-9999.ebuild b/sci-libs/mxnet/mxnet-9999.ebuild
new file mode 100644
index 0000000..6bc87c7
--- /dev/null
+++ b/sci-libs/mxnet/mxnet-9999.ebuild
@@ -0,0 +1,131 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
+DISTUTILS_OPTIONAL=1
+inherit cmake-utils eutils distutils-r1 git-r3
+
+DESCRIPTION="Flexible and Efficient Library for Deep Learning"
+HOMEPAGE="http://mxnet.io/"
+EGIT_REPO_URI="https://github.com/dmlc/mxnet"
+#EGIT_SUBMODULES=( "*" "-dmlc-core" "-nnvm" "-ps-lite" )
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS=""
+IUSE="cuda distributed opencv openmp python +mxnet_blas_mkl mxnet_blas_openblas mxnet_blas_atlas"
+
+RDEPEND="
+ sys-devel/gcc[cxx,openmp=]
+ mxnet_blas_mkl? ( ~sci-libs/mkl-2017 )
+ mxnet_blas_openblas? ( sci-libs/openblas )
+ mxnet_blas_atlas? ( sci-libs/atlas )
+ cuda? ( dev-util/nvidia-cuda-toolkit )
+ distributed? ( sci-libs/ps-lite )
+ opencv? ( media-libs/opencv )
+ python? ( ${PYTHON_DEPS} dev-python/numpy[${PYTHON_USEDEP}] )"
+DEPEND="${RDEPEND}
+ python? ( dev-python/setuptools[${PYTHON_USEDEP}] )"
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )
+ ^^ (
+ mxnet_blas_mkl
+ mxnet_blas_openblas
+ mxnet_blas_atlas
+ )"
+
+#PATCHES=( "${FILESDIR}/${P}-build-fix.patch" "${FILESDIR}/${P}-fix-python-stupid.patch" )
+#PATCHES=( "${FILESDIR}/${P}-fix-python-stupid.patch" )
+PATCHES=( "${FILESDIR}/${P}-build-fix.patch" )
+
+pkg_setup() {
+ lsmod|grep -q '^nvidia_uvm'
+ if [ $? -ne 0 ] || [ ! -c /dev/nvidia-uvm ]; then
+ eerror "Please run: \"nvidia-modprobe -u -c 0\" before attempting to install ${PN}."
+ eerror "Otherwise the hardware autodetect will fail and all architecture modules will be built."
+ fi
+}
+
+src_prepare() {
+ default
+ if use python; then
+ cd "${S}"/python
+ distutils-r1_src_prepare
+ fi
+ if use cuda; then
+ cd "${S}"/mshadow
+ epatch "${FILESDIR}/${P}-fix-c++11.patch"
+ fi
+ if use distributed; then
+ cd "${S}"
+ epatch "${FILESDIR}/${P}-link-shared-zmq.patch"
+ fi
+}
+
+src_configure() {
+ local mycmakeargs=(
+ #-DBUILD_SHARED_LIBS=ON
+ -DUSE_CUDA=$(usex cuda)
+ -DUSE_OPENCV=$(usex opencv)
+ -DUSE_OPENMP=$(usex openmp)
+ -DUSE_DIST_KVSTORE=$(usex distributed)
+ )
+
+ if use mxnet_blas_mkl; then
+ einfo "BLAS provided by Intel Math Kernel Library"
+ get_major_version
+ mycmakeargs+=(
+ -DBLAS=MKL
+ -DUSE_MKLML_MKL=OFF
+ )
+ export MKL_ROOT=$(find /opt/intel -xtype d -regextype posix-extended -regex '.*compilers_and_libraries_[[:digit:]\.]+/linux/mkl$')
+ if [[ -z ${MKL_ROOT} ]]; then
+ eerror "Cannot find intel library in /opt/intel."
+ return 0
+ fi
+ elif use mxnet_blas_openblas; then
+ einfo "BLAS provided by OpenBLAS"
+ mycmakeargs+=(
+ -DBLAS=Open
+ )
+ elif use mxnet_blas_atlas; then
+ einfo "BLAS provided by ATLAS"
+ mycmakeargs+=(
+ -DBLAS=Atlas
+ )
+ fi
+
+ addwrite /dev/nvidia-uvm
+ addwrite /dev/nvidiactl
+ addwrite /dev/nvidia0
+
+ cmake-utils_src_configure
+
+ if use python; then
+ cd python;
+ distutils-r1_src_configure
+ fi
+}
+
+src_compile() {
+ cmake-utils_src_compile
+
+ if use python; then
+ cd python
+ export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${BUILD_DIR}"
+ distutils-r1_src_compile
+ fi
+}
+
+src_install() {
+ doheader -r include/mxnet
+
+ if use python; then
+ cd python
+ distutils-r1_src_install
+ fi
+
+ cd "${BUILD_DIR}"
+ dolib.so libmxnet.so
+}