Skip to content

Commit

Permalink
cmake build configuration for travis-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Kosiorek authored and jeffdonahue committed Aug 17, 2014
1 parent c357810 commit a2a4d63
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 21 deletions.
47 changes: 33 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ before_install:
- sudo apt-get -y install wget git curl python-dev python-numpy libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev protobuf-compiler libatlas-dev libatlas-base-dev bc

install:
# CMake 2.8.12
- wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz -O /tmp/cmake.tar.gz && tar -C /tmp -xvf /tmp/cmake.tar.gz && rm /tmp/cmake.tar.gz
- cd /tmp/cmake-2.8.12 && ./bootstrap --prefix=/usr && make -j4 && sudo make install -j4 && cd - #&& rm -r /tmp/cmake-2.8.12
#
- wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz -O /tmp/glog-0.3.3.tar.gz && tar -C /tmp -xzvf /tmp/glog-0.3.3.tar.gz && rm /tmp/glog-0.3.3.tar.gz
- cd /tmp/glog-0.3.3 && ./configure && make && sudo make install && cd -
- cd /tmp/glog-0.3.3 && ./configure && make -j4 && sudo make install -j4 && cd -
- wget https://github.com/schuhschuh/gflags/archive/master.zip -O /tmp/gflags-master.zip && pushd /tmp/ && unzip gflags-master.zip && cd gflags-master && mkdir build && cd build && export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1 && sudo make install && popd
- curl http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb -o /tmp/cuda_install.deb && sudo dpkg -i /tmp/cuda_install.deb && rm /tmp/cuda_install.deb
- sudo apt-get -y update
Expand All @@ -30,27 +34,42 @@ install:
# manually since we did a partial installation.)
- sudo ln -s /usr/local/cuda-6.0 /usr/local/cuda
- curl https://gitorious.org/mdb/mdb/archive/7f038d0f15bec57b4c07aa3f31cd5564c88a1897.tar.gz -o /tmp/mdb.tar.gz && tar -C /tmp -xzvf /tmp/mdb.tar.gz && rm /tmp/mdb.tar.gz
- cd /tmp/mdb-mdb/libraries/liblmdb/ && make && sudo make install && cd -
- cd /tmp/mdb-mdb/libraries/liblmdb/ && make -j4 && sudo make install -j4 && cd -

before_script:
- mv Makefile.config.example Makefile.config
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
- export NUM_THREADS=4

script:
# CPU-GPU: build only.
- export CPU_ONLY=0
- make --keep-going --jobs=$NUM_THREADS all
# CMake build.
- mkdir build
- cd build
## CPU-only build
#- cmake -DBUILD_PYTHON=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release -DCPU_ONLY=ON ..
#- make --keep-going --jobs=$NUM_THREADS
#- make clean
#- rm -rf *
## GPU + CPU build
- cmake -DBUILD_PYTHON=ON -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release ..
- make --keep-going --jobs=$NUM_THREADS
- make clean
# CPU-only: comprehensive.
- export CPU_ONLY=1
- make --keep-going --jobs=$NUM_THREADS all test warn lint
- make runtest
- make --jobs=$NUM_THREADS all
- make --jobs=$NUM_THREADS test
- make --jobs=$NUM_THREADS warn
- make --jobs=$NUM_THREADS lint
- make --jobs=$NUM_THREADS pycaffe
- cd ..
- rm -r build

# # CPU-GPU: build only.
# - export CPU_ONLY=0
# - make --keep-going --jobs=$NUM_THREADS all
# - make clean
# # CPU-only: comprehensive.
# - export CPU_ONLY=1
# - make --keep-going --jobs=$NUM_THREADS all test warn lint
# - make runtest
# - make --jobs=$NUM_THREADS all
# - make --jobs=$NUM_THREADS test
# - make --jobs=$NUM_THREADS warn
# - make --jobs=$NUM_THREADS lint
# - make --jobs=$NUM_THREADS pycaffe

notifications:
# Emails are sent to the committer's git-configured email address by default,
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.8)
project( Caffe )

### Build Options ##########################################################################
Expand Down Expand Up @@ -29,7 +29,7 @@ enable_testing()
# Compiler Flags
set(CMAKE_CXX_COMPILER_FLAGS ${CMAKE_CXX_COMPILER_FLAGS} -Wall)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fPIC)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} -O3)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )#-O3)

# Include Directories
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include)
Expand All @@ -43,7 +43,6 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeScripts)
find_package(CUDA 5.5 REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})


### Subdirectories ##########################################################################

add_subdirectory(src/gtest)
Expand Down
33 changes: 33 additions & 0 deletions CMakeScripts/FindSnappy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Find the Snappy libraries
#
# The following variables are optionally searched for defaults
# Snappy_ROOT_DIR: Base directory where all Snappy components are found
#
# The following are set after configuration is done:
# Snappy_FOUND
# Snappy_INCLUDE_DIRS
# Snappy_LIBS

find_path(SNAPPY_INCLUDE_DIR
NAMES snappy.h
HINTS ${SNAPPY_ROOT_DIR}
${SNAPPY_ROOT_DIR}/include
)

find_library(SNAPPY_LIBS
NAMES snappy
HINTS ${SNAPPY_ROOT_DIR}
${SNAPPY_ROOT_DIR}/lib
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Snappy
DEFAULT_MSG
SNAPPY_LIBS
SNAPPY_INCLUDE_DIR
)

mark_as_advanced(
SNAPPY_LIBS
SNAPPY_INCLUDE_DIR
)
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})

# Boost.Python
find_package(Boost 1.49 COMPONENTS python REQUIRED)
find_package(Boost 1.46 COMPONENTS python REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

file(GLOB_RECURSE Python_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
Expand Down
10 changes: 9 additions & 1 deletion src/caffe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ include_directories(${OpenCV_INCLUDE_DIRS})
# LevelDB
find_package(LevelDB REQUIRED)
include_directories(${LEVELDB_INCLUDE})
if(LEVELDB_FOUND)
find_package(Snappy REQUIRED)
include_directories(${SNAPPY_INCLUDE_DIR})
set(LEVELDB_LIBS
${LEVELDB_LIBS}
${SNAPPY_LIBS}
)
endif()

# LMDB
find_package(LMDB REQUIRED)
Expand Down Expand Up @@ -82,12 +90,12 @@ add_dependencies(caffe_cu proto)

target_link_libraries(caffe caffe_cu proto
${GLOG_LIBRARIES}
${CUDA_curand_LIBRARY}
${HDF5_LIBRARIES}
${OpenCV_LIBS}
${LEVELDB_LIBS}
${LMDB_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_curand_LIBRARY}
${BLAS_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
Expand Down
4 changes: 3 additions & 1 deletion src/caffe/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project( Proto )

# Google Protocol Buffers
Expand All @@ -23,6 +22,9 @@ add_library(proto

target_link_libraries(proto ${PROTOBUF_LIBRARIES})

# Create proto include directory
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/include/caffe/proto)

# Copy proto headers to include/caffe/proto/
foreach(header ${ProtoHeaders})

Expand Down
1 change: 0 additions & 1 deletion src/caffe/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# All test files' names must begin with a "test_" prefix
#
#
cmake_minimum_required(VERSION 2.8)
project( Test )

# Set CUDA Device number and CMAKE_SOURCE_DIR
Expand Down

0 comments on commit a2a4d63

Please sign in to comment.