Skip to content

Commit

Permalink
Merge pull request #586 from drnikolaev/caffe-0.17
Browse files Browse the repository at this point in the history
0.17.4
CUDNN 8, CUDA 11, UBUNTU 20.04 etc.
  • Loading branch information
drnikolaev authored Jan 9, 2021
2 parents 4867dc2 + 4c7481c commit c1e3b78
Show file tree
Hide file tree
Showing 42 changed files with 370 additions and 312 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: trusty
dist: bionic
sudo: required

language: cpp
Expand All @@ -14,14 +14,14 @@ env:
# WITH_PYTHON3: false
# WITH_CUDA: const true since v0.17
# WITH_CUDNN: false
- BUILD_NAME="default-make"
# - BUILD_NAME="python3-make" WITH_PYTHON3=true
- BUILD_NAME="cudnn-make" WITH_CUDNN=true
# - BUILD_NAME="default-make"
- BUILD_NAME="python3-make" WITH_PYTHON3=true
- BUILD_NAME="python3-cudnn-make" WITH_PYTHON3=true WITH_CUDNN=true

- BUILD_NAME="default-cmake" WITH_CMAKE=true
# - BUILD_NAME="default-cmake" WITH_CMAKE=true
- BUILD_NAME="python3-cmake" WITH_CMAKE=true WITH_PYTHON3=true
- BUILD_NAME="cudnn-cmake" WITH_CMAKE=true WITH_CUDNN=true
- BUILD_NAME="cudnn-python3-cmake" WITH_CMAKE=true WITH_CUDNN=true WITH_PYTHON3=true
# - BUILD_NAME="cudnn-cmake" WITH_CMAKE=true WITH_CUDNN=true
- BUILD_NAME="python3-cudnn-cmake" WITH_CMAKE=true WITH_CUDNN=true WITH_PYTHON3=true

cache:
apt: true
Expand Down
23 changes: 12 additions & 11 deletions 3rdparty/half_float/half.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ namespace half_float
struct binary_t {};

/// Tag for binary construction.
HALF_CONSTEXPR_CONST binary_t binary = binary_t();
static HALF_CONSTEXPR_CONST binary_t binary = binary_t();

/// Temporary half-precision expression.
/// This class represents a half-precision expression which just stores a single-precision value internally.
Expand Down Expand Up @@ -1172,7 +1172,8 @@ namespace half_float
/// Constructor.
/// \param bits binary representation to set half to
CAFFE_UTIL_HD
HALF_CONSTEXPR half(detail::binary_t, detail::uint16 bits) : data_(bits) {}
HALF_CONSTEXPR half(detail::binary_t, unsigned int bits) HALF_NOEXCEPT
: data_(static_cast<detail::uint16>(bits)) {}

/// Internal binary representation
detail::uint16 data_;
Expand Down Expand Up @@ -3067,32 +3068,32 @@ namespace std
static HALF_CONSTEXPR_CONST int max_exponent10 = 4;

/// Smallest positive normal value.
static HALF_CONSTEXPR half_float::half min() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x0400); }
static HALF_CONSTEXPR half_float::half min() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x0400}; }

/// Smallest finite value.
static HALF_CONSTEXPR half_float::half lowest() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0xFBFF); }
static HALF_CONSTEXPR half_float::half lowest() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0xFBFF}; }

/// Largest finite value.
static HALF_CONSTEXPR half_float::half max() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x7BFF); }
static HALF_CONSTEXPR half_float::half max() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x7BFF}; }

/// Difference between one and next representable value.
static HALF_CONSTEXPR half_float::half epsilon() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x1400); }
static HALF_CONSTEXPR half_float::half epsilon() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x1400}; }

/// Maximum rounding error.
static HALF_CONSTEXPR half_float::half round_error() HALF_NOTHROW
{ return half_float::half(half_float::detail::binary, (round_style==std::round_to_nearest) ? 0x3800 : 0x3C00); }
{ return half_float::half{half_float::detail::binary, (round_style==std::round_to_nearest) ? 0x3800 : 0x3C00}; }

/// Positive infinity.
static HALF_CONSTEXPR half_float::half infinity() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x7C00); }
static HALF_CONSTEXPR half_float::half infinity() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x7C00}; }

/// Quiet NaN.
static HALF_CONSTEXPR half_float::half quiet_NaN() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x7FFF); }
static HALF_CONSTEXPR half_float::half quiet_NaN() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x7FFF}; }

/// Signalling NaN.
static HALF_CONSTEXPR half_float::half signaling_NaN() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x7DFF); }
static HALF_CONSTEXPR half_float::half signaling_NaN() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x7DFF}; }

/// Smallest positive subnormal value.
static HALF_CONSTEXPR half_float::half denorm_min() HALF_NOTHROW { return half_float::half(half_float::detail::binary, 0x0001); }
static HALF_CONSTEXPR half_float::half denorm_min() HALF_NOTHROW { return half_float::half{half_float::detail::binary, 0x0001}; }
};


Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif()

caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)
caffe_option(BUILD_python "Build Python wrapper" ON)
set(python_version "2" CACHE STRING "Specify which Python version to use")
set(python_version "3" CACHE STRING "Specify which Python version to use")
caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)
caffe_option(BUILD_docs "Build documentation" ON IF UNIX OR APPLE)
caffe_option(BUILD_python_layer "Build the Caffe Python layer" ON)
Expand All @@ -73,7 +73,7 @@ include(cmake/Dependencies.cmake)

# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++14")
endif()

caffe_set_caffe_link()
Expand Down Expand Up @@ -114,7 +114,7 @@ add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/l
# ---[ pytest target
if(BUILD_python)
add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )
add_dependencies(pytest pycaffe)
# add_dependencies(pytest pycaffe)
endif()

# ---[ Configuration summary
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ endif
THIRDPARTY_DIR := ./3rdparty

# All of the directories containing code.
SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
SRC_DIRS := $(shell find src python tools examples -type d -exec bash -c "find {} -maxdepth 1 \
\( -name '*.cpp' -o -name '*.proto' \) | grep -q ." \; -print 2>/dev/null)


# The target shared library name
LIBRARY_NAME := $(PROJECT)$(LIBRARY_NAME_SUFFIX)
LIB_BUILD_DIR := $(BUILD_DIR)/lib
STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
DYNAMIC_VERSION_MAJOR := 0
DYNAMIC_VERSION_MINOR := 17
DYNAMIC_VERSION_REVISION := 3
DYNAMIC_VERSION_REVISION := 4
DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR)
DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_SONAME_SHORT).$(DYNAMIC_VERSION_REVISION)
DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
# NVCaffe requires C++ 11
COMMON_FLAGS += -std=c++11
# NVCaffe requires C++ 14
COMMON_FLAGS += -std=c++14
COMMON_FLAGS += -DCUDA_NO_HALF


##############################
# Get all source files
##############################
Expand Down Expand Up @@ -179,7 +181,7 @@ CUDA_LIB_DIR :=
# add <cuda>/lib64 only if it exists
ifneq ("$(wildcard $(CUDA_DIR)/lib64)","")
CUDA_LIB_DIR += $(CUDA_DIR)/lib64
CUDA_LIB_DIR += /usr/lib/nvidia-410 /usr/lib/nvidia-418 /usr/lib/nvidia-396 /usr/lib/nvidia-390 /usr/lib/nvidia-387 /usr/lib/nvidia-384 /usr/lib/nvidia-381 /usr/lib/nvidia-375 /usr/lib/nvidia-367 /usr/lib/nvidia-361 /usr/lib/nvidia-352
CUDA_LIB_DIR += /usr/lib/nvidia-440 /usr/lib/nvidia-410 /usr/lib/nvidia-418 /usr/lib/nvidia-396 /usr/lib/nvidia-390 /usr/lib/nvidia-387 /usr/lib/nvidia-384 /usr/lib/nvidia-381 /usr/lib/nvidia-375 /usr/lib/nvidia-367 /usr/lib/nvidia-361 /usr/lib/nvidia-352
endif
CUDA_LIB_DIR += $(CUDA_DIR)/lib

Expand Down
12 changes: 6 additions & 6 deletions Makefile.config.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ BLAS_LIB := /opt/OpenBLAS/lib/

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include
#PYTHON_INCLUDE := /usr/include/python2.7 \
# /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
Expand All @@ -69,9 +69,9 @@ PYTHON_INCLUDE := /usr/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# Uncomment to use Python 3 (default is Python 2)
# PYTHON_LIBRARIES := boost_python3 python3.5m
# PYTHON_INCLUDE := /usr/include/python3.5m \
# /usr/lib/python3.5/dist-packages/numpy/core/include
PYTHON_LIBRARIES := boost_python38 python3.8
PYTHON_INCLUDE := /usr/include/python3.8 \
/usr/lib/python3.8/dist-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib
Expand All @@ -82,7 +82,7 @@ PYTHON_LIB := /usr/lib
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1
WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ to your PR.

Libturbojpeg library is used since 0.16.5. It has a packaging bug. Please execute the following (required for Makefile, optional for CMake):
```
sudo apt-get install libturbojpeg
sudo apt-get install libturbojpeg libturbojpeg0-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
```
2 changes: 1 addition & 1 deletion cmake/Cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ if(USE_CUDNN)
endif()

if(UNIX OR APPLE)
list(APPEND CUDA_NVCC_FLAGS -std=c++11;-Xcompiler;-fPIC)
list(APPEND CUDA_NVCC_FLAGS -std=c++14;-Xcompiler;-fPIC)
endif()

if(APPLE)
Expand Down
3 changes: 2 additions & 1 deletion cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ if(BUILD_python)
boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
PATHS ${LIBDIR})
if ("${Boost_PYTHON_FOUND}" STREQUAL "Boost_PYTHON_FOUND-NOTFOUND")
message(SEND_ERROR "Could NOT find Boost Python Library")
find_package(Boost 1.65 COMPONENTS "python${python_version}")
set(Boost_PYTHON_FOUND ${Boost_PYTHON${python_version}_FOUND})
else()
message(STATUS "Found Boost Python Library ${Boost_PYTHON_FOUND}")
list(APPEND Caffe_LINKER_LIBS ${Boost_PYTHON_FOUND})
Expand Down
2 changes: 1 addition & 1 deletion cmake/Misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif()

# ---[ RPATH settings
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOLEAN "Use link paths for shared library rpath")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOLEAN "Use link paths for shared library rpath")
set(CMAKE_MACOSX_RPATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/lib __is_systtem_dir)
Expand Down
2 changes: 1 addition & 1 deletion examples/web_demo/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ flask
tornado
numpy
pandas
pillow=>6.2.0
pillow>=6.2.0
pyyaml
Loading

0 comments on commit c1e3b78

Please sign in to comment.