From 3f432a8d43c3f4fc218d054020eeac9bd8f7daec Mon Sep 17 00:00:00 2001 From: Bram Wasti Date: Wed, 4 Jan 2017 10:56:15 -0800 Subject: [PATCH] Migrate brewtool stuff into brewtool/ and update makefile to use cmake --- Makefile | 8 +- build.py | 163 --------------------------------------- build_android.py | 45 ----------- build_android_prepare.py | 19 ----- 4 files changed, 4 insertions(+), 231 deletions(-) delete mode 100644 build.py delete mode 100644 build_android.py delete mode 100644 build_android_prepare.py diff --git a/Makefile b/Makefile index 507893c2920..819b73fe7d6 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ # This makefile does nothing but delegating the actual compilation to build.py. all: - @python build.py build + @mkdir -p build && cd build && cmake .. && make android: - @python build_android.py build + @python brewtool/build_android.py build clean: - @python build.py clean + @rm -r build/ test: - @python build.py test + @python brewtool/build.py test lint: @find caffe2 -type f -exec python brewtool/cpplint.py {} \; diff --git a/build.py b/build.py deleted file mode 100644 index 1ba131752a8..00000000000 --- a/build.py +++ /dev/null @@ -1,163 +0,0 @@ -"""Configuration for the Caffe2 installation. -""" - - -class Config(object): - ############################################################################ - # Common settings that are necessary to build Caffe2's core functionality. - ############################################################################ - # If you want to show a lot of the build details, set VERBOSE_BUILD to True. - # This will show the detailed commands being run during the build process. - VERBOSE_BUILD = True - # Specify your compiler. - CC = "c++" - # Specify your archiver. - AR = "ar" - # Specify your output folder. - GENDIR = "gen" - - # Specify if you want to use the system protocol buffer or not. - # If you have protobuf installed, use the following two lines usually - # suffice: - USE_SYSTEM_PROTOBUF = True - PROTOC_BINARY = "protoc" - # Otherwise, use the following line: we will build protobuf using the - # included source file. - #USE_SYSTEM_PROTOBUF = False - #PROTOC_BINARY = 'gen/third_party/protoc' - # Note for the line above: if you are doing things like cross-compilation, - # the built protoc compiler will not work on the host, in which case you - # will need to provide a protoc binary that can run on the host environment. - - # Choose if Caffe2 uses only lite proto or not. Note that this will turn off - # quite a few capabilities in Caffe2's generated protobuf, notably the text - # format support. But, if you are using lite proto already, you don't want - # text format anyway, do you? - USE_LITE_PROTO = False - - # Eigen: Eigen is a third party library that Caffe2 uses for some numerical - # operations. If you have eigen installed in your system, you can simply use - # USE_SYSTEM_EIGEN = True. Otherwise (for example when you are cross - # compiling) you may want to set USE_SYSTEM_EIGEN to False. - USE_SYSTEM_EIGEN = False - - # BLAS backend: which backend to use for blas functions. - # Note that, if the BLAS backend is MKL, we will also assume that the - # MKL VSL library is present, and we will use the VSL function calls as - # well. - # Also note that, if the BLAS backend is eigen, there is actually *no* - # actual blas function calls. We only routed the caffe-specific functions - # to use Eigen. - BLAS_BACKEND = "eigen" - - # google-glog: Caffe can choose to use google glog, which will allow a more - # sophisticated logging scheme. It also comes with a minimal logging tool - # that does not depend on glog. If you wish to use glog, set USE_GLOG to - # True. - USE_GLOG = True - - # gflags: Caffe can choose to use google glog, which will allow a more - # feature complete flags registration mechanism. If you wish to use gflags, - # set USE_GFLAGS to True. - USE_GFLAGS = True - - # Whether to use RTTI or not. Note that this might not always work; to - # disable RTTI means that all your dependencies, most notably protobuf, have - # to be built without RTTI. If you don't know, leave USE_RTTI True. - USE_RTTI = True - - # Whether to use openmp or not. Note that currently, a lot of Caffe2's code - # is not using openmp, but the underlying Eigen library can take advantage - # of that. - USE_OPENMP = True - - # Manually specified defines. - DEFINES = ["-DNDEBUG"] - - # Manually specified include paths. These include paths are searched before - # any auto-generated include paths. - INCLUDES = [] - - # Manually specified lib directories. These are searched before any - # auto-generated library directories. - LIBDIRS = [] - - # Additional cflags you would like to add to the compilation. - CFLAGS = [] - # If you have a nice CPU, you can enable several intrinsics. Make sure you know - # that these are available on your CPU though, otherwise you will get illegal - # instruction errors. - #CFLAGS = ["-mavx", "-mavx2", "-mfma"] - - # Additional link flags you would like to add to the compilation. - LINKFLAGS = [] - - # Additional libraries to link against. This will be appended to each link - # link command. - # ADDITIONAL_LIBS = ['boost_system', 'boost_thread'] - ADDITIONAL_LIBS = [] - - ########################################################################### - # (optional) CUDA. If you do not specify this, the GPU part of Caffe2 will - # not be available. - ############################################################################ - # Specify the cuda directory. - CUDA_DIR = "/usr/local/cuda" - # If you are cross compiling, you may need to add paths where the cuda - # libraries for the target platform can be found. Otherwise, leave it empty. - MANUAL_CUDA_LIB_DIRS = [] - CUDA_GENCODE = [ - 'arch=compute_30,code=sm_30', - 'arch=compute_35,code=sm_35', - 'arch=compute_50,code=sm_50', - 'arch=compute_61,code=sm_61', - ] - # additional CUDA cflags to pass to nvcc. - CUDA_CFLAGS = [] - - # You can choose to add the path of the cuda libraries to the rpath, so that - # during runtime you do not need to hard-code the library paths. You can, - # of course, set this to False. - CUDA_ADD_TO_RPATH = True - # Specify if you want to link cuda as static libraries. - LINK_CUDA_STATIC = True - - ############################################################################ - # (optional) MPI setting. - ############################################################################ - # Specify the MPI c++ compiler. You usually don't need to change this. - MPICC = "mpic++" - MPIRUN = "mpirun" - # Specify ompi_info if you are using openmpi. - OMPI_INFO = 'ompi_info' - # Now, the cuda MPI suport is available after certain versions (such as - # OpenMPI 1.7), but it is possible that the MPI is built without cuda - # support. We will try to figure out if cuda support is available, but - # sometimes you may need to manually request MPI operators to go to - # "fallback" mode: in which case the MPI operations are carried out by CUDA - # memory copy followed by MPI in the CPU space. - FORCE_FALLBACK_CUDA_MPI = False - # Whether to add the MPI library to rpath. - MPI_ADD_TO_RPATH = True - - ################################################################################ - # Very rarely used configurations. - ################################################################################ - # If the platform uses a non-conventional shared library extension, manually - # specify it here. - SHARED_LIB_EXT = '' - # If you would like to pass in any specific environmental variables to the - # build command, do it here. - ENVIRONMENTAL_VARS = {} - # Optimization flags: -O2 in default. The reason we do not include it - # directly in the CFLAGS option is because it will be inserted to both - # c++ and nvcc: some cflags may not be compatible with nvcc so we do not - # want to put all cflags into nvcc. - OPTIMIZATION_FLAGS = ["-O2"] - - -# brew.py -if __name__ == '__main__': - from brewtool.brewery import Brewery - import sys - Brewery.Run(Config, sys.argv) diff --git a/build_android.py b/build_android.py deleted file mode 100644 index 888634d9445..00000000000 --- a/build_android.py +++ /dev/null @@ -1,45 +0,0 @@ -"""Configuration for the Caffe2 installation targeted for Android. - -To run the build, first create a standalone toolchain from the NDK root using: - -./build/tools/make-standalone-toolchain.sh \ - --arch=arm --platform=android-21 \ - --toolchain=arm-linux-androideabi-4.9 \ - --install-dir=./standalone-toolchains/arm-linux-androideabi-4.9-android-21 - -(change the platform and toolchain if necessary) and update the -STANDALONE_TCHAIN_ROOT variable below. -""" - -from build import Config - -STANDALONE_TCHAIN_ROOT = ( - '/opt/android_ndk/android-ndk-r10e/' - 'standalone-toolchains/arm-linux-androideabi-4.9-android-21/') - -# We change necessary components in the Config class. - -Config.VERBOSE_BUILD = True -Config.CC = STANDALONE_TCHAIN_ROOT + 'bin/arm-linux-androideabi-g++' -Config.AR = STANDALONE_TCHAIN_ROOT + 'bin/arm-linux-androideabi-ar' -Config.GENDIR = "gen-android" -Config.USE_SYSTEM_PROTOBUF = False -Config.PROTOC_BINARY = 'gen/third_party/protoc' -Config.USE_LITE_PROTO = False -Config.USE_SYSTEM_EIGEN = False -Config.USE_GLOG = False -Config.USE_GFLAGS = False -Config.USE_RTTI = False -Config.USE_OPENMP = False -Config.CUDA_DIR = "non-existing" -Config.MPICC = "non-existing" -Config.MPIRUN = "non-existing" -Config.OMPI_INFO = "non-existing" -Config.PYTHON_CONFIG = "non-existing" -Config.OPTIMIZATION_FLAGS = ["-O3", "-D__ARM_NEON__", "-mfpu=neon"] - -# brew.py -if __name__ == '__main__': - from brewtool.brewery import Brewery - import sys - Brewery.Run(Config, sys.argv) diff --git a/build_android_prepare.py b/build_android_prepare.py deleted file mode 100644 index b46cc629ce6..00000000000 --- a/build_android_prepare.py +++ /dev/null @@ -1,19 +0,0 @@ -"""Configuration for the Caffe2 installation. -""" - -from build import Config -import sys - -Config.USE_SYSTEM_PROTOBUF = False -Config.PROTOC_BINARY = 'gen/third_party/protoc' -Config.USE_OPENMP = False - -if __name__ == '__main__': - from brewtool.brewery import Brewery - Brewery.Run( - Config, - ['build_android_prepare.py', - 'build', '//third_party:protoc']) -else: - print('This script is not intended to be used as an imported module.') - sys.exit(1)