2017-02-14 03:57:46 +08:00
|
|
|
##############################################################################
|
2017-09-07 11:44:16 +08:00
|
|
|
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
|
2017-02-14 03:57:46 +08:00
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
2017-11-05 08:08:04 +08:00
|
|
|
# For details, see https://github.com/spack/spack
|
2017-06-25 13:22:55 +08:00
|
|
|
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
2017-02-14 03:57:46 +08:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
##############################################################################
|
|
|
|
from spack import *
|
|
|
|
|
|
|
|
|
|
|
|
class Lbann(CMakePackage):
|
|
|
|
"""LBANN: Livermore Big Artificial Neural Network Toolkit. A distributed
|
|
|
|
memory, HPC-optimized, model and data parallel training toolkit for deep
|
|
|
|
neural networks."""
|
|
|
|
|
|
|
|
homepage = "http://software.llnl.gov/lbann/"
|
|
|
|
url = "https://github.com/LLNL/lbann/archive/v0.91.tar.gz"
|
|
|
|
|
|
|
|
version('develop', git='https://github.com/LLNL/lbann.git', branch="develop")
|
2018-01-03 10:01:23 +08:00
|
|
|
version('0.93', '1913a25a53d4025fa04c16f14afdaa55')
|
|
|
|
version('0.92', 'c0eb1595a7c74640e96f280beb497564')
|
2017-02-14 03:57:46 +08:00
|
|
|
version('0.91', '83b0ec9cd0b7625d41dfb06d2abd4134')
|
|
|
|
|
|
|
|
variant('gpu', default=False, description='Builds with support for GPUs via CUDA and cuDNN')
|
2018-01-03 10:01:23 +08:00
|
|
|
variant('nccl', default=False, description='Builds with support for NCCL communication lib')
|
2017-02-14 03:57:46 +08:00
|
|
|
variant('opencv', default=True, description='Builds with support for image processing routines with OpenCV')
|
|
|
|
variant('seq_init', default=False, description='Force serial initialization of weight matrices.')
|
2018-01-03 10:01:23 +08:00
|
|
|
variant('dtype', default='float',
|
|
|
|
description='Type for floating point representation of weights',
|
|
|
|
values=('float', 'double'))
|
2017-08-08 02:41:13 +08:00
|
|
|
variant('build_type', default='Release',
|
|
|
|
description='The build type to build',
|
|
|
|
values=('Debug', 'Release'))
|
2017-02-14 03:57:46 +08:00
|
|
|
|
2017-08-11 21:29:24 +08:00
|
|
|
depends_on('elemental +openmp_blas +shared +int64')
|
|
|
|
depends_on('elemental +openmp_blas +shared +int64 build_type=Debug',
|
2017-08-08 02:41:13 +08:00
|
|
|
when=('build_type=Debug'))
|
2017-02-14 03:57:46 +08:00
|
|
|
depends_on('cuda', when='+gpu')
|
2017-11-02 08:25:28 +08:00
|
|
|
depends_on('cudnn', when='+gpu')
|
|
|
|
depends_on('cub', when='+gpu')
|
2017-02-14 03:57:46 +08:00
|
|
|
depends_on('mpi')
|
2018-01-26 04:10:37 +08:00
|
|
|
depends_on('hwloc ~pci ~libxml2')
|
2017-11-02 08:25:28 +08:00
|
|
|
depends_on('opencv@3.2.0: +openmp +core +highgui +imgproc +jpeg +png +tiff +zlib ~eigen', when='+opencv')
|
2017-04-11 10:02:32 +08:00
|
|
|
depends_on('protobuf@3.0.2:')
|
2017-08-08 02:41:13 +08:00
|
|
|
depends_on('cnpy')
|
2018-01-03 10:01:23 +08:00
|
|
|
depends_on('nccl', when='+gpu +nccl')
|
2017-02-14 03:57:46 +08:00
|
|
|
|
2018-01-24 09:05:54 +08:00
|
|
|
@property
|
|
|
|
def common_config_args(self):
|
2018-01-03 10:01:23 +08:00
|
|
|
spec = self.spec
|
|
|
|
# Environment variables
|
|
|
|
CPPFLAGS = []
|
2018-01-24 09:05:54 +08:00
|
|
|
CPPFLAGS.append('-DLBANN_SET_EL_RNG -ldl')
|
2018-01-03 10:01:23 +08:00
|
|
|
|
2018-01-24 09:05:54 +08:00
|
|
|
return [
|
2018-01-03 10:01:23 +08:00
|
|
|
'-DCMAKE_INSTALL_MESSAGE=LAZY',
|
|
|
|
'-DCMAKE_CXX_FLAGS=%s' % ' '.join(CPPFLAGS),
|
2018-01-24 09:05:54 +08:00
|
|
|
'-DLBANN_VERSION=spack',
|
|
|
|
'-DCNPY_DIR={0}'.format(spec['cnpy'].prefix),
|
|
|
|
]
|
|
|
|
|
|
|
|
# Get any recent versions or non-numeric version
|
|
|
|
# Note that develop > numeric and non-develop < numeric
|
|
|
|
@when('@:0.91' or '@0.94:')
|
|
|
|
def cmake_args(self):
|
|
|
|
spec = self.spec
|
|
|
|
args = self.common_config_args
|
|
|
|
args.extend([
|
2018-01-03 10:01:23 +08:00
|
|
|
'-DLBANN_WITH_TOPO_AWARE:BOOL=%s' % ('+gpu +nccl' in spec),
|
|
|
|
'-DLBANN_SEQUENTIAL_INITIALIZATION:BOOL=%s' %
|
|
|
|
('+seq_init' in spec),
|
|
|
|
'-DLBANN_WITH_TBINF=OFF',
|
|
|
|
'-DLBANN_WITH_VTUNE=OFF',
|
|
|
|
'-DElemental_DIR={0}/CMake/elemental'.format(
|
|
|
|
spec['elemental'].prefix),
|
|
|
|
'-DLBANN_DATATYPE={0}'.format(spec.variants['dtype'].value),
|
2018-01-24 09:05:54 +08:00
|
|
|
'-DLBANN_VERBOSE=0'])
|
2018-01-03 10:01:23 +08:00
|
|
|
|
|
|
|
if '+opencv' in spec:
|
|
|
|
args.extend(['-DOpenCV_DIR:STRING={0}'.format(
|
|
|
|
spec['opencv'].prefix)])
|
|
|
|
|
|
|
|
if '+gpu' in spec:
|
|
|
|
args.extend([
|
|
|
|
'-DLBANN_WITH_CUDA:BOOL=%s' % ('+gpu' in spec),
|
|
|
|
'-DLBANN_WITH_SOFTMAX_CUDA:BOOL=%s' % ('+gpu' in spec),
|
|
|
|
'-DCUDA_TOOLKIT_ROOT_DIR={0}'.format(
|
|
|
|
spec['cuda'].prefix)])
|
|
|
|
args.extend([
|
|
|
|
'-DLBANN_WITH_CUDNN:BOOL=%s' % ('+gpu' in spec),
|
|
|
|
'-DcuDNN_DIR={0}'.format(
|
|
|
|
spec['cudnn'].prefix)])
|
|
|
|
args.extend(['-DCUB_DIR={0}'.format(
|
|
|
|
spec['cub'].prefix)])
|
|
|
|
if '+nccl' in spec:
|
|
|
|
args.extend([
|
|
|
|
'-DLBANN_WITH_NCCL:BOOL=%s' % ('+gpu +nccl' in spec),
|
|
|
|
'-DNCCL_DIR={0}'.format(
|
|
|
|
spec['nccl'].prefix)])
|
|
|
|
|
|
|
|
return args
|
|
|
|
|
2018-01-24 09:05:54 +08:00
|
|
|
@when('@0.91:0.93')
|
2017-02-14 03:57:46 +08:00
|
|
|
def cmake_args(self):
|
|
|
|
spec = self.spec
|
2018-01-24 09:05:54 +08:00
|
|
|
args = self.common_config_args
|
|
|
|
args.extend([
|
2017-02-14 03:57:46 +08:00
|
|
|
'-DWITH_CUDA:BOOL=%s' % ('+gpu' in spec),
|
|
|
|
'-DWITH_CUDNN:BOOL=%s' % ('+gpu' in spec),
|
2017-08-08 02:41:13 +08:00
|
|
|
'-DELEMENTAL_USE_CUBLAS:BOOL=%s' % (
|
|
|
|
'+cublas' in spec['elemental']),
|
2017-02-14 03:57:46 +08:00
|
|
|
'-DWITH_TBINF=OFF',
|
|
|
|
'-DWITH_VTUNE=OFF',
|
2017-08-08 02:41:13 +08:00
|
|
|
'-DElemental_DIR={0}'.format(spec['elemental'].prefix),
|
2017-02-14 03:57:46 +08:00
|
|
|
'-DELEMENTAL_MATH_LIBS={0}'.format(
|
2017-08-08 02:41:13 +08:00
|
|
|
spec['elemental'].libs),
|
|
|
|
'-DSEQ_INIT:BOOL=%s' % ('+seq_init' in spec),
|
2017-02-14 03:57:46 +08:00
|
|
|
'-DVERBOSE=0',
|
2018-01-24 09:05:54 +08:00
|
|
|
'-DLBANN_HOME=.'])
|
2017-02-14 03:57:46 +08:00
|
|
|
|
2018-01-03 10:01:23 +08:00
|
|
|
if spec.variants['dtype'].value == 'float':
|
|
|
|
args.extend(['-DDATATYPE=4'])
|
|
|
|
elif spec.variants['dtype'].value == 'double':
|
|
|
|
args.extend(['-DDATATYPE=8'])
|
|
|
|
|
2017-08-08 02:41:13 +08:00
|
|
|
if '+opencv' in spec:
|
2017-02-14 03:57:46 +08:00
|
|
|
args.extend(['-DOpenCV_DIR:STRING={0}'.format(
|
2017-08-08 02:41:13 +08:00
|
|
|
spec['opencv'].prefix)])
|
2017-02-14 03:57:46 +08:00
|
|
|
|
2017-11-02 08:25:28 +08:00
|
|
|
if '+cudnn' in spec:
|
|
|
|
args.extend(['-DcuDNN_DIR={0}'.format(
|
|
|
|
spec['cudnn'].prefix)])
|
|
|
|
|
2018-01-26 04:10:37 +08:00
|
|
|
if '+cub' in spec:
|
2017-11-02 08:25:28 +08:00
|
|
|
args.extend(['-DCUB_DIR={0}'.format(
|
|
|
|
spec['cub'].prefix)])
|
|
|
|
|
2017-02-14 03:57:46 +08:00
|
|
|
return args
|