| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,24 +6,31 @@ env: | |||
| 6 | 6 | - WITH_CUDA=false WITH_CMAKE=true | |
| 7 | 7 | - WITH_CUDA=true WITH_CMAKE=false | |
| 8 | 8 | - WITH_CUDA=true WITH_CMAKE=true | |
| 9 | + - WITH_CUDA=false WITH_CMAKE=true PYTHON_VERSION=3 | ||
| 9 | 10 | ||
| 10 | 11 | language: cpp | |
| 11 | 12 | ||
| 12 | 13 | # Cache Ubuntu apt packages. | |
| 13 | - cache: apt | ||
| 14 | + cache: | ||
| 15 | + apt: true | ||
| 16 | + directories: | ||
| 17 | + - /home/travis/miniconda | ||
| 18 | + - /home/travis/miniconda2 | ||
| 19 | + - /home/travis/miniconda3 | ||
| 14 | 20 | ||
| 15 | 21 | compiler: gcc | |
| 16 | 22 | ||
| 17 | 23 | before_install: | |
| 18 | 24 | - export NUM_THREADS=4 | |
| 19 | 25 | - export SCRIPTS=./scripts/travis | |
| 26 | + - export CONDA_DIR="/home/travis/miniconda$PYTHON_VERSION" | ||
| 20 | 27 | ||
| 21 | 28 | install: | |
| 22 | 29 | - sudo -E $SCRIPTS/travis_install.sh | |
| 23 | 30 | ||
| 24 | 31 | before_script: | |
| 25 | - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/cuda/lib64 | ||
| 26 | - - export PATH=/home/travis/miniconda/bin:$PATH | ||
| 32 | + - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/cuda/lib64:$CONDA_DIR/lib | ||
| 33 | + - export PATH=$CONDA_DIR/bin:$PATH | ||
| 27 | 34 | - if ! $WITH_CMAKE; then $SCRIPTS/travis_setup_makefile_config.sh; fi | |
| 28 | 35 | ||
| 29 | 36 | script: $SCRIPTS/travis_build_and_test.sh | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,6 +62,10 @@ add_subdirectory(docs) | |||
| 62 | 62 | # ---[ Linter target | |
| 63 | 63 | add_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake) | |
| 64 | 64 | ||
| 65 | + # ---[ pytest target | ||
| 66 | + add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python ) | ||
| 67 | + add_dependencies(pytest pycaffe) | ||
| 68 | + | ||
| 65 | 69 | # ---[ Configuration summary | |
| 66 | 70 | caffe_print_configuration_summary() | |
| 67 | 71 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -228,7 +228,7 @@ ifeq ($(LINUX), 1) | |||
| 228 | 228 | CXX ?= /usr/bin/g++ | |
| 229 | 229 | GCCVERSION := $(shell $(CXX) -dumpversion | cut -f1,2 -d.) | |
| 230 | 230 | # older versions of gcc are too dumb to build boost with -Wuninitalized | |
| 231 | - ifeq ($(shell echo $(GCCVERSION) \< 4.6 | bc), 1) | ||
| 231 | + ifeq ($(shell echo | awk '{exit $(GCCVERSION) < 4.6;}'), 1) | ||
| 232 | 232 | WARNINGS += -Wno-uninitialized | |
| 233 | 233 | endif | |
| 234 | 234 | # boost::thread is reasonably called boost_thread (compare OS X) | |
@@ -243,7 +243,7 @@ ifeq ($(OSX), 1) | |||
| 243 | 243 | CXX := /usr/bin/clang++ | |
| 244 | 244 | ifneq ($(CPU_ONLY), 1) | |
| 245 | 245 | CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release \d' | grep -o '\d') | |
| 246 | - ifeq ($(shell echo $(CUDA_VERSION) \< 7.0 | bc), 1) | ||
| 246 | + ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1) | ||
| 247 | 247 | CXXFLAGS += -stdlib=libstdc++ | |
| 248 | 248 | LINKFLAGS += -stdlib=libstdc++ | |
| 249 | 249 | endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,14 +106,15 @@ if(BUILD_python) | |||
| 106 | 106 | ||
| 107 | 107 | while(NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND) | |
| 108 | 108 | STRING( REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version} ) | |
| 109 | - STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} ) | ||
| 110 | - if("${has_more_version}" STREQUAL "") | ||
| 111 | - break() | ||
| 112 | - endif() | ||
| 113 | 109 | ||
| 114 | 110 | STRING( REPLACE "." "" boost_py_version ${version} ) | |
| 115 | 111 | find_package(Boost 1.46 COMPONENTS "python-py${boost_py_version}") | |
| 116 | 112 | set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND}) | |
| 113 | + | ||
| 114 | + STRING( REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version} ) | ||
| 115 | + if("${has_more_version}" STREQUAL "") | ||
| 116 | + break() | ||
| 117 | + endif() | ||
| 117 | 118 | endwhile() | |
| 118 | 119 | if(NOT Boost_PYTHON_FOUND) | |
| 119 | 120 | find_package(Boost 1.46 COMPONENTS python) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | import tempfile | |
| 3 | 3 | import os | |
| 4 | 4 | import numpy as np | |
| 5 | + import six | ||
| 5 | 6 | ||
| 6 | 7 | import caffe | |
| 7 | 8 | ||
@@ -10,7 +11,7 @@ def simple_net_file(num_output): | |||
| 10 | 11 | """Make a simple net prototxt, based on test_net.cpp, returning the name | |
| 11 | 12 | of the (temporary) file.""" | |
| 12 | 13 | ||
| 13 | - f = tempfile.NamedTemporaryFile(delete=False) | ||
| 14 | + f = tempfile.NamedTemporaryFile(mode='w+', delete=False) | ||
| 14 | 15 | f.write("""name: 'testnet' force_backward: true | |
| 15 | 16 | layer { type: 'DummyData' name: 'data' top: 'data' top: 'label' | |
| 16 | 17 | dummy_data_param { num: 5 channels: 2 height: 3 width: 4 | |
@@ -47,7 +48,7 @@ def setUp(self): | |||
| 47 | 48 | def test_memory(self): | |
| 48 | 49 | """Check that holding onto blob data beyond the life of a Net is OK""" | |
| 49 | 50 | ||
| 50 | - params = sum(map(list, self.net.params.itervalues()), []) | ||
| 51 | + params = sum(map(list, six.itervalues(self.net.params)), []) | ||
| 51 | 52 | blobs = self.net.blobs.values() | |
| 52 | 53 | del self.net | |
| 53 | 54 | ||
@@ -67,7 +68,7 @@ def test_inputs_outputs(self): | |||
| 67 | 68 | self.assertEqual(self.net.outputs, ['loss']) | |
| 68 | 69 | ||
| 69 | 70 | def test_save_and_read(self): | |
| 70 | - f = tempfile.NamedTemporaryFile(delete=False) | ||
| 71 | + f = tempfile.NamedTemporaryFile(mode='w+', delete=False) | ||
| 71 | 72 | f.close() | |
| 72 | 73 | self.net.save(f.name) | |
| 73 | 74 | net_file = simple_net_file(self.num_output) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,7 +43,7 @@ def anon_lenet(batch_size): | |||
| 43 | 43 | ||
| 44 | 44 | class TestNetSpec(unittest.TestCase): | |
| 45 | 45 | def load_net(self, net_proto): | |
| 46 | - f = tempfile.NamedTemporaryFile(delete=False) | ||
| 46 | + f = tempfile.NamedTemporaryFile(mode='w+', delete=False) | ||
| 47 | 47 | f.write(str(net_proto)) | |
| 48 | 48 | f.close() | |
| 49 | 49 | return caffe.Net(f.name, caffe.TEST) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import unittest | |
| 2 | 2 | import tempfile | |
| 3 | 3 | import os | |
| 4 | + import six | ||
| 4 | 5 | ||
| 5 | 6 | import caffe | |
| 6 | 7 | ||
@@ -22,7 +23,7 @@ def backward(self, top, propagate_down, bottom): | |||
| 22 | 23 | ||
| 23 | 24 | ||
| 24 | 25 | def python_net_file(): | |
| 25 | - with tempfile.NamedTemporaryFile(delete=False) as f: | ||
| 26 | + with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: | ||
| 26 | 27 | f.write("""name: 'pythonnet' force_backward: true | |
| 27 | 28 | input: 'data' input_shape { dim: 10 dim: 9 dim: 8 } | |
| 28 | 29 | layer { type: 'Python' name: 'one' bottom: 'data' top: 'one' | |
@@ -58,6 +59,6 @@ def test_reshape(self): | |||
| 58 | 59 | s = 4 | |
| 59 | 60 | self.net.blobs['data'].reshape(s, s, s, s) | |
| 60 | 61 | self.net.forward() | |
| 61 | - for blob in self.net.blobs.itervalues(): | ||
| 62 | + for blob in six.itervalues(self.net.blobs): | ||
| 62 | 63 | for d in blob.data.shape: | |
| 63 | 64 | self.assertEqual(s, d) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | import tempfile | |
| 3 | 3 | import os | |
| 4 | 4 | import numpy as np | |
| 5 | + import six | ||
| 5 | 6 | ||
| 6 | 7 | import caffe | |
| 7 | 8 | from test_net import simple_net_file | |
@@ -11,7 +12,7 @@ class TestSolver(unittest.TestCase): | |||
| 11 | 12 | def setUp(self): | |
| 12 | 13 | self.num_output = 13 | |
| 13 | 14 | net_f = simple_net_file(self.num_output) | |
| 14 | - f = tempfile.NamedTemporaryFile(delete=False) | ||
| 15 | + f = tempfile.NamedTemporaryFile(mode='w+', delete=False) | ||
| 15 | 16 | f.write("""net: '""" + net_f + """' | |
| 16 | 17 | test_iter: 10 test_interval: 10 base_lr: 0.01 momentum: 0.9 | |
| 17 | 18 | weight_decay: 0.0005 lr_policy: 'inv' gamma: 0.0001 power: 0.75 | |
@@ -45,8 +46,8 @@ def test_net_memory(self): | |||
| 45 | 46 | ||
| 46 | 47 | total = 0 | |
| 47 | 48 | for net in nets: | |
| 48 | - for ps in net.params.itervalues(): | ||
| 49 | + for ps in six.itervalues(net.params): | ||
| 49 | 50 | for p in ps: | |
| 50 | 51 | total += p.data.sum() + p.diff.sum() | |
| 51 | - for bl in net.blobs.itervalues(): | ||
| 52 | + for bl in six.itervalues(net.blobs): | ||
| 52 | 53 | total += bl.data.sum() + bl.diff.sum() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,8 +7,17 @@ MAKE="make --jobs=$NUM_THREADS --keep-going" | |||
| 7 | 7 | if $WITH_CMAKE; then | |
| 8 | 8 | mkdir build | |
| 9 | 9 | cd build | |
| 10 | - cmake -DBUILD_python=ON -DCMAKE_BUILD_TYPE=Release -DCPU_ONLY=ON .. | ||
| 10 | + CPU_ONLY=" -DCPU_ONLY=ON" | ||
| 11 | + if ! $WITH_CUDA; then | ||
| 12 | + CPU_ONLY=" -DCPU_ONLY=OFF" | ||
| 13 | + fi | ||
| 14 | + PYTHON_ARGS="" | ||
| 15 | + if [ "$PYTHON_VERSION" = "3" ]; then | ||
| 16 | + PYTHON_ARGS="$PYTHON_ARGS -Dpython_version=3 -DBOOST_LIBRARYDIR=$CONDA_DIR/lib/" | ||
| 17 | + fi | ||
| 18 | + cmake -DBUILD_python=ON -DCMAKE_BUILD_TYPE=Release $CPU_ONLY $PYTHON_ARGS -DCMAKE_INCLUDE_PATH="$CONDA_DIR/include/" -DCMAKE_LIBRARY_PATH="$CONDA_DIR/lib/" .. | ||
| 11 | 19 | $MAKE | |
| 20 | + $MAKE pytest | ||
| 12 | 21 | if ! $WITH_CUDA; then | |
| 13 | 22 | $MAKE runtest | |
| 14 | 23 | $MAKE lint | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,17 +4,15 @@ | |||
| 4 | 4 | set -e | |
| 5 | 5 | ||
| 6 | 6 | MAKE="make --jobs=$NUM_THREADS" | |
| 7 | - | ||
| 8 | 7 | # Install apt packages where the Ubuntu 12.04 default and ppa works for Caffe | |
| 9 | 8 | ||
| 10 | 9 | # This ppa is for gflags and glog | |
| 11 | 10 | add-apt-repository -y ppa:tuleu/precise-backports | |
| 12 | 11 | apt-get -y update | |
| 13 | 12 | apt-get install \ | |
| 14 | 13 | wget git curl \ | |
| 15 | - python-dev python-numpy \ | ||
| 14 | + python-dev python-numpy python3-dev\ | ||
| 16 | 15 | libleveldb-dev libsnappy-dev libopencv-dev \ | |
| 17 | - libboost-dev libboost-system-dev libboost-python-dev libboost-thread-dev \ | ||
| 18 | 16 | libprotobuf-dev protobuf-compiler \ | |
| 19 | 17 | libatlas-dev libatlas-base-dev \ | |
| 20 | 18 | libhdf5-serial-dev libgflags-dev libgoogle-glog-dev \ | |
@@ -24,9 +22,10 @@ apt-get install \ | |||
| 24 | 22 | # if needed. By default, Aptitude in Ubuntu 12.04 installs CMake 2.8.7, but | |
| 25 | 23 | # Caffe requires a minimum CMake version of 2.8.8. | |
| 26 | 24 | if $WITH_CMAKE; then | |
| 27 | - add-apt-repository -y ppa:ubuntu-sdk-team/ppa | ||
| 28 | - apt-get -y update | ||
| 29 | - apt-get -y install cmake | ||
| 25 | + # cmake 3 will make sure that the python interpreter and libraries match | ||
| 26 | + wget http://www.cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.sh -O cmake3.sh | ||
| 27 | + chmod +x cmake3.sh | ||
| 28 | + ./cmake3.sh --prefix=/usr/ --skip-license --exclude-subdir | ||
| 30 | 29 | fi | |
| 31 | 30 | ||
| 32 | 31 | # Install CUDA, if needed | |
@@ -60,10 +59,37 @@ rm -f $LMDB_FILE | |||
| 60 | 59 | ||
| 61 | 60 | # Install the Python runtime dependencies via miniconda (this is much faster | |
| 62 | 61 | # than using pip for everything). | |
| 63 | - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh | ||
| 64 | - chmod +x miniconda.sh | ||
| 65 | - ./miniconda.sh -b | ||
| 66 | - export PATH=/home/travis/miniconda/bin:$PATH | ||
| 67 | - conda update --yes conda | ||
| 68 | - conda install --yes numpy scipy matplotlib scikit-image pip | ||
| 69 | - pip install protobuf | ||
| 62 | + export PATH=$CONDA_DIR/bin:$PATH | ||
| 63 | + if [ ! -d $CONDA_DIR ]; then | ||
| 64 | + if [ "$PYTHON_VERSION" -eq "3" ]; then | ||
| 65 | + wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh | ||
| 66 | + else | ||
| 67 | + wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh | ||
| 68 | + fi | ||
| 69 | + chmod +x miniconda.sh | ||
| 70 | + ./miniconda.sh -b -p $CONDA_DIR | ||
| 71 | + | ||
| 72 | + conda update --yes conda | ||
| 73 | + conda install --yes numpy scipy matplotlib scikit-image pip | ||
| 74 | + # Let conda install boost (so that boost_python matches) | ||
| 75 | + conda install --yes -c https://conda.binstar.org/menpo boost=1.56.0 | ||
| 76 | + fi | ||
| 77 | + | ||
| 78 | + # install protobuf 3 (just use the miniconda3 directory to avoid having to setup the path again) | ||
| 79 | + if [ "$PYTHON_VERSION" -eq "3" ] && [ ! -e "$CONDA_DIR/bin/protoc" ]; then | ||
| 80 | + pushd . | ||
| 81 | + wget https://github.com/google/protobuf/archive/v3.0.0-alpha-3.1.tar.gz -O protobuf-3.tar.gz | ||
| 82 | + tar -C /tmp -xzvf protobuf-3.tar.gz | ||
| 83 | + cd /tmp/protobuf-3*/ | ||
| 84 | + ./autogen.sh | ||
| 85 | + ./configure --prefix=$CONDA_DIR | ||
| 86 | + $MAKE | ||
| 87 | + $MAKE install | ||
| 88 | + popd | ||
| 89 | + fi | ||
| 90 | + | ||
| 91 | + if [ "$PYTHON_VERSION" -eq "3" ]; then | ||
| 92 | + pip install --pre protobuf | ||
| 93 | + else | ||
| 94 | + pip install protobuf | ||
| 95 | + fi | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments