diff --git a/.gitignore b/.gitignore index 11c5f22..6c2e43f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ obj/ lib/ bin/ build/ +build-dep-src/ +build-dep-install/ python/nexus/proto/ cmake-build*/ diff --git a/.gitmodules b/.gitmodules index d5b1bdb..9d817d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,10 +10,6 @@ # path = frameworks/caffe2 # url = https://github.com/icemelon9/caffe2.git # branch = nexus -[submodule "frameworks/tensorflow"] - path = frameworks/tensorflow - url = https://github.com/tensorflow/tensorflow.git - branch = master [submodule "frameworks/caffe2"] path = frameworks/caffe2 url = https://github.com/abcdabcd987/caffe2-nexus.git diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..4d2c647 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,53 @@ +# Building Nexus on Ubuntu 18.04 + +## Install system-wide packages + +```bash +# Build system and utilities +sudo apt-get install -y unzip build-essential git autoconf automake libtool pkg-config curl make zlib1g-dev wget + +# For OpenCV +sudo apt-get install -y libswscale-dev libjpeg-dev libpng-dev + +# Python 3.7 for Nexus +sudo apt-get install -y software-properties-common +sudo add-apt-repository -y ppa:deadsnakes/ppa +sudo apt-get install -y python3.7 python3.7-dev +curl https://bootstrap.pypa.io/get-pip.py | python3.7 +python3.7 -m pip install --upgrade --user numpy matplotlib protobuf grpcio opencv-python pyyaml six + +# CMake 3.16.3 (install globally) +# ref: https://cmake.org/install/ +# ref: https://stackoverflow.com/questions/44633043/cmake-libcurl-was-built-with-ssl-disabled-https-not-supported +sudo apt-get install -y libcurl4-openssl-dev +wget https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3.tar.gz +tar xf cmake-3.16.3.tar.gz +cd cmake-3.16.3 +./bootstrap --system-curl --parallel=$(nproc) +make -j$(nproc) +sudo make install +cd .. +``` + +## Clone Nexus + +```bash +git clone https://github.com/uwsampl/nexus.git +cd nexus +``` + +## Build Nexus dependencies + +```bash +./build-deps.bash +./build-tensorflow.bash +``` + +## Build Nexus + +```bash +mkdir build +cd build +cmake .. -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DCUDA_PATH=/usr/local/cuda-10.0 -DUSE_TENSORFLOW=ON -DUSE_CAFFE2=OFF +make -j$(nproc) +``` diff --git a/CMakeLists.txt b/CMakeLists.txt index 4523638..847b495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,17 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.12) project(nexus LANGUAGES CXX) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +set(NEXUS_DEP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build-dep-install) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/boost) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/gflags) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/glog) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/grpc) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/gtest) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/opencv) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/protobuf) +list(INSERT CMAKE_PREFIX_PATH 0 ${NEXUS_DEP_DIR}/yaml-cpp) + # We don't support caffe2/caffe/darknet any more #option(USE_GPU "Use GPU" ON ) #option(USE_TENSORFLOW "Use TensorFlow" ON ) @@ -13,7 +23,6 @@ set(USE_TENSORFLOW ON) set(USE_DARKNET OFF) #set(USE_CAFFE2 OFF) set(USE_CAFFE OFF) -option(DEBUG_TF_BUILD "Build TensorFlow in Debug model" OFF) if(USE_CAFFE2 AND USE_CAFFE) message(FATAL_ERROR "`USE_CAFFE2` and `USE_CAFFE` cannot be set at the same time.") endif() @@ -25,6 +34,7 @@ find_package(Protobuf REQUIRED) find_package(gRPC REQUIRED) find_package(glog REQUIRED) find_package(gflags REQUIRED COMPONENTS shared) +find_package(GTest REQUIRED) find_package(yaml-cpp 0.6.2 REQUIRED) find_package(OpenCV REQUIRED) include(ProcessorCount) @@ -84,7 +94,7 @@ target_include_directories(common PUBLIC ${GENERATED_SRC_DIR}/src) target_compile_features(common PUBLIC cxx_std_11) target_link_libraries(common PUBLIC - yaml-cpp gflags glog::glog gRPC::grpc++ protobuf::libprotobuf + yaml-cpp gflags glog::glog gRPC::grpc++ GTest::GTest protobuf::libprotobuf ${OpenCV_LIBS} Boost::filesystem Boost::system) set_target_properties(common PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -117,7 +127,7 @@ add_library(nexus SHARED target_include_directories(nexus PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ${GENERATED_SRC_DIR}/src) -target_compile_features(nexus PRIVATE cxx_std_11) +target_compile_features(nexus PUBLIC cxx_std_11) target_link_libraries(nexus PUBLIC common) @@ -156,61 +166,20 @@ endif() ## backend: TensorFlow support ## if(USE_TENSORFLOW) - target_compile_definitions(backend_obj PUBLIC USE_TENSORFLOW) - target_sources(backend_obj PUBLIC + target_compile_definitions(backend_obj PRIVATE USE_TENSORFLOW) + target_sources(backend_obj PRIVATE src/nexus/backend/tensorflow_model.cpp src/nexus/backend/tf_share_model.cpp) - # set_source_files_properties(src/nexus/backend/tensorflow_model.cpp PROPERTIES COMPILE_OPTIONS -DNDEBUG) - set(TENSORFLOW_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR}/tensorflow/execroot/org_tensorflow/bazel-out) - - # tensorflow/core/lib/core/refcount.h is REALLY REALLY annoying. Need NDEBUG here. - # https://github.com/tensorflow/tensorflow/issues/17316 - if(CMAKE_BUILD_TYPE MATCHES DEBUG) - target_compile_definitions(backend_obj PUBLIC NDEBUG) - endif() - if(DEBUG_TF_BUILD) - set(TENSORFLOW_BUILD_ROOT ${TENSORFLOW_BUILD_ROOT}/k8-dbg) - set(TENSORFLOW_BUILD_OPT --compilation_mode=dbg --strip=never --copt="-DNDEBUG" --copt="-march=x86-64") - else() - set(TENSORFLOW_BUILD_ROOT ${TENSORFLOW_BUILD_ROOT}/k8-opt) - set(TENSORFLOW_BUILD_OPT --config=opt) - endif() - - set(TENSORFLOW_SO - ${TENSORFLOW_BUILD_ROOT}/bin/tensorflow/libtensorflow_cc.so - ${TENSORFLOW_BUILD_ROOT}/bin/tensorflow/libtensorflow_framework.so) - add_custom_command( - OUTPUT ${TENSORFLOW_SO} - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/tensorflow - COMMAND - cp ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/tf_configure.bazelrc - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/tensorflow/.tf_configure.bazelrc - COMMAND - bazel --output_base=${CMAKE_CURRENT_BINARY_DIR}/tensorflow build ${TENSORFLOW_BUILD_OPT} - --action_env CUDA_TOOLKIT_PATH=${CUDA_PATH} - --action_env CUDNN_INSTALL_PATH=${CUDA_PATH} - //tensorflow:libtensorflow_cc.so - //tensorflow:libtensorflow_framework.so - //tensorflow:install_headers - COMMAND - bazel --output_base=${CMAKE_CURRENT_BINARY_DIR}/tensorflow shutdown) - add_custom_target(tensorflow DEPENDS ${TENSORFLOW_SO}) - add_custom_target(clean-tensorflow - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/tensorflow - COMMAND - bazel --output_base=${CMAKE_CURRENT_BINARY_DIR}/tensorflow clean) - target_include_directories(backend_obj PUBLIC ${TENSORFLOW_BUILD_ROOT}/genfiles/tensorflow/include) - target_include_directories(backend_obj PUBLIC ${TENSORFLOW_BUILD_ROOT}/genfiles/tensorflow/include/external/com_google_absl) - target_link_libraries(backend_obj PUBLIC ${TENSORFLOW_SO}) - add_dependencies(backend_obj tensorflow) + set(TENSORFLOW_BUILD_ROOT /host/nexus-deps-src/tensorflow/bazel-out/k8-opt/bin/tensorflow) + target_include_directories(backend_obj PRIVATE ${TENSORFLOW_BUILD_ROOT}/include) + target_link_libraries(backend_obj PRIVATE ${TENSORFLOW_BUILD_ROOT}/libtensorflow_cc.so) + target_link_libraries(backend_obj PRIVATE ${TENSORFLOW_BUILD_ROOT}/libtensorflow_framework.so) endif() ## backend: Caffe2 support ## if(USE_CAFFE2) target_compile_definitions(backend_obj PRIVATE USE_CAFFE2) - target_sources(backend_obj PUBLIC src/nexus/backend/caffe2_model.cpp) + target_sources(backend_obj PRIVATE src/nexus/backend/caffe2_model.cpp) set(CAFFE2_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR}/caffe2) set(CAFFE2_SO ${CAFFE2_BUILD_ROOT}/install/lib/libcaffe2.so @@ -230,15 +199,15 @@ if(USE_CAFFE2) COMMAND make -j${NPROC} install ) add_custom_target(caffe2 DEPENDS ${CAFFE2_SO}) - target_include_directories(backend_obj PUBLIC ${CAFFE2_BUILD_ROOT}/install/include) - target_link_libraries(backend_obj PUBLIC ${CAFFE2_SO}) + target_include_directories(backend_obj PRIVATE ${CAFFE2_BUILD_ROOT}/install/include) + target_link_libraries(backend_obj PRIVATE ${CAFFE2_SO}) add_dependencies(backend_obj caffe2) endif() ## backend: Caffe support ## if(USE_CAFFE) target_compile_definitions(backend PRIVATE USE_CAFFE) - target_sources(backend_obj PUBLIC + target_sources(backend_obj PRIVATE src/nexus/backend/caffe_densecap_model.cpp src/nexus/backend/caffe_model.cpp) set(CAFFE_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/caffe) @@ -249,9 +218,9 @@ if(USE_CAFFE) WORKING_DIRECTORY ${CAFFE_SRC_ROOT} COMMAND make -j${NPROC} all) add_custom_target(caffe DEPENDS ${CAFFE_SO}) - target_include_directories(backend_obj PUBLIC ${CAFFE_SRC_ROOT}/src) - target_include_directories(backend_obj PUBLIC ${CAFFE_SRC_ROOT}/include) - target_link_libraries(backend_obj PUBLIC ${CAFFE_SO}) + target_include_directories(backend_obj PRIVATE ${CAFFE_SRC_ROOT}/src) + target_include_directories(backend_obj PRIVATE ${CAFFE_SRC_ROOT}/include) + target_link_libraries(backend_obj PRIVATE ${CAFFE_SO}) add_dependencies(backend_obj caffe) endif() @@ -266,9 +235,9 @@ if(USE_DARKNET) WORKING_DIRECTORY ${DARKNET_SRC_ROOT} COMMAND make -j${NPROC} all) add_custom_target(darknet DEPENDS ${DARKNET_SO}) - target_include_directories(backend_obj PUBLIC ${DARKNET_SRC_ROOT}/src) - target_include_directories(backend_obj PUBLIC ${DARKNET_SRC_ROOT}/include) - target_link_libraries(backend_obj PUBLIC ${DARKNET_SO}) + target_include_directories(backend_obj PRIVATE ${DARKNET_SRC_ROOT}/src) + target_include_directories(backend_obj PRIVATE ${DARKNET_SRC_ROOT}/include) + target_link_libraries(backend_obj PRIVATE ${DARKNET_SO}) add_dependencies(backend_obj darknet) endif() diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index 5834422..0000000 --- a/INSTALL.md +++ /dev/null @@ -1,189 +0,0 @@ -# INSTALL on Ubuntu 16.04 - -```bash -sudo apt-get install -y unzip build-essential git autoconf automake libtool curl make zlib1g-dev -mkdir -p download -cd download - -# CUDA 10.0 -wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux -chmod +x cuda_10.0.130_410.48_linux -sudo ./cuda_10.0.130_410.48_linux -silent -toolkit -sudo unlink /usr/local/cuda - -# cuDNN v7.5.0 -# ref: https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installlinux-tar -# Sign in and download from https://developer.nvidia.com/rdp/cudnn-download -tar xf cudnn-10.0-linux-x64-v7.5.0.56.tgz -sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include -sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64 -sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn* -sudo ldconfig - -# CMake 3.14.0 -# ref: https://cmake.org/install/ -# ref: https://stackoverflow.com/questions/44633043/cmake-libcurl-was-built-with-ssl-disabled-https-not-supported -sudo apt-get install -y libcurl4-openssl-dev -wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz -tar xf cmake-3.14.0.tar.gz -cd cmake-3.14.0 -./bootstrap --system-curl --parallel=$(nproc) -make -j$(nproc) -sudo make install -cd .. - -# yaml-cpp 0.6.2 -# ref: https://github.com/jbeder/yaml-cpp/tree/yaml-cpp-0.6.2 -wget https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz -tar xf yaml-cpp-0.6.2.tar.gz -cd yaml-cpp-yaml-cpp-0.6.2/ -mkdir build -cd build -cmake .. -DBUILD_SHARED_LIBS=ON -make -j$(nproc) -sudo make install -cd ../.. - -# Boost 1.69.0 -# ref: https://www.boost.org/doc/libs/1_69_0/more/getting_started/unix-variants.html -wget https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz -tar xf boost_1_69_0.tar.gz -cd boost_1_69_0 -./bootstrap.sh -./b2 --without-python --without-mpi --layout=system -j$(nproc) -sudo ./b2 install --without-python --without-mpi --layout=system -j$(nproc) -cd .. - -# OpenCV 4.0.1 -# ref: https://docs.opencv.org/4.0.1/d7/d9f/tutorial_linux_install.html -sudo apt-get install -y libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -wget https://github.com/opencv/opencv/archive/4.0.1.zip -O opencv-4.0.1.zip -unzip opencv-4.0.1.zip -cd opencv-4.0.1 -mkdir build -cd build -cmake .. -DOPENCV_GENERATE_PKGCONFIG=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_JAVA=OFF -DBUILD_WITH_DEBUG_INFO=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -make -j$(nproc) -sudo make install -cd ../.. - -# gflags 2.2.2 -# ref: https://github.com/gflags/gflags/blob/master/INSTALL.md -wget https://github.com/gflags/gflags/archive/v2.2.2.tar.gz -O gflags-2.2.2.tar.gz -tar xf gflags-2.2.2.tar.gz -cd gflags-2.2.2 -mkdir build -cd build -cmake .. -DBUILD_SHARED_LIBS=ON -make -j$(nproc) -sudo make install -cd ../.. - -# glog 0.3.5 -# ref: https://github.com/google/glog/blob/master/cmake/INSTALL.md -wget https://github.com/google/glog/archive/v0.3.5.tar.gz -O glog-0.3.5.tar.gz -tar xf glog-0.3.5.tar.gz -cd glog-0.3.5 -mkdir build -cd build -cmake .. -DBUILD_SHARED_LIBS=ON -make -j$(nproc) -sudo make install -cd ../.. - -# gtest 1.8.1 -# ref: https://github.com/google/googletest/blob/master/googletest/README.md -wget https://github.com/google/googletest/archive/release-1.8.1.tar.gz -O googletest-release-1.8.1.tar.gz -tar xf googletest-release-1.8.1.tar.gz -cd googletest-release-1.8.1 -mkdir build -cd build -cmake .. -DBUILD_SHARED_LIBS=OFF -make -j$(nproc) -sudo make install -cd ../.. - -# protobuf 3.6.1.2 (need to sync with TensorFlow) -# ref: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md -wget https://github.com/protocolbuffers/protobuf/archive/v3.6.1.2.tar.gz -O protobuf-3.6.1.2.tar.gz -tar xf protobuf-3.6.1.2.tar.gz -cd protobuf-3.6.1.2/ -./autogen.sh -./configure -make -j$(nproc) -sudo make install -sudo ldconfig -cd .. - -# grpc 1.19.1 -# ref: https://github.com/grpc/grpc/blob/master/BUILDING.md -git clone -b v1.19.1 https://github.com/grpc/grpc grpc-1.19.1 -cd grpc-1.19.1 -git submodule update --init -make -j$(nproc) -sudo make install -cd .. - -# bazel 0.21.0 -# ref: https://docs.bazel.build/versions/master/install-ubuntu.html -wget https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-installer-linux-x86_64.sh -chmod +x bazel-0.21.0-installer-linux-x86_64.sh -sudo ./bazel-0.21.0-installer-linux-x86_64.sh -bazel version - -# gcc 8.3 -# ref: https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/ -wget https://ftpmirror.gnu.org/gcc/gcc-8.3.0/gcc-8.3.0.tar.gz -tar xf gcc-8.3.0.tar.gz -cd gcc-8.3.0 -contrib/download_prerequisites -cd ../ -mkdir gcc-8.3.0-build -cd gcc-8.3.0-build -../gcc-8.3.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-8.3 -make -j$(nproc) -sudo make install -cd .. -echo "/usr/local/lib64" | sudo tee /etc/ld.so.conf.d/local-lib64.conf -sudo ldconfig - -# python 3.7 by pyenv -sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git -curl https://pyenv.run | bash -echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc -echo 'eval "$(pyenv init -)"' >> ~/.bashrc -echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc -export PATH="$HOME/.pyenv/bin:$PATH" -eval "$(pyenv init -)" -eval "$(pyenv virtualenv-init -)" -pyenv install 3.7.2 -pyenv global 3.7.2 -python --version - -# python packages -python -m pip install pip --upgrade -python -m pip install numpy matplotlib protobuf grpcio opencv-python --upgrade - - -# eigen (for caffe2) -wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz -O eigen-3.3.7.tar.gz -tar xf eigen-3.3.7.tar.gz -cd eigen-eigen-323c052e1731 -mkdir build -cd build -cmake .. -make -j$(nproc) -sudo make install -cd ../.. - -# YAY!!! FINALLY US!!! nexus -cd .. -git clone https://github.com/uwsampl/nexus.git -cd nexus -git submodule update --init --recursive -mkdir build -cd build -cmake .. -DCMAKE_CXX_COMPILER=g++-8.3 -DCMAKE_BUILD_TYPE=Debug -DUSE_GPU=ON -DCUDA_PATH=/usr/local/cuda-10.0 -DUSE_TENSORFLOW=ON -DUSE_CAFFE=OFF -DUSE_CAFFE2=OFF -DUSE_DARKNET=OFF -make -j$(nproc) -``` diff --git a/Makefile b/Makefile deleted file mode 100644 index 15f2b1a..0000000 --- a/Makefile +++ /dev/null @@ -1,235 +0,0 @@ -CONFIG_FILE := Makefile.config -ifeq ($(wildcard $(CONFIG_FILE)),) - $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.) -endif -include $(CONFIG_FILE) - -ROOTDIR = $(CURDIR) - -# protobuf srcs and objs -PROTO_SRC_DIR = src/nexus/proto -PROTO_SRCS := $(PROTO_SRC_DIR)/nnquery.proto -PROTO_GEN_HEADERS := ${PROTO_SRCS:src/%.proto=build/gen/%.pb.h} -PROTO_GEN_CC := ${PROTO_SRCS:src/%.proto=build/gen/%.pb.cc} -PROTO_OBJS := ${PROTO_SRCS:src/nexus/%.proto=build/obj/%.pb.o} -# gen python code -PROTO_GEN_PY_DIR = python/nexus/proto -PROTO_GEN_PY := $(patsubst $(PROTO_SRC_DIR)/%.proto, $(PROTO_GEN_PY_DIR)/%_pb2.py, $(PROTO_SRCS)) -# grpc protobuf -GRPC_PROTO_SRCS := $(PROTO_SRC_DIR)/control.proto -PROTO_GEN_HEADERS += ${GRPC_PROTO_SRCS:src/%.proto=build/gen/%.pb.h} \ - ${GRPC_PROTO_SRCS:src/%.proto=build/gen/%.grpc.pb.h} -PROTO_GEN_CC += ${GRPC_PROTO_SRCS:src/%.proto=build/gen/%.pb.cc} \ - ${GRPC_PROTO_SRCS:src/%.proto=build/gen/%.grpc.pb.cc} -PROTO_OBJS += ${GRPC_PROTO_SRCS:src/nexus/%.proto=build/obj/%.pb.o} \ - ${GRPC_PROTO_SRCS:src/nexus/%.proto=build/obj/%.grpc.pb.o} - -# protoc config -PROTOC = `which protoc` -GRPC_CPP_PLUGIN = grpc_cpp_plugin -GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)` - -# c++ srcs and objs -CXX_COMMON_SRCS := $(wildcard src/nexus/common/*.cpp) -CXX_APP_SRCS := $(wildcard src/nexus/app/*.cpp) -CXX_BACKEND_SRCS := $(wildcard src/nexus/backend/*.cpp) -CXX_SCHEDULER_SRCS := $(wildcard src/nexus/scheduler/*.cpp) -CXX_LIB_SRCS := $(shell find src ! -name "*_main.cpp" -name "*.cpp") -CXX_TEST_SRCS := $(wildcard tests/cpp/*.cpp) $(wildcard tests/cpp/*/*.cpp) -CXX_TOOL_SRCS := $(wildcard tools/*/*.cpp) - -CXX_COMMON_OBJS := $(patsubst src/nexus/%.cpp, build/obj/%.o, $(CXX_COMMON_SRCS)) $(PROTO_OBJS) -CXX_APP_OBJS := $(patsubst src/nexus/%.cpp, build/obj/%.o, $(CXX_APP_SRCS)) -CXX_BACKEND_OBJS := $(patsubst src/nexus/%.cpp, build/obj/%.o, $(CXX_BACKEND_SRCS)) -CXX_SCHEDULER_OBJS := $(patsubst src/nexus/%.cpp, build/obj/%.o, $(CXX_SCHEDULER_SRCS)) -CXX_LIB_OBJS := $(patsubst src/nexus/%.cpp, build/obj/%.o, $(CXX_LIB_SRCS)) $(PROTO_OBJS) -CXX_TEST_OBJS := $(patsubst tests/cpp/%.cpp, build/obj/tests/%.o, $(CXX_TEST_SRCS)) -CXX_TOOL_OBJS := $(patsubst %.cpp, build/obj/%.o, $(CXX_TOOL_SRCS)) -OBJS := $(CXX_COMMON_OBJS) $(CXX_APP_OBJS) $(CXX_BACKEND_OBJS) $(CXX_SCHEDULER_OBJS) \ - $(CXX_TEST_OBJS) $(CXX_TOOL_OBJS) -DEPS := ${OBJS:.o=.d} - -TEST_BIN := build/bin/test - -# c++ configs -CXX = g++ -WARNING = -Wall -Wfatal-errors -Wno-unused -Wno-unused-result -CXXFLAGS = -std=c++11 -O3 -fPIC $(WARNING) -Isrc -Ibuild/gen $(shell pkg-config --cflags protobuf) -# Automatic dependency generation -CXXFLAGS += -MMD -MP -LD_FLAGS = -lm -pthread -lglog -lgflags -lgtest -lgtest_main \ - -lboost_system -lboost_thread -lboost_filesystem -lyaml-cpp \ - $(shell pkg-config --libs protobuf grpc++ grpc opencv) -DLL_LINK_FLAGS = -shared -ifeq ($(USE_GPU), 1) - CXXFLAGS += -I$(CUDA_PATH)/include - LD_FLAGS += -L$(CUDA_PATH)/lib64 -lcuda -lcudart -lcurand -endif - -# library dependency -DARKNET_ROOT_DIR = $(ROOTDIR)/frameworks/darknet -DARKNET_BUILD_DIR = $(DARKNET_ROOT_DIR) -CAFFE_ROOT_DIR = $(ROOTDIR)/frameworks/caffe -CAFFE_BUILD_DIR = $(CAFFE_ROOT_DIR)/build -CAFFE2_ROOT_DIR = $(ROOTDIR)/frameworks/caffe2 -CAFFE2_BUILD_DIR = $(CAFFE2_ROOT_DIR)/build -CAFFE2_INSTALL_DIR = $(CAFFE2_ROOT_DIR)/install -TENSORFLOW_ROOT_DIR = $(ROOTDIR)/frameworks/tensorflow -TENSORFLOW_BUILD_DIR = $(ROOTDIR)/build/tensorflow/execroot/org_tensorflow/bazel-out/k8-opt - -BACKEND_DEPS = -BACKEND_CXXFLAGS = -BACKEND_LD_FLAGS = - -ifeq ($(USE_CAFFE2), 1) - BACKEND_DEPS += caffe2 - BACKEND_CXXFLAGS += -DUSE_CAFFE2 -I$(CAFFE2_INSTALL_DIR)/include - BACKEND_LD_FLAGS += -L$(CAFFE2_INSTALL_DIR)/lib -lcaffe2 -lcaffe2_gpu -Wl,-rpath,$(CAFFE2_INSTALL_DIR)/lib - USE_CAFFE = 0 -endif -ifeq ($(USE_CAFFE), 1) - BACKEND_DEPS += caffe - BACKEND_CXXFLAGS += -DUSE_CAFFE -I$(CAFFE_ROOT_DIR)/include -I$(CAFFE_BUILD_DIR)/src - BACKEND_LD_FLAGS += -L$(CAFFE_BUILD_DIR)/lib -lcaffe -Wl,-rpath,$(CAFFE_BUILD_DIR)/lib -endif -ifeq ($(USE_DARKNET), 1) - BACKEND_DEPS += darknet - BACKEND_CXXFLAGS += -DUSE_DARKNET -I$(DARKNET_ROOT_DIR)/src -I$(DARKNET_ROOT_DIR)/include - BACKEND_LD_FLAGS += -L$(DARKNET_BUILD_DIR) -ldarknet -Wl,-rpath,$(DARKNET_BUILD_DIR) -endif -ifeq ($(USE_TENSORFLOW), 1) - # BACKEND_DEPS += tensorflow - BACKEND_CXXFLAGS += -DUSE_TENSORFLOW - BACKEND_CXXFLAGS += -I$(TENSORFLOW_BUILD_DIR)/genfiles/tensorflow/include - BACKEND_CXXFLAGS += -I$(TENSORFLOW_BUILD_DIR)/genfiles/tensorflow/include/external/com_google_absl - BACKEND_LD_FLAGS += -L$(TENSORFLOW_BUILD_DIR)/bin/tensorflow -ltensorflow -ltensorflow_cc -ltensorflow_framework - BACKEND_LD_FLAGS += -Wl,-rpath,$(TENSORFLOW_BUILD_DIR)/bin/tensorflow -endif - -all: proto python lib backend scheduler tools - -caffe: $(CAFFE_BUILD_DIR)/lib/libcaffe.so -caffe2: $(CAFFE2_INSTALL_DIR)/lib/libcaffe2_gpu.so -darknet: $(DARKNET_BUILD_DIR)/libdarknet.so -# tensorflow: $(TENSORFLOW_BUILD_DIR)/lib/tensorflow/libtensorflow_cc.so -tensorflow: ; - -$(CAFFE_BUILD_DIR)/lib/libcaffe.so: - cd $(CAFFE_ROOT_DIR) && $(MAKE) proto && $(MAKE) all && $(MAKE) pycaffe && cd - - -$(CAFFE2_INSTALL_DIR)/lib/libcaffe2_gpu.so: - @mkdir -p $(CAFFE2_BUILD_DIR) - @cd $(CAFFE2_BUILD_DIR) && \ - cmake .. -DUSE_NNPACK=OFF -DUSE_NCCL=OFF -DCMAKE_INSTALL_PREFIX=../install \ - && $(MAKE) && $(MAKE) install - -$(DARKNET_BUILD_DIR)/libdarknet.so: - cd $(DARKNET_ROOT_DIR) && $(MAKE) all && cd - - -# $(TENSORFLOW_BUILD_DIR)/lib/tensorflow/libtensorflow_cc.so: -# @mkdir -p $(TENSORFLOW_BUILD_DIR) -# cd $(TENSORFLOW_BUILD_DIR) && cmake -DCMAKE_INSTALL_PREFIX=. .. && make -# @if [ -e $(TENSORFLOW_ROOT_DIR)/bazel-bin/tensorflow/libtensorflow_cc.so ]; then \ -# cd $(TENSORFLOW_BUILD_DIR) && make install; \ -# else \ -# echo "Build Tensorflow failed"; exit 0; \ -# fi - -proto: $(PROTO_GEN_CC) - -python: $(PROTO_GEN_PY) - -lib: build/lib/libnexus.so - -backend: build/bin/backend - -scheduler: build/bin/scheduler - -tools: build/bin/profiler build/bin/test_pb - -test: build/bin/runtest - -runtest: test - @build/bin/runtest -model_root $(ROOTDIR)/tests/data/model_db - -build/lib/libnexus.so: $(CXX_COMMON_OBJS) $(CXX_APP_OBJS) - @mkdir -p $(@D) - $(CXX) $(DLL_LINK_FLAGS) -o $@ $^ $(LD_FLAGS) - -build/bin/backend: $(CXX_COMMON_OBJS) $(CXX_BACKEND_OBJS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LD_FLAGS) $(BACKEND_LD_FLAGS) - -build/bin/scheduler: $(CXX_COMMON_OBJS) $(CXX_SCHEDULER_OBJS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LD_FLAGS) - -build/bin/profiler: $(CXX_LIB_OBJS) build/obj/tools/profiler/profiler.o - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LD_FLAGS) $(BACKEND_LD_FLAGS) - -build/bin/test_pb: $(CXX_LIB_OBJS) build/obj/tools/profiler/test_pb.o - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LD_FLAGS) $(BACKEND_LD_FLAGS) - -build/bin/runtest: $(CXX_TEST_OBJS) $(CXX_LIB_OBJS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -o $@ $^ $(LD_FLAGS) $(BACKEND_LD_FLAGS) - -build/gen/%.pb.cc build/gen/%.pb.h: src/%.proto - @mkdir -p $(@D) - $(PROTOC) -I$(PROTO_SRC_DIR) --cpp_out=$(@D) $< - -build/gen/%.grpc.pb.cc build/gen/%.grpc.pb.h: src/%.proto | build/gen/%.pb.h - @mkdir -p $(@D) - $(PROTOC) -I$(PROTO_SRC_DIR) --grpc_out=$(@D) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $< - -$(PROTO_GEN_PY_DIR)/%_pb2.py: $(PROTO_SRC_DIR)/%.proto - @mkdir -p $(@D) - touch $(@D)/__init__.py - $(PROTOC) --proto_path=$(PROTO_SRC_DIR) --python_out=$(@D) $< - -build/obj/%.pb.o: build/gen/nexus/%.pb.cc build/gen/nexus/%.pb.h - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -c $< -o $@ - -build/obj/backend/%.o: src/nexus/backend/%.cpp | $(PROTO_GEN_HEADERS) $(BACKEND_DEPS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(BACKEND_CXXFLAGS) -c $< -o $@ - -build/obj/%.o: src/nexus/%.cpp | $(PROTO_GEN_HEADERS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -c $< -o $@ - -build/obj/tools/%.o: tools/%.cpp | $(PROTO_GEN_HEADERS) - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(BACKEND_CXXFLAGS) -c $< -o $@ - -build/obj/tests/%.o: tests/cpp/%.cpp - @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) $(BACKEND_CXXFLAGS) -c $< -o $@ - -.PRECIOUS: $(PROTO_GEN_HEADERS) $(PROTO_GEN_CC) - -.PHONY: proto python lib backend scheduler tools test runtest \ - darknet caffe tensorflow \ - clean clean-darknet clean-caffe clean-caffe2 clean-tensorflow cleanall - -clean: - rm -rf build/gen build/lib build/obj $(PROTO_GEN_PY_DIR) $(PROTO_GEN_CC) $(PROTO_GEN_HEADERS) - -clean-darknet: - cd $(DARKNET_ROOT_DIR) && $(MAKE) clean && cd - - -clean-caffe: - cd $(CAFFE_ROOT_DIR) && $(MAKE) clean && cd - - -clean-caffe2: - rm -rf $(CAFFE2_BUILD_DIR) $(CAFFE2_INSTALL_DIR) - -clean-tensorflow: - rm -rf $(TENSORFLOW_BUILD_DIR) $(TENSORFLOW_ROOT_DIR)/.tf_configure.bazelrc $(TENSORFLOW_ROOT_DIR)/bazel-* - -cleanall: clean clean-darknet clean-caffe clean-caffe2 clean-tensorflow - --include $(DEPS) diff --git a/Makefile.config b/Makefile.config deleted file mode 100644 index c651495..0000000 --- a/Makefile.config +++ /dev/null @@ -1,9 +0,0 @@ -USE_DARKNET := 1 -# USE_CAFFE and USE_CAFFE2 cannot be set to 1 at the same time -USE_CAFFE2 := 1 -USE_CAFFE := 0 -USE_TENSORFLOW := 1 -USE_GPU := 1 - -CUDA_PATH ?= /usr/local/cuda -CUDNN_PATH ?= /usr/local/cuda diff --git a/README.md b/README.md index 9e1f4e5..9da9ebe 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ Nexus ===== + Nexus is a scalable and efficient serving system for DNN applications on GPU cluster. -## Installation +## Building Nexus -See [INSTALL.md](INSTALL.md) for details. +See [BUILDING.md](BUILDING.md) for details. ## SOSP 2019 Paper diff --git a/build-deps.bash b/build-deps.bash new file mode 100755 index 0000000..ddaec75 --- /dev/null +++ b/build-deps.bash @@ -0,0 +1,139 @@ +#!/bin/bash +set -e +set -x + +SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" +SRC_DIR="$SCRIPT_DIR/build-dep-src" +INSTALL_DIR="$SCRIPT_DIR/build-dep-install" + +mkdir -p "$SRC_DIR" +mkdir -p "$INSTALL_DIR" + +cd "$SRC_DIR" + + +###### yaml-cpp 0.6.3 ###### +# ref: https://github.com/jbeder/yaml-cpp/tree/yaml-cpp-0.6.3 +if [ ! -d "$INSTALL_DIR/yaml-cpp" ]; then + wget -N https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.3.tar.gz -O yaml-cpp-0.6.3.tar.gz + tar xf yaml-cpp-0.6.3.tar.gz + cd yaml-cpp-yaml-cpp-0.6.3/ + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/yaml-cpp" -DYAML_BUILD_SHARED_LIBS=ON + make -j$(nproc) + make install + cd ../.. +fi + + +###### Boost 1.72.0 ###### +# ref: https://www.boost.org/doc/libs/1_72_0/more/getting_started/unix-variants.html +if [ ! -d "$INSTALL_DIR/boost" ]; then + wget -N https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz -O boost_1_72_0.tar.gz + tar xf boost_1_72_0.tar.gz + cd boost_1_72_0 + ./bootstrap.sh --prefix="$INSTALL_DIR/boost" + ./b2 install --prefix="$INSTALL_DIR/boost" --without-python --without-mpi --layout=system -j$(nproc) + cd .. +fi + + +###### OpenCV 4.2.0 ###### +# ref: https://docs.opencv.org/4.2.0/d7/d9f/tutorial_linux_install.html +if [ ! -d "$INSTALL_DIR/opencv" ]; then + wget -N https://github.com/opencv/opencv/archive/4.2.0.zip -O opencv-4.2.0.zip + unzip opencv-4.2.0.zip + cd opencv-4.2.0 + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/opencv" -DOPENCV_GENERATE_PKGCONFIG=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_JAVA=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_QT=OFF -DWITH_GTK=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF -DBUILD_LIST=core,imgcodecs,imgproc + make -j$(nproc) + make install + cd ../.. +fi + + +###### gflags 2.2.2 ###### +# ref: https://github.com/gflags/gflags/blob/master/INSTALL.md +if [ ! -d "$INSTALL_DIR/gflags" ]; then + wget -N https://github.com/gflags/gflags/archive/v2.2.2.tar.gz -O gflags-2.2.2.tar.gz + tar xf gflags-2.2.2.tar.gz + cd gflags-2.2.2 + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/gflags" -DBUILD_SHARED_LIBS=ON + make -j$(nproc) + make install + cd ../.. +fi + + +###### glog 0.4.0 ###### +# ref: https://github.com/google/glog/blob/master/cmake/INSTALL.md +if [ ! -d "$INSTALL_DIR/glog" ]; then + wget -N https://github.com/google/glog/archive/v0.4.0.tar.gz -O glog-0.4.0.tar.gz + tar xf glog-0.4.0.tar.gz + cd glog-0.4.0 + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/glog" -DBUILD_SHARED_LIBS=ON + make -j$(nproc) + make install + cd ../.. +fi + + +###### gtest 1.10.0 ###### +# ref: https://github.com/google/googletest/blob/master/googletest/README.md +if [ ! -d "$INSTALL_DIR/gtest" ]; then + wget -N https://github.com/google/googletest/archive/release-1.10.0.tar.gz -O googletest-release-1.10.0.tar.gz + tar xf googletest-release-1.10.0.tar.gz + cd googletest-release-1.10.0 + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR/gtest" -DBUILD_SHARED_LIBS=OFF + make -j$(nproc) + make install + cd ../.. +fi + +###### protobuf 3.8.0 (need to sync with TensorFlow) ###### +# TensorFlow dependency: https://github.com/tensorflow/tensorflow/blob/906f537c0be010929a0bda3c7d061de9d3d8d5b0/tensorflow/workspace.bzl#L472 +# ref: https://github.com/protocolbuffers/protobuf/blob/master/src/README.md +if [ ! -d "$INSTALL_DIR/protobuf" ]; then + wget -N https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz -O protobuf-3.8.0.tar.gz + tar xf protobuf-3.8.0.tar.gz + cd protobuf-3.8.0/ + ./autogen.sh + ./configure --prefix="$INSTALL_DIR/protobuf" + make -j$(nproc) + make install + cd .. +fi + +###### grpc 1.27.0 ###### +# ref: https://github.com/grpc/grpc/blob/master/BUILDING.md +if [ ! -d "$INSTALL_DIR/grpc" ]; then + if [ ! -d grpc-1.27 ]; then + git clone -b v1.27.0 --depth 1 https://github.com/grpc/grpc grpc-1.27 + cd grpc-1.27 + git submodule update --init + else + cd grpc-1.27 + fi + make -j$(nproc) + make install --prefix="$INSTALL_DIR/grpc" + cd .. +fi + +###### bazel 1.2.1 ###### +if [ ! -d "$INSTALL_DIR/bazel" ]; then + wget -N https://github.com/bazelbuild/bazel/releases/download/1.2.1/bazel-1.2.1-linux-x86_64 -O bazel-1.2.1-linux-x86_64 + chmod +x bazel-1.2.1-linux-x86_64 + mkdir -p "$INSTALL_DIR/bazel" + mv bazel-1.2.1-linux-x86_64 "$INSTALL_DIR/bazel/" + ln -sf bazel-1.2.1-linux-x86_64 "$INSTALL_DIR/bazel/bazel" +fi + +exit 0 diff --git a/build-tensorflow.bash b/build-tensorflow.bash new file mode 100755 index 0000000..eaeba61 --- /dev/null +++ b/build-tensorflow.bash @@ -0,0 +1,167 @@ +#!/bin/bash +set -e +set -x + +SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" +SRC_DIR="$SCRIPT_DIR/build-dep-src" +INSTALL_DIR="$SCRIPT_DIR/build-dep-install" + +mkdir -p "$SRC_DIR" +mkdir -p "$INSTALL_DIR" + +cd "$SRC_DIR" + +if [ ! -d "$INSTALL_DIR/tensorflow" ]; then + # TensorFlow 2.0 master + git clone https://github.com/tensorflow/tensorflow.git +fi +cd tensorflow +git checkout 906f537c0be010929a0bda3c7d061de9d3d8d5b0 + +# Tensorflow build config +export PYTHON_BIN_PATH=/usr/bin/python3 +export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')" +export TF_ENABLE_XLA=0 +export TF_NEED_OPENCL_SYCL=0 +export TF_NEED_ROCM=0 +export TF_NEED_CUDA=1 +export TF_NEED_TENSORRT=0 +export TF_CUDA_COMPUTE_CAPABILITIES=3.5,3.7,5.2,6.0,6.1,7.0,7.5 +export TF_CUDA_PATHS=/usr/local/cuda-10.0,/usr +export TF_CUDA_CLANG=0 +export GCC_HOST_COMPILER_PATH=/usr/bin/gcc +export TF_NEED_MPI=0 +export TF_SET_ANDROID_WORKSPACE=0 +export CC_OPT_FLAGS="-march=native -Wno-sign-compare" +export PATH="$PATH:$INSTALL_DIR/bazel" +./configure + +# Fix grpc (https://github.com/tensorflow/tensorflow/issues/33758#issuecomment-547867642) +git checkout -- tensorflow/workspace.bzl +rm -f third_party/grpc/backport-pr-18950.patch +git apply << EOM +From 73640aaec2ab0234d9fff138e3c9833695570c0a Mon Sep 17 00:00:00 2001 +From: Hiroshi Ogawa +Date: Wed, 30 Oct 2019 15:06:40 +0900 +Subject: [PATCH] Backport grpc PR 18950 + +--- + tensorflow/workspace.bzl | 1 + + third_party/grpc/backport-pr-18950.patch | 66 ++++++++++++++++++++++++ + 2 files changed, 67 insertions(+) + create mode 100644 third_party/grpc/backport-pr-18950.patch + +diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl +index d361130b358c3..5c120709bc652 100755 +--- a/tensorflow/workspace.bzl ++++ b/tensorflow/workspace.bzl +@@ -517,6 +517,7 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): + sha256 = "67a6c26db56f345f7cee846e681db2c23f919eba46dd639b09462d1b6203d28c", + strip_prefix = "grpc-4566c2a29ebec0835643b972eb99f4306c4234a3", + system_build_file = clean_dep("//third_party/systemlibs:grpc.BUILD"), ++ patch_file = clean_dep("//third_party/grpc:backport-pr-18950.patch"), + urls = [ + "https://storage.googleapis.com/mirror.tensorflow.org/github.com/grpc/grpc/archive/4566c2a29ebec0835643b972eb99f4306c4234a3.tar.gz", + "https://github.com/grpc/grpc/archive/4566c2a29ebec0835643b972eb99f4306c4234a3.tar.gz", +diff --git a/third_party/grpc/backport-pr-18950.patch b/third_party/grpc/backport-pr-18950.patch +new file mode 100644 +index 0000000000000..55290dfb40567 +--- /dev/null ++++ b/third_party/grpc/backport-pr-18950.patch +@@ -0,0 +1,66 @@ ++diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc ++index 561276f0c2..8b597b4cf2 100644 ++--- a/src/core/lib/gpr/log_linux.cc +++++ b/src/core/lib/gpr/log_linux.cc ++@@ -40,7 +40,7 @@ ++ #include ++ #include ++ ++-static long gettid(void) { return syscall(__NR_gettid); } +++static long sys_gettid(void) { return syscall(__NR_gettid); } ++ ++ void gpr_log(const char* file, int line, gpr_log_severity severity, ++ const char* format, ...) { ++@@ -70,7 +70,7 @@ void gpr_default_log(gpr_log_func_args* args) { ++ gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); ++ struct tm tm; ++ static __thread long tid = 0; ++- if (tid == 0) tid = gettid(); +++ if (tid == 0) tid = sys_gettid(); ++ ++ timer = static_cast(now.tv_sec); ++ final_slash = strrchr(args->file, '/'); ++diff --git a/src/core/lib/gpr/log_posix.cc b/src/core/lib/gpr/log_posix.cc ++index b6edc14ab6..2f7c6ce376 100644 ++--- a/src/core/lib/gpr/log_posix.cc +++++ b/src/core/lib/gpr/log_posix.cc ++@@ -31,7 +31,7 @@ ++ #include ++ #include ++ ++-static intptr_t gettid(void) { return (intptr_t)pthread_self(); } +++static intptr_t sys_gettid(void) { return (intptr_t)pthread_self(); } ++ ++ void gpr_log(const char* file, int line, gpr_log_severity severity, ++ const char* format, ...) { ++@@ -86,7 +86,7 @@ void gpr_default_log(gpr_log_func_args* args) { ++ char* prefix; ++ gpr_asprintf(&prefix, "%s%s.%09d %7" PRIdPTR " %s:%d]", ++ gpr_log_severity_string(args->severity), time_buffer, ++- (int)(now.tv_nsec), gettid(), display_file, args->line); +++ (int)(now.tv_nsec), sys_gettid(), display_file, args->line); ++ ++ fprintf(stderr, "%-70s %s\n", prefix, args->message); ++ gpr_free(prefix); ++diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc ++index b6d13b44d1..e1cda21b3e 100644 ++--- a/src/core/lib/iomgr/ev_epollex_linux.cc +++++ b/src/core/lib/iomgr/ev_epollex_linux.cc ++@@ -1103,7 +1103,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker, ++ } ++ ++ #ifndef NDEBUG ++-static long gettid(void) { return syscall(__NR_gettid); } +++static long sys_gettid(void) { return syscall(__NR_gettid); } ++ #endif ++ ++ /* pollset->mu lock must be held by the caller before calling this. ++@@ -1123,7 +1123,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset, ++ #define WORKER_PTR (&worker) ++ #endif ++ #ifndef NDEBUG ++- WORKER_PTR->originator = gettid(); +++ WORKER_PTR->originator = sys_gettid(); ++ #endif ++ if (grpc_polling_trace.enabled()) { ++ gpr_log(GPR_INFO, +EOM + +# Fix install_headers (https://github.com/tensorflow/tensorflow/pull/36013) +git checkout -- tensorflow/core/BUILD +git apply << EOM +diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD +index 422df45c79..d2dac95add 100644 +--- a/tensorflow/core/BUILD ++++ b/tensorflow/core/BUILD +@@ -4481,7 +4481,7 @@ transitive_hdrs( + name = "headers", + visibility = ["//tensorflow:__subpackages__"], + deps = [ +- ":core_cpu", ++ ":core", + ":framework", + ":lib", + ":protos_all_cc", +EOM + +# Build +bazel build --config=opt --config=noaws --config=nogcp --config=nohdfs --config=nonccl \ + --noincompatible_do_not_split_linking_cmdline \ + //tensorflow:libtensorflow_cc.so \ + //tensorflow:libtensorflow_framework.so \ + //tensorflow:install_headers + +# Copy files +rm -rf "$INSTALL_DIR/tensorflow" +cp -av bazel-out/k8-opt/bin/tensorflow "$INSTALL_DIR/tensorflow" diff --git a/frameworks/tensorflow b/frameworks/tensorflow deleted file mode 160000 index 42c4f4a..0000000 --- a/frameworks/tensorflow +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 42c4f4ab6b53bce8639c203d7839d27eac11bd2f diff --git a/frameworks/tf_configure.bazelrc b/frameworks/tf_configure.bazelrc deleted file mode 100644 index 7b74b8e..0000000 --- a/frameworks/tf_configure.bazelrc +++ /dev/null @@ -1,17 +0,0 @@ -build:xla --define with_xla_support=false -build --action_env TF_NEED_OPENCL_SYCL="0" -build --action_env TF_NEED_ROCM="0" -build --action_env TF_NEED_CUDA="1" -build --action_env TF_CUDA_VERSION="10.0" -build --action_env TF_CUDNN_VERSION="7" -build --action_env TF_NCCL_VERSION="" -build --action_env TF_CUDA_COMPUTE_CAPABILITIES="6.1" -build --action_env TF_CUDA_CLANG="0" -build --action_env GCC_HOST_COMPILER_PATH="/usr/bin/gcc" -build --config=cuda -test --config=cuda -build:opt --copt=-march=native -build:opt --copt=-Wno-sign-compare -build:opt --host_copt=-march=native -build:opt --define with_default_optimizations=true -build:v2 --define=tf_api_version=2