Docker build from Dockerfile with more memory - docker

How to docker build from Dockerfile with more memory?
This is a different question from this Allow more memory when docker build a Dockerfile
When installing the software natively, there is enough memory to successfully build and install the marian tool
But when building the Docker image using the Dockerfile
https://github.com/marian-nmt/marian/blob/master/scripts/docker/Dockerfile.cpu , it fails with multiple memory exhausted errors
virtual memory exhausted: Cannot allocate memory
[out]:
Step : RUN cmake $MARIANPATH && make -j
---> Running in 4867d166d17a
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Cannot find CUDA libraries. Compiling without them.
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- program_options
-- timer
-- iostreams
-- python
-- thread
-- chrono
-- regex
-- date_time
-- atomic
-- Found Python
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.12", minimum required is "2.7")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Found Git: /usr/bin/git (found version "2.7.4")
-- Git version: 5abc774
-- Found SparseHash: /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /marian/build
Scanning dependencies of target fast_align
Scanning dependencies of target extract_lex
Scanning dependencies of target libcnpy
Scanning dependencies of target atools
Scanning dependencies of target libyaml-cpp-amun
[ 2%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/exception.cpp.o
[ 2%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/utils.cpp.o
[ 3%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/fast_align.dir/src/ttables.cc.o
[ 6%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/fast_align.dir/src/fast_align.cc.o
[ 7%] Building CXX object src/amun/3rd_party/extract_lex/CMakeFiles/extract_lex.dir/extract-lex-main.cpp.o
[ 10%] Building CXX object src/amun/3rd_party/CMakeFiles/libcnpy.dir/cnpy/cnpy.cpp.o
[ 10%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/atools.dir/src/atools.cc.o
[ 10%] Building CXX object src/amun/3rd_party/fast_align/CMakeFiles/atools.dir/src/alignment_io.cc.o
[ 11%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/regex_yaml.cpp.o
[ 12%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scanner.cpp.o
[ 14%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/convert.cpp.o
[ 15%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/stream.cpp.o
[ 16%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/memory.cpp.o
[ 17%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/node.cpp.o
[ 19%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/directives.cpp.o
[ 20%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/null.cpp.o
[ 21%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitfromevents.cpp.o
[ 23%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/singledocparser.cpp.o
[ 24%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitterstate.cpp.o
[ 25%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scantag.cpp.o
[ 26%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/simplekey.cpp.o
[ 28%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/binary.cpp.o
[ 29%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/parser.cpp.o
[ 30%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/nodeevents.cpp.o
[ 32%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emit.cpp.o
[ 33%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/exp.cpp.o
[ 35%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/nodebuilder.cpp.o
[ 38%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scanscalar.cpp.o
[ 39%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitter.cpp.o
[ 41%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/tag.cpp.o
[ 42%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/scantoken.cpp.o
[ 43%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/ostream_wrapper.cpp.o
Scanning dependencies of target libcommon
[ 37%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/node_data.cpp.o
[ 44%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/contrib/graphbuilder.cpp.o
[ 46%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/emitterutils.cpp.o
[ 34%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/contrib/graphbuilderadapter.cpp.o
[ 47%] Building CXX object src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/parse.cpp.o
[ 48%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/scorer.cpp.o
[ 50%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/git_version.cpp.o
[ 51%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/base_matrix.cpp.o
[ 52%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/sentence.cpp.o
[ 53%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/config.cpp.o
[ 55%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/utils.cpp.o
[ 56%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/vocab.cpp.o
[ 65%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/filter.cpp.o
[ 66%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/god.cpp.o
[ 67%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/exception.cpp.o
[ 69%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/search.cpp.o
[ 69%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/hypothesis.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/translation_task.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/sentences.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/history.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/logging.cpp.o
[ 70%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/processor/bpe.cpp.o
[ 71%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/output_collector.cpp.o
[ 73%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/types.cpp.o
[ 74%] Building CXX object src/amun/CMakeFiles/libcommon.dir/common/loader.cpp.o
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
virtual memory exhausted: Cannot allocate memory
And eventually it leads to:
src/amun/CMakeFiles/libcommon.dir/build.make:254: recipe for target 'src/amun/CMakeFiles/libcommon.dir/common/loader.cpp.o' failed
virtual memory exhausted: Cannot allocate memory
make[2]: *** [src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder.cpp.o] Error 1
src/amun/CMakeFiles/cpumode.dir/build.make:110: recipe for target 'src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder.cpp.o' failed
[ 79%] Built target libcnpy
virtual memory exhausted: Cannot allocate memory
src/amun/CMakeFiles/libcommon.dir/build.make:326: recipe for target 'src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o' failed
make[2]: *** [src/amun/CMakeFiles/libcommon.dir/common/printer.cpp.o] Error 1
CMakeFiles/Makefile2:340: recipe for target 'src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/all' failed
make[1]: *** [src/amun/3rd_party/yaml-cpp/CMakeFiles/libyaml-cpp-amun.dir/all] Error 2
CMakeFiles/Makefile2:182: recipe for target 'src/amun/CMakeFiles/libcommon.dir/all' failed
make[1]: *** [src/amun/CMakeFiles/libcommon.dir/all] Error 2
make[1]: *** [src/amun/CMakeFiles/cpumode.dir/all] Error 2
CMakeFiles/Makefile2:110: recipe for target 'src/amun/CMakeFiles/cpumode.dir/all' failed
make: *** [all] Error 2
Looking at the docker build --help, there are options to control memory usage:
$ docker build --help
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Options:
--build-arg list Set build-time variables (default [])
--cache-from stringSlice Images to consider as cache sources
--cgroup-parent string Optional parent cgroup for the container
--compress Compress the build context using gzip
--cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota
-c, --cpu-shares int CPU shares (relative weight)
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--disable-content-trust Skip image verification (default true)
-f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')
--force-rm Always remove intermediate containers
--help Print usage
--isolation string Container isolation technology
--label list Set metadata for an image (default [])
-m, --memory string Memory limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--network string Set the networking mode for the RUN instructions during build (default "default")
--no-cache Do not use cache when building the image
--pull Always attempt to pull a newer version of the image
-q, --quiet Suppress the build output and print image ID on success
--rm Remove intermediate containers after a successful build (default true)
--security-opt stringSlice Security options
--shm-size string Size of /dev/shm, default value is 64MB
-t, --tag list Name and optionally a tag in the 'name:tag' format (default [])
--ulimit ulimit Ulimit options (default [])
But I couldn't figure out the correct syntax of where exactly to put the -m option -_-|||
It isn't before the Dockerfile:
# Before Docker file.
$ docker build -m 4g Dockerfile.cpu -t ibot-cpu .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after Dockerfile before -t
# Before -t
$ docker build Dockerfile.cpu -m 4g -t ibot-cpu .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after -t before the local path
# Before local path
$ docker build Dockerfile.cpu -t ibot-cpu -m 4g .
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
It isn't after the local path at the end too...
# At the end...
$ docker build Dockerfile.cpu -t ibot-cpu . -m 4g
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
How to docker build from Dockerfile with more memory?
My docker version:
docker version
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Tue Mar 28 00:40:02 2017
OS/Arch: darwin/amd64
Server:
Version: 17.04.0-ce
API version: 1.28 (minimum version 1.12)
Go version: go1.7.5
Git commit: 4845c56
Built: Wed Apr 5 18:45:47 2017
OS/Arch: linux/amd64
Experimental: false

It is not something about order. The Dockerfile must be specified with -f
docker build -f Dockerfile.cpu -t ibot-cpu -m 4g .
However, take into account that by default docker does not limit the container memory. It can take the whole free memory.
As I can see that you are on OSX, which runs docker over a Linux VM. Configure the max memory clicking the whale icon in the task bar. It's 2GB by default.
For further information please see my other answer:
How to assign more memory to docker container

Related

fbthrift: No generator named 'cpp2' could be found after (seemingly) successful build

I'm trying to install crnn which requires fblualib on Ubuntu 18.04 LTS. While building TH++, an error occured (Complete build print attached below):
[ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o
In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0:
/home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include **<thpp/if/gen-cpp2/Tensor_types.h>**
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If I build thpp without using fbthrift and folly by running THPP_NOFB=1 ./build.sh in the thpp directory, the build would be successful (I have thpp files in torch/install/include and torch/install/lib). However, if I move on and build fblualib, an almost identical error occurs:
[ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o
In file included from
/home/huiji/torch/install/include/thpp/Tensor.h:20:0,
from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19,
from /home/huiji/Downloads/fblualib- master/fblualib/LuaUtils.cpp:11:
/home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error:
thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I figure that there may be something wrong with my fbthrift. Then I tried the following commands under directory "thpp/if/". It seems that my fbthrift can't generate a cpp2-format file, but can generate a cpp/py file, awhile my python thrift_compiler can only generate an errored cpp2-format file.
$ thrift --gen cpp2 Tensor.thrift
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:1] No generator named 'cpp2' could be found!
[WARNING:generation:1] Unable to get a generator for "cpp2".
# Nothing was generated in /thpp/if
$ thrift --gen cpp Tensor.thrift && ls gen-cpp
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
Tensor_constants.cpp Tensor_constants.h Tensor_types.cpp Tensor_types.h
$ thrift --gen py Tensor.thrift && ls -R gen-py
[WARNING:/home/huiji/Downloads/thpp-master/thpp/if/Tensor.thrift:3] No generator named 'cpp2' could be found!
gen-py:
__init__.py Tensor
gen-py/Tensor:
constants.py __init__.py ttypes.py
$ python -m thrift_compiler.main --gen cpp2 Tensor.thrift && ls gen-cpp2
Tensor_fatal_all.h Tensor_fatal.h Tensor_fatal_types.h
Tensor_fatal_constant.h Tensor_fatal_service.h Tensor_fatal_union.h
Tensor_fatal_enum.h Tensor_fatal_struct.h
# A "gen-cpp2" directory was created, but in it there was no "Tensor_types.h"!
$ python -m thrift_compiler.main --gen cpp Tensor.thrift
('Argument Error:', ArgumentError('Language cpp not defined.',))
$ python -m thrift_compiler.main --gen py Tensor.thrift
('Argument Error:', ArgumentError('Language py not defined.',))
By the way, my fbthrift install seemed successful except the python package thrift_compiler was not installed correctly. I've followed GitHubGS's suggestion. That seem to have worked (I can now import thrift_compiler in python, below is what I did) but as you can see, it is not really working.
1.modify /thrift/compiler/CMakefile.txt by inserting these lines
set(CMAKE_CXX_FLAGS "-fPIC")
set(CMAKE_C_FLAGS "-fPIC")
2.rebuild/reinstall fbthrift(must step)
3.run your command under /fbthrift/thrift/compiler/py
g++ -I /usr/include/python2.7 -I ../../.. -std=c++14 -fpic -shared -o frontend.so compiler.cc -lboost_python -lpython2.7 -L/build/lib -lcompiler_base -lcompiler_ast -lboost_system -lboost_filesystem -lssl -lcrypto
sudo cp frontend.so /usr/local/lib/python2.7/dist-packages/thrift_py-0.9.0-py2.7.egg/thrift_compiler
Any ideas/suggestions would be greatly appreciated.
=================
Complete message of thpp build:
huiji#NoBoDy:~/Downloads/thpp-master/thpp$ ./build.sh
If you don&apos;t have folly or thrift installed, try doing
THPP_NOFB=1 ./build.sh
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /home/huiji/torch/install
-- Found Folly: /usr/local/include
-- Found Thrift: /usr/local/include
-- Performing Test HAS_NO_AS_NEEDED
-- Performing Test HAS_NO_AS_NEEDED - Success
-- Found Glog: /usr/include
-- Found PythonInterp: /usr/bin/python (found version "2.7.15")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/huiji/Downloads/thpp-master/thpp/build
[ 5%] Generating thpp/if/gen-cpp2/Tensor_data.h, thpp/if/gen-cpp2/Tensor_types.h, thpp/if/gen-cpp2/Tensor_types.tcc, thpp/if/gen-cpp2/Tensor_constants.h, thpp/if/gen-cpp2/Tensor_data.cpp, thpp/if/gen-cpp2/Tensor_types.cpp, thpp/if/gen-cpp2/Tensor_constants.cpp
Scanning dependencies of target thpp
[ 10%] Building CXX object CMakeFiles/thpp.dir/Storage.cpp.o
In file included from /home/huiji/Downloads/thpp-master/thpp/Storage.cpp:11:0:
/home/huiji/Downloads/thpp-master/thpp/../thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/thpp.dir/build.make:84: recipe for target &apos;CMakeFiles/thpp.dir/Storage.cpp.o&apos; failed
make[2]: *** [CMakeFiles/thpp.dir/Storage.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target &apos;CMakeFiles/thpp.dir/all&apos; failed
make[1]: *** [CMakeFiles/thpp.dir/all] Error 2
Makefile:140: recipe for target &apos;all&apos; failed
make: *** [all] Error 2
Complete message of fblualib build:
huiji#NoBoDy:~/Downloads/fblualib-master/fblualib$ ./build.sh
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/g++
-- Check for working CXX compiler: /usr/local/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Folly: /usr/local/include
-- Found Glog: /usr/include
-- Found Torch7 in /home/huiji/torch/install
-- Found Folly: /home/huiji/torch/install/include
-- Configuring done
WARNING: Target "fblualib" requests linking to directory "/home/huiji/torch/install/lib". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /home/huiji/Downloads/fblualib-master/fblualib/build
Scanning dependencies of target fblualib
[ 20%] Building CXX object CMakeFiles/fblualib.dir/LuaUtils.cpp.o
In file included from /home/huiji/torch/install/include/thpp/Tensor.h:20:0,
from /home/huiji/Downloads/fblualib-master/fblualib/../fblualib/LuaUtils.h:19,
from /home/huiji/Downloads/fblualib-master/fblualib/LuaUtils.cpp:11:
/home/huiji/torch/install/include/thpp/Storage.h:22:10: fatal error: thpp/if/gen-cpp2/Tensor_types.h: no such file or directory
#include <thpp/if/gen-cpp2/Tensor_types.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/fblualib.dir/build.make:62: recipe for target &apos;CMakeFiles/fblualib.dir/LuaUtils.cpp.o&apos; failed
make[2]: *** [CMakeFiles/fblualib.dir/LuaUtils.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target &apos;CMakeFiles/fblualib.dir/all&apos; failed
make[1]: *** [CMakeFiles/fblualib.dir/all] Error 2
Makefile:129: recipe for target &apos;all&apos; failed
make: *** [all] Error 2
Use thrift1 and mstch_cpp2 instead. It works for me!
See https://github.com/facebook/fbthrift/issues/271 and $THRIFT_INCLUDE is /usr/local/include/thrift/ in my system.
As one of the above answer mentioned, after building fbthrift successfully, you get bin/thrift1 binary in your build folder. You can then use the output thrift1 with generator mstch_cpp2.
./build/bin/thrift1 --gen mstch_cpp2 --templates ./thrift/compiler/generate/templates --out /tmp/ ./thrift/example/if/chatroom.thrift
Ref https://github.com/facebook/fbthrift/issues/303

How to find OpenCV installed in /usr/local when building ROS node

I am using ROS Kinetic with OpenCV. I created a node that uses CUDA implemented algorithms of OpenCV (which are not available in the ros-kinetic-opencv3 package) so I compiled OpenCV from source with CUDA enabled and installed it in /usr/local.
To test if my /usr/local installation was working as expected (and if my code was correct) I created a program, outside of ROS, with the following CMakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(stereo_algorithms_testing)
set(ENV{OpenCV_DIR} "/usr/local")
find_package(OpenCV REQUIRED)
include_directories(include ${OpenCV_INCLUDE_DIRS})
add_executable(stereo_algorithms main.cpp)
target_link_libraries(stereo_algorithms ${OpenCV_LIBS})
When I run cmake ., I get the following output:
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found suitable exact version "8.0")
-- Found OpenCV: /usr/local (found version "3.2.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/degraw/Opencv_testing/stereo_algorithms/test
All is well, and the code runs as expected with no runtime errors.
Now when I use the same code in a ROS node I have the following CMakeList.txt:
cmake_minimum_required(VERSION 2.8.3)
project(depth_calculator)
set(ENV{OpenCV_DIR} "/usr/local")
find_package(OpenCV REQUIRED core highgui calib3d PATHS /usr/local NO_DEFAULT_PATH)
find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport)
catkin_package()
include_directories(include ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
add_executable(double_image_acq src/double_image_acquisition.cpp)
target_link_libraries(double_image_acq ${OpenCV_LIBS} ${catkin_LIBRARIES})
Notice that I explicitly tell cmake to only look for OpenCV in /usr/local.
The output of catkin_make is:
-- Using CATKIN_DEVEL_PREFIX: /home/degraw/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/degraw/catkin_ws/devel;/usr/local;/opt/ros/kinetic
-- This workspace overlays: /home/degraw/catkin_ws/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/degraw/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.6
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 2 packages in topological order:
-- ~~ - depth_calculator
-- ~~ - zed_wrapper
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'depth_calculator'
-- ==> add_subdirectory(depth_calculator)
-- Found OpenCV: /opt/ros/kinetic (found version "3.2.0") found components: core highgui calib3d
...
...
...
Running command: "make -j4 -l4" in "/home/degraw/catkin_ws/build"
[ 14%] Built target zed_wrapper_gencfg
[ 28%] Linking CXX executable /home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq
[ 57%] Built target ZEDWrapper
[ 85%] Built target zed_wrapper_node
CMakeFiles/double_image_acq.dir/src/double_image_acquisition.cpp.o: In function `OpencvDisparityCalculator::callback(boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&, boost::shared_ptr<sensor_msgs::Image_<std::allocator<void> > const> const&)':
double_image_acquisition.cpp:(.text._ZN25OpencvDisparityCalculator8callbackERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEES9_[_ZN25OpencvDisparityCalculator8callbackERKN5boost10shared_ptrIKN11sensor_msgs6Image_ISaIvEEEEES9_]+0x1ad): undefined reference to `cv::cuda::createStereoBM(int, int)'
collect2: error: ld returned 1 exit status
depth_calculator/CMakeFiles/double_image_acq.dir/build.make:175: recipe for target '/home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq' failed
make[2]: *** [/home/degraw/catkin_ws/devel/lib/depth_calculator/double_image_acq] Error 1
CMakeFiles/Makefile2:353: recipe for target 'depth_calculator/CMakeFiles/double_image_acq.dir/all' failed
make[1]: *** [depth_calculator/CMakeFiles/double_image_acq.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
Obviously it's a linker issue. It finds the wrong OpenCV (the ROS OpenCV) which does not include the libraries for CUDA.
How can I tell catkin_make to find the OpenCV in /usr/local?

How to install cvblob on ubuntu 12.04

I am trying to do blob detection in OpenCV on Ubuntu 12.04 system. I need to install cvblob library for this. So, i downloaded the zip file, extracted it and tried to run cmake. But everytime i run this
cmake . -DOpenCV_DIR=<directory path>
it shows the following error
bash: syntax error near unexpected token `newline'
and also the following error:
CMake Error: The source directory "/home/arvindnarayanan/Documents/cvblob" does not appear to contain CMakeLists.txt.
What do i do?
Both of your problems are essentially CMake issues, not cvblob issues.
Here is a full example how to compile cvblob on Ubuntu 12.04 LTS. It assumes OpenCV has been installed into the system successfully.
dev#dev:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.3 LTS"
dev#dev:~$
First get cvblob sources from http://cvblob.googlecode.com/files/cvblob-0.10.4-src.tgz (the location of latest version at the moment of writing) and untar the package:
dev#dev:~$ tar xzvf cvblob-0.10.4-src.tgz
cvblob/
cvblob/CMakeLists.txt
cvblob/CMakeScripts/
cvblob/CMakeScripts/Toolchain-mingw32.cmake
cvblob/COPYING
cvblob/COPYING.LESSER
cvblob/ChangeLog
cvblob/Doxyfile
cvblob/README
cvblob/contrib/
cvblob/contrib/cvBlobDLL/
cvblob/contrib/cvBlobDLL/README
cvblob/contrib/cvBlobDLL/TestDLL/
cvblob/contrib/cvBlobDLL/TestDLL/Debug/
cvblob/contrib/cvBlobDLL/TestDLL/ReadMe.txt
cvblob/contrib/cvBlobDLL/TestDLL/Release/
cvblob/contrib/cvBlobDLL/TestDLL/TestDLL.c
cvblob/contrib/cvBlobDLL/TestDLL/TestDLL.vcproj
cvblob/contrib/cvBlobDLL/TestDLL/imgout.png
cvblob/contrib/cvBlobDLL/TestDLL/stdafx.cpp
cvblob/contrib/cvBlobDLL/TestDLL/stdafx.h
cvblob/contrib/cvBlobDLL/TestDLL/targetver.h
cvblob/contrib/cvBlobDLL/TestDLL/test.png
cvblob/contrib/cvBlobDLL/cvblobDLL/
cvblob/contrib/cvBlobDLL/cvblobDLL/Debug/
cvblob/contrib/cvBlobDLL/cvblobDLL/Release/
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.h
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.sln
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.suo
cvblob/contrib/cvBlobDLL/cvblobDLL/cvblobDLL.vcproj
cvblob/contrib/cvBlobDLL/cvblobDLL/dllmain.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/stdafx.cpp
cvblob/contrib/cvBlobDLL/cvblobDLL/stdafx.h
cvblob/contrib/cvBlobDLL/cvblobDLL/targetver.h
cvblob/cvBlob/
cvblob/cvBlob/CMakeLists.txt
cvblob/cvBlob/cvaux.cpp
cvblob/cvBlob/cvblob.cpp
cvblob/cvBlob/cvblob.h
cvblob/cvBlob/cvcolor.cpp
cvblob/cvBlob/cvcontour.cpp
cvblob/cvBlob/cvlabel.cpp
cvblob/cvBlob/cvtrack.cpp
cvblob/cvBlobConfig.cmake.in
cvblob/cvblob.pc.cmake.in
cvblob/doc/
cvblob/samples/
cvblob/samples/Makefile
cvblob/samples/red_object_tracking.cpp
cvblob/samples/red_object_tracking.txt
cvblob/test/
cvblob/test/CMakeLists.txt
cvblob/test/EnterExitCrossingPaths2front_blobs.mpeg
cvblob/test/EnterExitCrossingPaths2front_blobs.txt
cvblob/test/test.cpp
cvblob/test/test.png
cvblob/test/test_random.cpp
cvblob/test/test_tracking.cpp
dev#dev:~$
As you can see there is cvblob/CMakeLists.txt that is required by CMake. You get the second error because you're saying to CMake to look from wrong directory:
dev#dev:~$ cmake .
CMake Error: The source directory "/home/dev" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
dev#dev:~$
You get the first error because you didn't realize that <directory path> is a placeholder text you're supposed to replace with a real directory path:
dev#dev:~$ cmake . -DOpenCV_DIR=<directory path>
bash: syntax error near unexpected token `newline'
dev#dev:~$
Instead you should have written:
dev#dev:~$ cmake . -DOpenCV_DIR=/usr/local/
Where /usr/local/ is a real and correct path in your system.
So how to build the library correctly ?
dev#dev:~$ cd cvblob/
dev#dev:~/cvblob$ mkdir build
dev#dev:~/cvblob$ cd build
dev#dev:~/cvblob/build$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
running mkdir -p "/home/dev/cvblob/build/unix-install/" 2>&1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dev/cvblob/build
dev#dev:~/cvblob/build$ make
Scanning dependencies of target cvblob
[ 11%] Building CXX object lib/CMakeFiles/cvblob.dir/cvblob.o
[ 22%] Building CXX object lib/CMakeFiles/cvblob.dir/cvlabel.o
[ 33%] Building CXX object lib/CMakeFiles/cvblob.dir/cvaux.o
[ 44%] Building CXX object lib/CMakeFiles/cvblob.dir/cvcontour.o
[ 55%] Building CXX object lib/CMakeFiles/cvblob.dir/cvtrack.o
[ 66%] Building CXX object lib/CMakeFiles/cvblob.dir/cvcolor.o
Linking CXX shared library libcvblob.so
[ 66%] Built target cvblob
Scanning dependencies of target test
[ 77%] Building CXX object test/CMakeFiles/test.dir/test.o
Linking CXX executable ../bin/test
[ 77%] Built target test
Scanning dependencies of target test_random
[ 88%] Building CXX object test/CMakeFiles/test_random.dir/test_random.o
Linking CXX executable ../bin/test_random
[ 88%] Built target test_random
Scanning dependencies of target test_tracking
[100%] Building CXX object test/CMakeFiles/test_tracking.dir/test_tracking.o
Linking CXX executable ../bin/test_tracking
[100%] Built target test_tracking
dev#dev:~/cvblob/build$ sudo make install
[sudo] password for dev:
[ 66%] Built target cvblob
[ 77%] Built target test
[ 88%] Built target test_random
[100%] Built target test_tracking
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/share/cvblob/cvBlobConfig.cmake
-- Installing: /usr/local/lib/pkgconfig/cvblob.pc
-- Installing: /usr/local/include/cvblob.h
-- Installing: /usr/local/lib/libcvblob.so
-- Removed runtime path from "/usr/local/lib/libcvblob.so"
dev#dev:~/cvblob/build$
you can try this url to download source for installation of cvblob
http://code.google.com/p/cvblob/downloads/detail?name=cvblob-0.10.4-src.tgz&can=2&q=
you required the support of cmake & make

Compile OpenCV without GPU?

I've just run cmake -D CMAKE_BUILD_TYPE=RELEASE .. from OpenCV/build, and got in my output:
-- OpenCV modules:
-- To be built: core imgproc flann highgui features2d calib3d ml video
objdetect contrib nonfree gpu legacy photo python
stitching ts videostab
-- Disabled: -
-- Disabled by dependency: -
-- Unavailable: androidcamera java world
The thing is, compilation with gpu fails, maybe because my machine doesn't have one? (It's an EC2 instance).
make fails with an odd error:
Scanning dependencies of target opencv_test_gpu
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_gpumat.cpp.o
[ 72%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/utility.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_filters.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_copy_make_border.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/main.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_threshold.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_video.cpp.o
[ 73%] Building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
make[2]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o] Error 4
make[1]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/all] Error 2
make: *** [all] Error 2
I've tried using the flag -DOPENCV_MODULES_DISABLED_USER="gpu" but that produces weird output with gpu listed as to be built and disabled.
-- OpenCV modules:
-- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree gpu legacy photo python stitching ts videostab
-- Disabled: gpu
-- Disabled by dependency: -
-- Unavailable: androidcamera java world
How do I compile without gpu?
To disable building a specific module, use
-D BUILD_opencv_{modulename}=OFF
In this case, use
-D BUILD_opencv_gpu=OFF
Try to add -D WITH_CUDA=OFF to your cmake command line.
For OpenCV 2.4.11 on EC2, I had to include both -D BUILD_opencv_gpu=OFF and -D WITH_CUDA=OFF. I also included -D WITH_1394=OFF to avoid a warning in python. So:
cd opencv-2.4.11/
mkdir release
cd release/
cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
This is caused by not having enough memory with your EC2 instance. I got a similar error (different module) with an EC2/Micro running Ubuntu 12.10, but it was smooth sailing on an EC2/Small.
The real question is , your device run out off memory.
This happens when gcc don't have enough memory. Trust me, since I had the same problem.
Had the same problem. It's a memory issue; increasing the swap space fixed it for me. Open a terminal and enter this:
free
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
free
Then proceed with your make.
Source
I have fixed this particular problem in a most horrible way:
touch modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o
make
Compilation then completes ok. This isn't really a solution though, so I'd like to know if there's a proper fix.

Unable to install opencv using brew?

I've just updated my Mac to Mountain Lion and XCode to ver4.4
Several issues which revolve around unable to resolve #include cropped up. So I decided to remove and reinstall both my python and opencv libs using Homebrew.
However after installing Python, I met errors while installing opencv using home-brew.
Does anyone know how to resolve this issue ?
Attached is the output log from running
brew install -v opencv
/usr/bin/env python -c import numpy
==> Downloading http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2
Already downloaded: /Library/Caches/Homebrew/opencv-2.4.2.tar.bz2
/usr/bin/tar xf /Library/Caches/Homebrew/opencv-2.4.2.tar.bz2
==> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.2 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev -DPYTHON_LIBRARY='/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python' -DPYTHON_INCLUDE_DIR='/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Headers' -DPYTHON_PACKAGES_PATH='/usr/local/Cellar/opencv/2.4.2/lib/python2.7/site-packages'
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.2 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev -DPYTHON_LIBRARY='/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python' -DPYTHON_INCLUDE_DIR='/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Headers' -DPYTHON_PACKAGES_PATH='/usr/local/Cellar/opencv/2.4.2/lib/python2.7/site-packages'
-- The CXX compiler identification is Clang 4.0.0
-- The C compiler identification is Clang 4.0.0
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Extracting svn version, please wait...
-- SVNVERSION: exported
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Performing Test HAVE_C_WNO_ATTRIBUTES
-- Performing Test HAVE_C_WNO_ATTRIBUTES - Success
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES
-- Performing Test HAVE_C_WNO_STRICT_PROTOTYPES - Success
-- Performing Test HAVE_C_WNO_MISSING_PROTOTYPES
-- Performing Test HAVE_C_WNO_MISSING_PROTOTYPES - Success
-- Performing Test HAVE_C_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_C_WNO_MISSING_DECLARATIONS - Success
-- Looking for assert.h
-- Looking for assert.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for io.h
-- Looking for io.h - not found
-- Looking for jbg_newlen
-- Looking for jbg_newlen - not found
-- Looking for mmap
-- Looking for mmap - found
-- Looking for search.h
-- Looking for search.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Performing Test HAVE_C_WNO_UNUSED_BUT_SET_VARIABLE
-- Performing Test HAVE_C_WNO_UNUSED_BUT_SET_VARIABLE - Success
-- Performing Test HAVE_C_WNO_UNDEF
-- Performing Test HAVE_C_WNO_UNDEF - Success
-- Performing Test HAVE_C_WNO_UNUSED
-- Performing Test HAVE_C_WNO_UNUSED - Success
-- Performing Test HAVE_C_WNO_SIGN_COMPARE
-- Performing Test HAVE_C_WNO_SIGN_COMPARE - Success
-- Performing Test HAVE_C_WNO_CAST_ALIGN
-- Performing Test HAVE_C_WNO_CAST_ALIGN - Success
-- Performing Test HAVE_C_WNO_SHADOW
-- Performing Test HAVE_C_WNO_SHADOW - Success
-- Performing Test HAVE_C_WNO_MAYBE_UNINITIALIZED
-- Performing Test HAVE_C_WNO_MAYBE_UNINITIALIZED - Success
-- Performing Test HAVE_C_WNO_POINTER_TO_INT_CAST
-- Performing Test HAVE_C_WNO_POINTER_TO_INT_CAST - Success
-- Performing Test HAVE_C_WNO_INT_TO_POINTER_CAST
-- Performing Test HAVE_C_WNO_INT_TO_POINTER_CAST - Success
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER
-- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER - Success
-- Performing Test HAVE_C_WNO_IMPLICIT_FUNCTION_DECLARATION
-- Performing Test HAVE_C_WNO_IMPLICIT_FUNCTION_DECLARATION - Success
-- Performing Test HAVE_C_WNO_UNINITIALIZED
-- Performing Test HAVE_C_WNO_UNINITIALIZED - Success
-- checking for module 'libdc1394-2'
-- package 'libdc1394-2' not found
-- checking for module 'libdc1394'
-- package 'libdc1394' not found
-- checking for module 'libavcodec'
-- package 'libavcodec' not found
-- checking for module 'libavformat'
-- package 'libavformat' not found
-- checking for module 'libavutil'
-- package 'libavutil' not found
-- checking for module 'libswscale'
-- package 'libswscale' not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - not found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Found CUDA: /usr/local/cuda (found suitable version "4.1", required is "4.1")
-- CUDA detected: 4.1
-- CUDA NVCC target flags: -gencode;arch=compute_11,code=sm_11;-gencode;arch=compute_12,code=sm_12;-gencode;arch=compute_13,code=sm_13;-gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_20,code=compute_20
-- Found PythonInterp: /usr/local/bin/python2 (found suitable version "2.7.3", required is "2.0")
-- Found PythonLibs: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python (found suitable version "2.7.3", required is "2.7.3")
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sphinx
-- Performing Test HAVE_CXX_WNO_UNDEF
-- Performing Test HAVE_CXX_WNO_UNDEF - Success
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success
--
-- General configuration for OpenCV 2.4.2 =====================================
--
-- Platform:
-- Host: Darwin 12.0.0 i386
-- CMake: 2.8.8
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: None
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/clang++
-- C++ flags (Release): -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -O3 -DNDEBUG
-- C++ flags (Debug): -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -g
-- C Compiler: /usr/bin/clang
-- C flags (Release): -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -O3 -DNDEBUG
-- C flags (Debug): -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -g
-- Linker flags (Release): -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib
-- Linker flags (Debug): -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib
-- Precompiled headers: NO
--
-- OpenCV modules:
-- To be built: core imgproc flann highgui features2d calib3d ml video objdetect contrib nonfree gpu legacy photo python stitching ts videostab
-- Disabled: -
-- Disabled by dependency: -
-- Unavailable: androidcamera java world
--
-- GUI:
-- QT 4.x: NO
-- Cocoa: YES
-- OpenGL support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.2.6)
-- JPEG: build (ver 62)
-- PNG: build (ver 1.5.9)
-- TIFF: build (ver 42 - 4.0.1)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: NO
-- FFMPEG: NO
-- codec: NO
-- format: NO
-- util: NO
-- swscale: NO
-- gentoo-style: NO
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- PvAPI: NO
-- QuickTime: NO
-- QTKit: YES
--
-- Other third-party libraries:
-- Use IPP: NO
-- Use TBB: NO
-- Use Cuda: YES (ver 4.1)
-- Use Eigen: NO
--
-- NVIDIA CUDA: (ver 4.1)
-- Use CUFFT: YES
-- Use CUBLAS: NO
-- NVIDIA GPU arch: 11 12 13 20 21
-- NVIDIA PTX archs: 11 12 13 20 21
-- NVIDIA GPU features: 11 12 13 20 20 20
--
-- Python:
-- Interpreter: /usr/local/bin/python2 (ver 2.7.3)
-- Libraries: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Python (ver 2.7.3)
-- numpy: /Library/Python/2.7/site-packages/numpy/core/include (ver 1.6.2)
-- packages path: /usr/local/Cellar/opencv/2.4.2/lib/python2.7/site-packages
--
-- Documentation:
-- Build Documentation: NO
-- Sphinx: NO
-- PdfLaTeX compiler: /usr/texbin/pdflatex
--
-- Tests and samples:
-- Tests: YES
-- Performance tests: YES
-- Examples: NO
--
-- Install path: /usr/local/Cellar/opencv/2.4.2
--
-- cvconfig.h is in: /tmp/homebrew-opencv-2.4.2-3DWY/OpenCV-2.4.2
-- -----------------------------------------------------------------
--
CMake Warning at CMakeLists.txt:785 (message):
The source directory is the same as binary directory. "make clean" may
damage the source tree
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/homebrew-opencv-2.4.2-3DWY/OpenCV-2.4.2
==> make
make
Scanning dependencies of target zlib
Scanning dependencies of target libjpeg
[ 0%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.o
[ 0%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcapimin.c.o
[ 0%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/compress.c.o
[ 0%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcapistd.c.o
[ 0%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/crc32.c.o
[ 1%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jccoefct.c.o
[ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/deflate.c.o
[ 1%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jccolor.c.o
[ 1%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcdctmgr.c.o
[ 1%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jchuff.c.o
[ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzclose.c.o
[ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzlib.c.o
[ 1%] [ 1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzread.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcinit.c.o
[ 1%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcmainct.c.o
[ 2%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzwrite.c.o
[ 2%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcmarker.c.o
[ 2%] [ 2%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inflate.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcmaster.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcomapi.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcparam.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcphuff.c.o
[ 3%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/infback.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcprepct.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jcsample.c.o
[ 3%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inftrees.c.o
[ 3%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inffast.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jctrans.c.o
[ 3%] [ 3%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/trees.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdapimin.c.o
[ 3%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdapistd.c.o
[ 4%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdatadst.c.o
[ 4%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/uncompr.c.o
[ 4%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdatasrc.c.o
[ 5%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/zutil.c.o
[ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdcoefct.c.o
Linking C static library ../lib/libzlib.a
[ 5%] Built target zlib
Scanning dependencies of target libjasper
[ 5%] [ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdcolor.c.o
Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_cm.c.o
[ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jddctmgr.c.o
[ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdhuff.c.o
[ 5%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_debug.c.o
[ 5%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_getopt.c.o
[ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdinput.c.o
[ 5%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_icc.c.o
[ 5%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdmainct.c.o
[ 6%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdmarker.c.o
[ 6%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_iccdata.c.o
[ 6%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_image.c.o
[ 6%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdmaster.c.o
[ 6%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdmerge.c.o
[ 6%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdphuff.c.o
[ 6%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_init.c.o
[ 6%] [ 7%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdpostct.c.o
Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_malloc.c.o
[ 7%] [ 7%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_seq.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdsample.c.o
[ 7%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jdtrans.c.o
[ 7%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_stream.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jerror.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jfdctflt.c.o
[ 8%] [ 8%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_string.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jfdctfst.c.o
[ 8%] [ 8%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_tmr.c.o
Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jfdctint.c.o
[ 8%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_tvp.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jidctflt.c.o
[ 8%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jas_version.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jidctfst.c.o
[ 8%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jp2_cod.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jidctint.c.o
[ 8%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jidctred.c.o
[ 9%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jp2_dec.c.o
[ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jmemansi.c.o
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jp2_enc.c.o
[ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jmemmgr.c.o
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_bs.c.o
[ 10%] [ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jquant1.c.o
Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_cs.c.o
[ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jquant2.c.o
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_dec.c.o
[ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/jutils.c.o
[ 10%] Building C object 3rdparty/libjpeg/CMakeFiles/libjpeg.dir/transupp.c.o
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_enc.c.o
Linking C static library ../lib/liblibjpeg.a
[ 10%] Built target libjpeg
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_math.c.o
[ 10%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_mct.c.o
[ 11%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_mqcod.c.o
[ 11%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_mqdec.c.o
[ 11%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_mqenc.c.o
Scanning dependencies of target libpng
[ 11%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/png.c.o
[ 11%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_qmfb.c.o
[ 11%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngerror.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngget.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngmem.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngpread.c.o
[ 12%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t1cod.c.o
[ 12%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t1dec.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngread.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngrio.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngrtran.c.o
[ 12%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t1enc.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngrutil.c.o
[ 12%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t2cod.c.o
[ 12%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngset.c.o
[ 13%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t2dec.c.o
[ 13%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_t2enc.c.o
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngtest.c.o
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngtrans.c.o
[ 14%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_tagtree.c.o
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngwio.c.o
[ 14%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_tsfb.c.o
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngwrite.c.o
[ 14%] Building C object 3rdparty/libjasper/CMakeFiles/libjasper.dir/jpc_util.c.o
Linking C static library ../lib/liblibjasper.a
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngwtran.c.o
[ 14%] Built target libjasper
[ 14%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_matrix_operations.cu.o
[ 14%] Building C object 3rdparty/libpng/CMakeFiles/libpng.dir/pngwutil.c.o
/tmp/homebrew-opencv-2.4.2-3DWY/OpenCV-2.4.2/modules/core/src/cuda/matrix_operations.cu:0: error: bad value (native) for -march= switch
/tmp/homebrew-opencv-2.4.2-3DWY/OpenCV-2.4.2/modules/core/src/cuda/matrix_operations.cu:0: error: bad value (native) for -mtune= switch
CMake Error at cuda_compile_generated_matrix_operations.cu.o.cmake:200 (message):
Error generating
/tmp/homebrew-opencv-2.4.2-3DWY/OpenCV-2.4.2/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_matrix_operations.cu.o
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_matrix_operations.cu.o] Error 1
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking C static library ../lib/liblibpng.a
[ 14%] Built target libpng
make: *** [all] Error 2
==> Exit Status: 2
https://github.com/mxcl/master/blob/master/Library/Formula/opencv.rb#L70
==> Build Environment
HOMEBREW_VERSION: 0.9.2
HEAD: 92393f1526b443e86b78629fae795eb4d8e3a6a5
CPU: dual-core 64-bit penryn
OS X: 10.8-x86_64
Xcode: 4.4
CLT: 4.4.0.0.1.1249367152
X11: 2.7.2 # /opt/X11
CC: /usr/bin/clang
CXX: /usr/bin/clang++ => /usr/bin/clang
LD: /usr/bin/clang
CFLAGS: -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8
CXXFLAGS: -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8
CPPFLAGS: -I/usr/local/Cellar/gettext/0.18.1.1/include -isystem /usr/local/include
LDFLAGS: -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib
MACOSX_DEPLOYMENT_TARGET: 10.8
MAKEFLAGS: -j2
Error: Failed executing: make (opencv.rb:70)
These existing issues may help you:
https://github.com/mxcl/homebrew/issues/13603
Otherwise, this may help you fix or report the issue:
https://github.com/mxcl/homebrew/wiki/bug-fixing-checklist
It looked like that the problem came from the compiler flag -march=native.
My solution was to edit opencv's homebrew recipe to override the compile flags.
brew edit opencv
Just add the following statements near the end of `def install' section
args << "-DCMAKE_CXX_FLAGS='-Os -w -pipe -Qunused-arguments -mmacosx-version-min=10.8'"
args << "-DCMAKE_C_FLAGS='-Os -w -pipe -Qunused-arguments -mmacosx-version-min=10.8'"
right before
system 'cmake', '.', *args
system "make"
system "make install"

Resources