mxnet: convert to CMakePackage (#21385)
* mxnet: convert to CMakePackage * Package isn't installed yet, can't find libs * Fix bug with GCC 8+ and CUDA 10 on PowerPC * Add space * Add patch to fix cmake cuda flags * Space no longer needed * Add patch to fix OpenBLAS linking * Add missing CMake flag * Fix env set, default to Distribution * Add new version, patch
This commit is contained in:
parent
02b64c8903
commit
c3206656bc
8 changed files with 148 additions and 236 deletions
|
@ -0,0 +1,14 @@
|
||||||
|
https://github.com/apache/incubator-mxnet/pull/17645
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 437d01668..1049a53b2 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -662,7 +662,7 @@ add_subdirectory("3rdparty/mshadow")
|
||||||
|
|
||||||
|
set(MXNET_INSTALL_TARGETS mxnet)
|
||||||
|
if(UNIX)
|
||||||
|
- string(APPEND CMAKE_CUDA_FLAGS "${CUDA_ARCH_FLAGS_SPACES}")
|
||||||
|
+ string(APPEND CMAKE_CUDA_FLAGS " ${CUDA_ARCH_FLAGS_SPACES}")
|
||||||
|
# Create dummy file since we want an empty shared library before linking
|
||||||
|
set(DUMMY_SOURCE ${CMAKE_BINARY_DIR}/dummy.c)
|
||||||
|
file(WRITE ${DUMMY_SOURCE} "")
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index 4746cc434..335c79b64 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -518,7 +518,7 @@ ifeq ($(USE_CUDA), 1)
|
|
||||||
endif
|
|
||||||
# Make sure to add stubs as fallback in order to be able to build
|
|
||||||
# without full CUDA install (especially if run without nvidia-docker)
|
|
||||||
- LDFLAGS += -L/usr/local/cuda/lib64/stubs
|
|
||||||
+ LDFLAGS += -L$(USE_CUDA_PATH)/lib64/stubs
|
|
||||||
ifeq ($(USE_NCCL), 1)
|
|
||||||
ifneq ($(USE_NCCL_PATH), NONE)
|
|
||||||
CFLAGS += -I$(USE_NCCL_PATH)/include
|
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index 4746cc434..e738fc53f 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -509,7 +509,7 @@ LIB_DEP += $(DMLC_CORE)/libdmlc.a $(NNVM_PATH)/lib/libnnvm.a
|
|
||||||
ALL_DEP = $(OBJ) $(EXTRA_OBJ) $(PLUGIN_OBJ) $(LIB_DEP)
|
|
||||||
|
|
||||||
ifeq ($(USE_CUDA), 1)
|
|
||||||
- CFLAGS += -I$(ROOTDIR)/3rdparty/nvidia_cub
|
|
||||||
+ CFLAGS += -I$(CUB_INCLUDE) -I$(CUDNN_PATH)/include
|
|
||||||
ALL_DEP += $(CUOBJ) $(EXTRA_CUOBJ) $(PLUGIN_CUOBJ)
|
|
||||||
LDFLAGS += -lcufft
|
|
||||||
ifeq ($(ENABLE_CUDA_RTC), 1)
|
|
|
@ -1,35 +0,0 @@
|
||||||
commit 638527ffaa35ffb0bf88a32910b809df09432406
|
|
||||||
Author: Toyohisa Kameyama <kameyama@riken.jp>
|
|
||||||
Date: Mon May 18 11:58:00 2020 +0900
|
|
||||||
|
|
||||||
Makefile bug fix for opencv4.
|
|
||||||
|
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index 51930c782..7f5d4da39 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -165,7 +165,23 @@ endif
|
|
||||||
ifeq ($(USE_OPENCV), 1)
|
|
||||||
CFLAGS += -DMXNET_USE_OPENCV=1
|
|
||||||
ifneq ($(filter-out NONE, $(USE_OPENCV_INC_PATH)),)
|
|
||||||
- CFLAGS += -I$(USE_OPENCV_INC_PATH)/include
|
|
||||||
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/include/opencv4/opencv2/opencv*),)
|
|
||||||
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/include/opencv4
|
|
||||||
+ endif
|
|
||||||
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/include/opencv2/opencv*),)
|
|
||||||
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/include
|
|
||||||
+ endif
|
|
||||||
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/opencv4/opencv2/opencv*),)
|
|
||||||
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)/opencv4
|
|
||||||
+ endif
|
|
||||||
+ ifneq ($(wildcard $(USE_OPENCV_INC_PATH)/opencv2/opencv*),)
|
|
||||||
+ opencv_inc = -I$(USE_OPENCV_INC_PATH)
|
|
||||||
+ endif
|
|
||||||
+ ifneq ($(filter-out NONE, $(opencv_inc)),)
|
|
||||||
+ CFLAGS += $(opencv_inc)
|
|
||||||
+ else
|
|
||||||
+$(error Cannot determine OpenCV include path)
|
|
||||||
+ endif
|
|
||||||
ifeq ($(filter-out NONE, $(USE_OPENCV_LIB_PATH)),)
|
|
||||||
$(error Please add the path of OpenCV shared library path into `USE_OPENCV_LIB_PATH`, when `USE_OPENCV_INC_PATH` is not NONE)
|
|
||||||
endif
|
|
|
@ -1,81 +0,0 @@
|
||||||
From 22b64127d7acc9c255b007e120e2a721f4e136d2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jianwen WEI <weijianwen@gmail.com>
|
|
||||||
Date: Fri, 18 Aug 2017 23:32:16 +0800
|
|
||||||
Subject: [PATCH] Enable customize CUB MSHADOW PSLITE CUDA paths.
|
|
||||||
|
|
||||||
---
|
|
||||||
Makefile | 26 +++++++++++++++++++++-----
|
|
||||||
1 file changed, 21 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/Makefile b/Makefile
|
|
||||||
index c71cb13..a53d072 100644
|
|
||||||
--- a/Makefile
|
|
||||||
+++ b/Makefile
|
|
||||||
@@ -14,6 +14,19 @@ ifndef DMLC_CORE
|
|
||||||
DMLC_CORE = $(ROOTDIR)/dmlc-core
|
|
||||||
endif
|
|
||||||
|
|
||||||
+ifndef MSHADOW_PATH
|
|
||||||
+ MSHADOW_PATH = $(ROOTDIR)/mshadow
|
|
||||||
+endif
|
|
||||||
+ifneq ("$(wildcard $(MSHADOW_PATH)/include/mshadow/base.h)","")
|
|
||||||
+MSHADOW_INC = $(MSHADOW_PATH)/include
|
|
||||||
+else
|
|
||||||
+MSHADOW_INC = $(MSHADOW_PATH)
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
+ifndef PS_PATH
|
|
||||||
+ PS_PATH = $(ROOTDIR)/ps-lite
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
ifndef NNVM_PATH
|
|
||||||
NNVM_PATH = $(ROOTDIR)/nnvm
|
|
||||||
endif
|
|
||||||
@@ -32,7 +45,7 @@ ifeq ($(USE_MKL2017), 1)
|
|
||||||
export USE_MKLML = $(lastword $(RETURN_STRING))
|
|
||||||
endif
|
|
||||||
|
|
||||||
-include mshadow/make/mshadow.mk
|
|
||||||
+include $(MSHADOW_PATH)/make/mshadow.mk
|
|
||||||
include $(DMLC_CORE)/make/dmlc.mk
|
|
||||||
|
|
||||||
# all tge possible warning tread
|
|
||||||
@@ -49,7 +62,7 @@ ifeq ($(DEBUG), 1)
|
|
||||||
else
|
|
||||||
CFLAGS += -O3 -DNDEBUG=1
|
|
||||||
endif
|
|
||||||
-CFLAGS += -I$(ROOTDIR)/mshadow/ -I$(ROOTDIR)/dmlc-core/include -fPIC -I$(NNVM_PATH)/include -Iinclude $(MSHADOW_CFLAGS)
|
|
||||||
+CFLAGS += -I$(MSHADOW_INC) -I$(DMLC_CORE)/include -fPIC -I$(NNVM_PATH)/include -Iinclude $(MSHADOW_CFLAGS)
|
|
||||||
LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)
|
|
||||||
ifeq ($(DEBUG), 1)
|
|
||||||
NVCCFLAGS = -std=c++11 -Xcompiler -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
|
|
||||||
@@ -125,8 +138,11 @@ ifneq ($(USE_CUDA_PATH), NONE)
|
|
||||||
NVCC=$(USE_CUDA_PATH)/bin/nvcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
+ifndef CUB_INCLUDE
|
|
||||||
+ CUB_PATH = $(ROOTDIR)/cub
|
|
||||||
+endif
|
|
||||||
+
|
|
||||||
# ps-lite
|
|
||||||
-PS_PATH=$(ROOTDIR)/ps-lite
|
|
||||||
DEPS_PATH=$(shell pwd)/deps
|
|
||||||
include $(PS_PATH)/make/ps.mk
|
|
||||||
ifeq ($(USE_DIST_KVSTORE), 1)
|
|
||||||
@@ -181,11 +197,11 @@ else
|
|
||||||
endif
|
|
||||||
|
|
||||||
# all dep
|
|
||||||
-LIB_DEP += $(DMLC_CORE)/libdmlc.a $(NNVM_PATH)/lib/libnnvm.a
|
|
||||||
+LIB_DEP += $(DMLC_CORE)/lib/libdmlc.a $(NNVM_PATH)/lib/libnnvm.a
|
|
||||||
ALL_DEP = $(OBJ) $(EXTRA_OBJ) $(PLUGIN_OBJ) $(LIB_DEP)
|
|
||||||
|
|
||||||
ifeq ($(USE_CUDA), 1)
|
|
||||||
- CFLAGS += -I$(ROOTDIR)/cub
|
|
||||||
+ CFLAGS += -I$(CUB_INCLUDE) -I$(USE_CUDA_PATH)/include -I$(CUDNN_PATH)/include
|
|
||||||
ALL_DEP += $(CUOBJ) $(EXTRA_CUOBJ) $(PLUGIN_CUOBJ)
|
|
||||||
LDFLAGS += -lcuda -lcufft
|
|
||||||
SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
14
var/spack/repos/builtin/packages/mxnet/openblas-1.6.0.patch
Normal file
14
var/spack/repos/builtin/packages/mxnet/openblas-1.6.0.patch
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
https://github.com/apache/incubator-mxnet/pull/19174
|
||||||
|
--- a/CMakeLists.txt 2020-01-30 17:45:22.000000000 -0600
|
||||||
|
+++ b/CMakeLists.txt 2021-02-03 11:11:30.000000000 -0600
|
||||||
|
@@ -446,7 +446,9 @@
|
||||||
|
if(USE_LAPACK)
|
||||||
|
message("USE_LAPACK is ON")
|
||||||
|
add_definitions(-DMXNET_USE_LAPACK=1)
|
||||||
|
- if (NOT MSVC)
|
||||||
|
+ # BLAS=open case is handled in ChooseBlas.cmake
|
||||||
|
+ if(NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Distribution"
|
||||||
|
+ AND NOT BLAS STREQUAL "Open" AND NOT BLAS STREQUAL "open")
|
||||||
|
list(APPEND mxnet_LINKER_LIBS lapack)
|
||||||
|
endif()
|
||||||
|
endif()
|
16
var/spack/repos/builtin/packages/mxnet/openblas-1.7.0.patch
Normal file
16
var/spack/repos/builtin/packages/mxnet/openblas-1.7.0.patch
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
https://github.com/apache/incubator-mxnet/pull/19174
|
||||||
|
--- a/CMakeLists.txt 2020-07-16 00:32:00.000000000 -0500
|
||||||
|
+++ b/CMakeLists.txt 2021-02-02 15:30:13.000000000 -0600
|
||||||
|
@@ -446,9 +446,9 @@
|
||||||
|
if(USE_LAPACK)
|
||||||
|
message("USE_LAPACK is ON")
|
||||||
|
add_definitions(-DMXNET_USE_LAPACK=1)
|
||||||
|
- # In the CMAKE_BUILD_TYPE="Distribution" case, we link against Blas libraries
|
||||||
|
- # that already provide lapack symbols. Thus -llapack would be wrong.
|
||||||
|
- if (NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Distribution")
|
||||||
|
+ # BLAS=open case is handled in ChooseBlas.cmake
|
||||||
|
+ if(NOT MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL "Distribution"
|
||||||
|
+ AND NOT BLAS STREQUAL "Open" AND NOT BLAS STREQUAL "open")
|
||||||
|
list(APPEND mxnet_LINKER_LIBS lapack)
|
||||||
|
endif()
|
||||||
|
endif()
|
|
@ -6,129 +6,139 @@
|
||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
|
|
||||||
class Mxnet(MakefilePackage, CudaPackage):
|
class Mxnet(CMakePackage, CudaPackage):
|
||||||
"""MXNet is a deep learning framework
|
"""MXNet is a deep learning framework
|
||||||
designed for both efficiency and flexibility."""
|
designed for both efficiency and flexibility."""
|
||||||
|
|
||||||
homepage = "http://mxnet.io"
|
homepage = "https://mxnet.apache.org"
|
||||||
url = "https://github.com/apache/incubator-mxnet/releases/download/1.3.0/apache-mxnet-src-1.3.0-incubating.tar.gz"
|
url = "https://archive.apache.org/dist/incubator/mxnet/1.7.0/apache-mxnet-src-1.7.0-incubating.tar.gz"
|
||||||
|
list_url = "https://mxnet.apache.org/get_started/download"
|
||||||
|
git = "https://github.com/apache/incubator-mxnet.git"
|
||||||
|
|
||||||
maintainers = ['adamjstewart']
|
maintainers = ['adamjstewart']
|
||||||
|
import_modules = [
|
||||||
|
'mxnet', 'mxnet.numpy_extension', 'mxnet.optimizer', 'mxnet.module',
|
||||||
|
'mxnet.io', 'mxnet.cython', 'mxnet.ndarray', 'mxnet.gluon',
|
||||||
|
'mxnet.symbol', 'mxnet._cy3', 'mxnet.contrib', 'mxnet.numpy',
|
||||||
|
'mxnet._ffi', 'mxnet.image', 'mxnet.kvstore', 'mxnet.notebook',
|
||||||
|
'mxnet._ctypes', 'mxnet.rnn', 'mxnet.ndarray.numpy_extension',
|
||||||
|
'mxnet.ndarray.numpy', 'mxnet.gluon.nn', 'mxnet.gluon.model_zoo',
|
||||||
|
'mxnet.gluon.contrib', 'mxnet.gluon.data', 'mxnet.gluon.rnn',
|
||||||
|
'mxnet.gluon.model_zoo.vision', 'mxnet.gluon.contrib.nn',
|
||||||
|
'mxnet.gluon.contrib.estimator', 'mxnet.gluon.contrib.cnn',
|
||||||
|
'mxnet.gluon.contrib.data', 'mxnet.gluon.contrib.rnn',
|
||||||
|
'mxnet.gluon.data.vision', 'mxnet.symbol.numpy_extension',
|
||||||
|
'mxnet.symbol.numpy', 'mxnet.contrib.onnx',
|
||||||
|
'mxnet.contrib.svrg_optimization', 'mxnet.contrib.amp',
|
||||||
|
'mxnet.contrib.text', 'mxnet.contrib.onnx.mx2onnx',
|
||||||
|
'mxnet.contrib.onnx.onnx2mx', 'mxnet.contrib.amp.lists',
|
||||||
|
'mxnet._ffi._cy3', 'mxnet._ffi._ctypes'
|
||||||
|
]
|
||||||
|
|
||||||
|
version('master', branch='master')
|
||||||
|
version('1.master', branch='v1.x')
|
||||||
|
version('1.7.0', sha256='1d20c9be7d16ccb4e830e9ee3406796efaf96b0d93414d676337b64bc59ced18')
|
||||||
version('1.6.0', sha256='01eb06069c90f33469c7354946261b0a94824bbaf819fd5d5a7318e8ee596def')
|
version('1.6.0', sha256='01eb06069c90f33469c7354946261b0a94824bbaf819fd5d5a7318e8ee596def')
|
||||||
version('1.3.0', sha256='c00d6fbb2947144ce36c835308e603f002c1eb90a9f4c5a62f4d398154eed4d2')
|
version('1.3.0', sha256='c00d6fbb2947144ce36c835308e603f002c1eb90a9f4c5a62f4d398154eed4d2')
|
||||||
|
|
||||||
|
variant('build_type', default='Distribution',
|
||||||
|
description='CMake build type',
|
||||||
|
values=('Distribution', 'Debug', 'Release',
|
||||||
|
'RelWithDebInfo', 'MinSizeRel'))
|
||||||
variant('cuda', default=True, description='Enable CUDA support')
|
variant('cuda', default=True, description='Enable CUDA support')
|
||||||
|
variant('cudnn', default=True, description='Build with cudnn support')
|
||||||
|
variant('nccl', default=False, description='Use NVidia NCCL with CUDA')
|
||||||
variant('opencv', default=True, description='Enable OpenCV support')
|
variant('opencv', default=True, description='Enable OpenCV support')
|
||||||
variant('openmp', default=False, description='Enable OpenMP support')
|
variant('openmp', default=False, description='Enable OpenMP support')
|
||||||
variant('profiler', default=False, description='Enable Profiler (for verification and debug only).')
|
variant('lapack', default=True, description='Build with lapack support')
|
||||||
|
variant('mkldnn', default=False, description='Build with MKL-DNN support')
|
||||||
variant('python', default=True, description='Install python bindings')
|
variant('python', default=True, description='Install python bindings')
|
||||||
|
|
||||||
depends_on('dmlc-core@20170508')
|
depends_on('cmake@3.13:', type='build')
|
||||||
depends_on('dmlc-core+openmp', when='+openmp')
|
depends_on('ninja', type='build')
|
||||||
depends_on('dmlc-core~openmp', when='~openmp')
|
depends_on('pkgconfig', when='@1.6.0', type='build')
|
||||||
depends_on('mshadow@20170721')
|
|
||||||
depends_on('ps-lite@20170328')
|
|
||||||
depends_on('nnvm~shared@20170418')
|
|
||||||
depends_on('blas')
|
depends_on('blas')
|
||||||
depends_on('cudnn', when='+cuda')
|
depends_on('cudnn', when='+cudnn')
|
||||||
depends_on('cudnn', when='+cuda')
|
depends_on('nccl', when='+nccl')
|
||||||
depends_on('cub', when='+cuda')
|
depends_on('opencv+core+highgui+imgproc+imgcodecs', when='+opencv')
|
||||||
depends_on('opencv+core+imgproc+highgui+jpeg+png+tiff~eigen~ipp@3.0:3.4.99', when='@1.3.0 +opencv')
|
depends_on('lapack', when='+lapack')
|
||||||
depends_on('opencv+core+imgproc+highgui+jpeg+png+tiff~eigen~ipp@3.0:', when='+opencv')
|
depends_on('onednn', when='+mkldnn')
|
||||||
|
|
||||||
# python extensions
|
# python/setup.py
|
||||||
depends_on('python@2.7:', type=('build', 'run'), when='+python')
|
|
||||||
depends_on('py-setuptools', type='build', when='+python')
|
|
||||||
depends_on('py-numpy@:1.15.0', type=('build', 'run'), when='@1.3.0 +python')
|
|
||||||
depends_on('py-numpy@1.16:', type=('build', 'run'), when='@1.6.0 +python')
|
|
||||||
extends('python', when='+python')
|
extends('python', when='+python')
|
||||||
|
depends_on('python@2.7:2.8,3.4:', when='+python', type=('build', 'run'))
|
||||||
|
depends_on('py-setuptools', when='+python', type='build')
|
||||||
|
depends_on('py-cython', when='+python', type='build')
|
||||||
|
depends_on('py-numpy@1.16.1:1.999', when='@1.6:+python', type=('build', 'run'))
|
||||||
|
depends_on('py-numpy@1.8.2:1.15.0', when='@1.3.0+python', type=('build', 'run'))
|
||||||
|
depends_on('py-requests@2.20.0:2.999', when='@1.6:+python', type=('build', 'run'))
|
||||||
|
depends_on('py-requests@2.18.4:2.18.999', when='@1.3.0+python', type=('build', 'run'))
|
||||||
|
depends_on('py-graphviz@0.8.1:0.8.999', when='+python', type=('build', 'run'))
|
||||||
|
|
||||||
patch('makefile.opencv.patch', when='@1.6.0')
|
conflicts('+cudnn', when='~cuda')
|
||||||
patch('makefile-cudnn-path-1.6.patch', when='@1.6.0')
|
conflicts('+nccl', when='~cuda')
|
||||||
patch('makefile-cuda-stub-1.6.patch', when='@1.6.0')
|
|
||||||
|
patch('openblas-1.7.0.patch', when='@1.7.0:1.master')
|
||||||
|
patch('openblas-1.6.0.patch', when='@1.6.0')
|
||||||
|
patch('cmake_cuda_flags.patch', when='@1.6:1.7')
|
||||||
patch('parallell_shuffle.patch', when='@1.6.0')
|
patch('parallell_shuffle.patch', when='@1.6.0')
|
||||||
|
|
||||||
def build(self, spec, prefix):
|
# python/setup.py assumes libs can be found in build directory
|
||||||
# copy template configuration file
|
build_directory = 'build'
|
||||||
copy('make/config.mk', 'config.mk')
|
generator = 'Ninja'
|
||||||
|
|
||||||
# remove compiler overrides
|
def setup_run_environment(self, env):
|
||||||
filter_file('export CC = gcc', '', 'config.mk', string=True)
|
env.set('MXNET_LIBRARY_PATH', self.spec['mxnet'].libs[0])
|
||||||
filter_file('export CXX = g++', '', 'config.mk', string=True)
|
|
||||||
|
|
||||||
# add blas prefix to include paths
|
if self.spec.satisfies('+nccl ^nccl@2.1:'):
|
||||||
filter_file(
|
env.set('NCCL_LAUNCH_MODE', 'PARALLEL')
|
||||||
'-I$(NNVM_PATH)/include',
|
|
||||||
'-I$(NNVM_PATH)/include -I%s/include' % spec['blas'].prefix,
|
|
||||||
'Makefile', string=True
|
|
||||||
)
|
|
||||||
|
|
||||||
# mxnet comes with its own version of nnvm and dmlc.
|
|
||||||
# building it will fail if we use the spack paths
|
|
||||||
|
|
||||||
|
def cmake_args(self):
|
||||||
|
# https://mxnet.apache.org/get_started/build_from_source
|
||||||
args = [
|
args = [
|
||||||
'CC=%s' % self.compiler.cc,
|
self.define_from_variant('USE_CUDA', 'cuda'),
|
||||||
'CXX=%s' % self.compiler.cxx,
|
self.define_from_variant('USE_CUDNN', 'cudnn'),
|
||||||
'MSHADOW_PATH=%s' % spec['mshadow'].prefix,
|
self.define_from_variant('USE_OPENCV', 'opencv'),
|
||||||
'PS_PATH=%s' % spec['ps-lite'].prefix,
|
self.define_from_variant('USE_OPENMP', 'openmp'),
|
||||||
'USE_OPENMP=%s' % ('1' if '+openmp' in spec else '0'),
|
self.define_from_variant('USE_LAPACK', 'lapack'),
|
||||||
'USE_CUDA=%s' % ('1' if '+cuda' in spec else '0'),
|
self.define_from_variant('USE_MKLDNN', 'mkldnn'),
|
||||||
'USE_CUDNN=%s' % ('1' if '+cuda' in spec else '0'),
|
|
||||||
'USE_OPENCV=%s' % ('1' if '+opencv' in spec else '0'),
|
|
||||||
'USE_PROFILER=%s' % ('1' if '+profiler' in spec else '0'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if '+opencv' in spec:
|
if '+cuda' in self.spec:
|
||||||
if spec.satisfies('@1.3.0'):
|
if 'cuda_arch=none' not in self.spec:
|
||||||
filter_file(
|
cuda_arch = ';'.join('{0:.1f}'.format(float(i) / 10.0) for i
|
||||||
'$(shell pkg-config --cflags opencv)',
|
in self.spec.variants['cuda_arch'].value)
|
||||||
spec['opencv'].headers.include_flags,
|
args.append(self.define('MXNET_CUDA_ARCH', cuda_arch))
|
||||||
'Makefile', string=True
|
|
||||||
)
|
|
||||||
filter_file(
|
|
||||||
'$(filter-out -lopencv_ts, '
|
|
||||||
'$(shell pkg-config --libs opencv))',
|
|
||||||
spec['opencv'].libs.link_flags,
|
|
||||||
'Makefile', string=True
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
args.extend(
|
|
||||||
['USE_OPENCV_INC_PATH=' +
|
|
||||||
spec['opencv'].headers.directories[0],
|
|
||||||
'USE_OPENCV_LIB_PATH=' +
|
|
||||||
spec['opencv'].libs.directories[0]]
|
|
||||||
)
|
|
||||||
|
|
||||||
if 'openblas' in spec:
|
args.append(self.define_from_variant('USE_NCCL', 'nccl'))
|
||||||
args.extend(['USE_BLAS=openblas'])
|
|
||||||
elif 'atlas' in spec or 'cblas' in spec:
|
|
||||||
args.extend(['USE_BLAS=atlas'])
|
|
||||||
else:
|
|
||||||
args.extend(['USE_BLAS=blas'])
|
|
||||||
|
|
||||||
if '+cuda' in spec:
|
# Workaround for bug in GCC 8+ and CUDA 10 on PowerPC
|
||||||
args.extend(['USE_CUDA_PATH=%s' % spec['cuda'].prefix,
|
args.append(self.define(
|
||||||
'CUDNN_PATH=%s' % spec['cudnn'].prefix,
|
'CMAKE_CUDA_FLAGS', self.compiler.cxx11_flag))
|
||||||
'CUB_INCLUDE=%s' % spec['cub'].prefix.include])
|
|
||||||
# By default, all cuda architectures are built. Restrict only
|
|
||||||
# if a specific list of architectures is specified in cuda_arch.
|
|
||||||
if 'cuda_arch=none' not in spec:
|
|
||||||
cuda_flags = self.cuda_flags(self.spec.variants['cuda_arch'].value)
|
|
||||||
args.append('CUDA_ARCH={0}'.format(' '.join(cuda_flags)))
|
|
||||||
|
|
||||||
make(*args)
|
return args
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
@run_after('build')
|
||||||
# mxnet is just a shared library -- no need to install a bin tree
|
def build_python(self):
|
||||||
|
if '+python' in self.spec:
|
||||||
install_tree('include', prefix.include)
|
|
||||||
install_tree('lib', prefix.lib)
|
|
||||||
|
|
||||||
# install python bindings
|
|
||||||
if '+python' in spec:
|
|
||||||
# The python libs are in a separate dir, and it is necessary to change
|
|
||||||
# directory so that setup.py picks them up.
|
|
||||||
with working_dir('python'):
|
with working_dir('python'):
|
||||||
setup_py('install', '--prefix={0}'.format(prefix),
|
setup_py('build')
|
||||||
|
|
||||||
|
@run_after('install')
|
||||||
|
def install_python(self):
|
||||||
|
if '+python' in self.spec:
|
||||||
|
with working_dir('python'):
|
||||||
|
setup_py('install', '--prefix={0}'.format(self.prefix),
|
||||||
'--single-version-externally-managed', '--root=/')
|
'--single-version-externally-managed', '--root=/')
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
"""Attempts to import modules of the installed package."""
|
||||||
|
|
||||||
|
if '+python' in self.spec:
|
||||||
|
# Make sure we are importing the installed modules,
|
||||||
|
# not the ones in the source directory
|
||||||
|
for module in self.import_modules:
|
||||||
|
self.run_test(self.spec['python'].command.path,
|
||||||
|
['-c', 'import {0}'.format(module)],
|
||||||
|
purpose='checking import of {0}'.format(module),
|
||||||
|
work_dir='spack-test')
|
||||||
|
|
Loading…
Reference in a new issue