Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
PROJECT(convnet)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)

IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0016 NEW)
ENDIF(COMMAND CMAKE_POLICY)

SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

SET(CMAKE_MODULE_PATH "cmake/;${CMAKE_MODULE_PATH}")

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

SET(CUDA_PROPAGATE_HOST_FLAGS OFF CACHE STRING "" FORCE)

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -mtune=native")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -mtune=native")
SET(CUDA_NVCC_FLAGS "-O3 --use_fast_math -gencode=arch=compute_20,code=sm_20
-gencode=arch=compute_30,code=sm_30
-gencode=arch=compute_35,code=sm_35")

# Set a default build type if none was specified
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
MESSAGE(STATUS "Setting build type to 'Release' as none was specified.")
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
ENDIF()

SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -g")

#####
# find OpenMP library
FIND_PACKAGE(OpenMP REQUIRED)
IF(OPENMP_FOUND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
MESSAGE(STATUS "OpenMP found.")
ENDIF()

#####
# find CUDA
FIND_PACKAGE(CUDA REQUIRED)
INCLUDE_DIRECTORIES(${CUDA_TOOLKIT_INCLUDE})

#####
# find OPENBLAS library
FIND_PATH(OPENBLAS_INCLUDE_DIR cblas.h PATH_SUFFIXES openblas)
INCLUDE_DIRECTORIES(${OPENBLAS_INCLUDE_DIR})
FIND_LIBRARY(CBLAS_LIBRARY NAMES openblas)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CBLAS DEFAULT_MSG CBLAS_LIBRARY)
MARK_AS_ADVANCED(CBLAS_LIBRARY)

#####
# find CIMG library
FIND_PATH(CIMG_INCLUDE_DIR CImg.h REQUIRED)
INCLUDE_DIRECTORIES(${CIMG_INCLUDE_DIR})
IF(CIMG_INCLUDE_DIR)
MESSAGE(STATUS "CImg found.")
ENDIF()

#####
# find TCLAP library
FIND_PATH(TCLAP_INCLUDE_DIR CmdLine.h REQUIRED PATH_SUFFIXES tclap)
INCLUDE_DIRECTORIES(${TCLAP_INCLUDE_DIR})
IF(TCLAP_INCLUDE_DIR)
MESSAGE(STATUS "TCLAP found.")
ENDIF()


INCLUDE(FindPkgConfig REQUIRED)

#####
# find HDF5 library
FIND_PACKAGE(HDF5 QUIET REQUIRED)
IF(HDF5_FOUND)
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
MESSAGE(STATUS "HDF5 found.")
ENDIF()

#####
# find JPEG library
FIND_PACKAGE(JPEG COMPONENTS REQUIRED)
IF(JPEG_FOUND)
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIRS})
MESSAGE(STATUS "JPEG found.")
ENDIF()

#####
# find X11 library
FIND_PACKAGE(X11 COMPONENTS REQUIRED)
IF(X11_FOUND)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIRS})
MESSAGE(STATUS "X11 found.")
ENDIF()

#####
# find google protobuf
IF(PKG_CONFIG_FOUND)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PROTOBUF REQUIRED protobuf)
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIRS})
ENDIF()

#####
# find protobuf compiler
FIND_PROGRAM(PROTOC_EXE NAMES protoc REQUIRED)
IF(NOT PROTOC_EXE)
MESSAGE(FATAL_ERROR "Could not find protoc rule compiler.")
ELSE()
MESSAGE(STATUS "Found protobuf compiler: " ${PROTOC_EXE})
ENDIF()

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(cpu)

52 changes: 0 additions & 52 deletions INSTALL

This file was deleted.

66 changes: 66 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

###Dependencies###


#####CUDA (>= 4.0) #####
(Not required for the CPU-only feature extractor).

#####HDF5 (>= 1.8.11) #####

Download the source code: [http://www.hdfgroup.org/ftp/HDF5/prev-releases/hdf5-1.8.12/src/hdf5-1.8.12.tar.gz](http://www.hdfgroup.org/ftp/HDF5/prev-releases/hdf5-1.8.12/src/hdf5-1.8.12.tar.gz)

To install locally -

> ./configure --prefix=~/local/ --enable-threadsafe --with-pthread=/usr/include
> make
> make install

#####Protocol Buffers (>= 2.5.0)#####

Download the source code:
[https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz](https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz)

To install locally -

> ./configure --prefix=~/local/
> make
> make install

#####libjpeg#####

This is often present on standard operating systems since it is used by a lot of programs.

It can be downloaded from [http://libjpeg.sourceforge.net/](http://libjpeg.sourceforge.net/)

#####C++ 11#####
This code uses C++11. Some features require gcc >= 4.6.


###Hardware requirements###

NVIDIA GPU(s).

Multi-GPU feature requires Fermi boards.


###Compilation###
Compiling the CPU-only feature extractor

- Set the paths to the dependencies in `convnet/cpu/Makefile`
- Run make in `convnet/cpu`.

Compiling the full package

- Set the paths to the dependencies in `convnet/Makefile`
- Set the compute capability for your GPU.
- Run make in `convnet`.

Add `convnet/bin` to your PATH variable (maybe in your .bashrc)


###Run test examples###

Examples of nets on `MNIST` and `ImageNet` are included in
`examples/mnist` and `examples/imagenet`.

Follow the instructions in the respective README.md files.
68 changes: 0 additions & 68 deletions Makefile

This file was deleted.

25 changes: 25 additions & 0 deletions cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

ADD_DEFINITIONS(-DUSE_OPENBLAS -DUSE_OPENMP)

# google protobuf
ADD_CUSTOM_COMMAND(
OUTPUT convnet_config.pb.h convnet_config.pb.cc
COMMAND ${PROTOC_EXE} --proto_path ${PROJECT_SOURCE_DIR}/proto/
${PROJECT_SOURCE_DIR}/proto/convnet_config.proto --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${PROJECT_SOURCE_DIR}/proto/convnet_config.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/convnet_config.pb.h
${CMAKE_CURRENT_BINARY_DIR}/convnet_config.pb.cc
PROPERTIES
GENERATED TRUE)

# extract_representation_cpu
ADD_EXECUTABLE( extract_representation_cpu convnet_config.pb.cc cpuconv.cc convnet_cpu.cc extract_representation_cpu.cc )
TARGET_LINK_LIBRARIES( extract_representation_cpu
${CBLAS_LIBRARY}
${HDF5_LIBRARIES}
${PROTOBUF_LIBRARIES}
${JPEG_LIBRARIES}
${X11_LIBRARIES} )

51 changes: 0 additions & 51 deletions cpu/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion cpu/cpuconv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#ifdef USE_OPENBLAS
#include <cblas.h>
#include <common.h>
#endif

using namespace std;
Expand Down
Loading