LoginSignup
10
10

More than 5 years have passed since last update.

Mac OS に CUDAサポート付きで OpenCV をインストールする

Last updated at Posted at 2015-08-03

普通にインストールするなら、以下のようにする。参考ページ

brew tap homebrew/science
brew install opencv

NvidiaのGPUが使えるなら、GPUで処理を高速化できるかもしれないと思い以下の環境で試しました。
スクリーンショット 2015-08-03 13.34.16.png

OpenCVをインストールする前に、CUDA Toolkitをインストールします。CUDA 7をインストールしました。

次に、OpenCVをインストールします。オプション --with-cuda を付けます。
(これを書いた時点では OpevCV 2.4.11がインストールされた)

brew install opencv --with-cuda

インストールはうまくいったようですが、プロジェクトをビルドすると、リンクで以下のエラーになりました。

Undefined symbols for architecture x86_64

このページを参考にして、CMakeLists.txtに以下の行を追加したところ、ビルドが成功しました。

set (CMAKE_CXX_FLAGS "-stdlib=libstdc++")

以下のコードを実行します。

std::cout << "GPU device count = " << cv::gpu::getCudaEnabledDeviceCount() << std::endl;

うまく行ったようです。

GPU device count = 1
10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10