BLAS(Basic Linear Algebra Subprograms)は,行列演算,ベクトル演算の機能をもったプログラム群である.
Windows で,OpenBLAS をソースコードからビルドしてインストールする. このとき, FORTRAN は使わないように設定してインストールする
【目次】
【Windows での OpenBLAS のインストール(サイト内のページ)】
複数の方法がある.方法を問わない場合には,Build Tools for Visual Studio を利用するのが簡単である.
【サイト内の関連ページ】
謝辞
OpenBLAS の作者に感謝します
BLAS の主な機能(ごく一部を紹介)
Windows での Visual Studio Community 2022 のインストール: 別ページ »で説明
Visual Studio Community 2022 に, Build Tools for Visual Studio 2022の機能が含まれている.
Windows での Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明
【関連する外部ページ】
Windows での Git のインストール: 別ページ »で説明
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
Windows での cmake のインストール: 別ページ »で説明
【関連する外部ページ】
cmake の公式ダウンロードページ: https://cmake.org/download/
【関連する外部ページ】 https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide
前もって,OpenBLAS をインストールするディレクトリを決めておく
このページでは,c:\OpenBLAS 下にインストールするものとして説明する.
必ず、最新情報を確認すること
C: cd %HOMEPATH% rmdir /s /q OpenBLAS
cd %HOMEPATH% git clone --recursive https://github.com/xianyi/OpenBLAS.git
https://github.com/xianyi/OpenBLAS/wiki/Installation-Guide の記述を参考にした.
cd %HOMEPATH% cd OpenBLAS rmdir /s /q build mkdir build cd build del CMakeCache.txt cmake .. -G "Visual Studio 17 2022" -A x64 -T host=x64 ^ -DNOFORTRAN=ON ^ -DDYNAMIC_ARCH=OFF ^ -DCMAKE_INSTALL_PREFIX="c:/OpenBLAS" ^ -DCMAKE_BUILD_TYPE=Release
エラーメッセージが出なければ OK.
終わるまでしばらく待つ
cmake --build . --config RELEASE cmake --build . --config RELEASE --target INSTALL
エラーメッセージが出なければ OK.
dir C:\OpenBLAS dir C:\OpenBLAS\include dir C:\OpenBLAS\lib
call powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";C:\OpenBLAS\lib\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
これは OpenCV のビルドのときに利用される環境変数
call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS\", \"C:\OpenBLAS\", \"Machine\")" call powershell -command "[System.Environment]::SetEnvironmentVariable(\"OpenBLAS_ROOT\", \"C:\OpenBLAS\", \"Machine\")"
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用
Windows での確認手順と結果は次の通り
https://gist.github.com/xianyi/6930656 に掲載の プログラムを利用. hoge.cのようなファイル名で保存.
cl /I"C:\OpenBLAS\include\openblas" hoge.c /link /LIBPATH:"C:\OpenBLAS\lib" openblas.lib .\hoge.exe
eig_lapack.c を使用
Windows での確認手順と結果は次の通り
eig_lapack.c を使用
cl /I"C:\OpenBLAS\include\openblas" eig_lapack.c /link /LIBPATH:"C:\OpenBLAS\lib" openblas.lib .\eig_lapack.exe