Matlab Distributed Computing Server(MDC​S)クラスター上での​mexコンパイルは可​能でしょうか?

2 vues (au cours des 30 derniers jours)
c0maru
c0maru le 15 Mai 2018
Modifié(e) : c0maru le 4 Déc 2018
[環境]
  • クラスターノードのOS: CentOS7.5
  • クラスターノードのMDCSバージョン: R2018a
  • クラスターノードのgccのバージョン: 4.8.5 20150623
  • クラスターノードのnvccのバージョン: 9.0.176
上記クラスターで、Parallel Command Windowを開き、mexおよびmexcudaコマンドを実行すると、次の様な出力が表示されます。
mex実行時
>> mex -compatibleArrayDims test.c
Error using mex
No supported compiler was found. For options, visit
https://www.mathworks.com/support/compilers.
mexcuda実行時
>> mexcuda -largeArrayDims mexMPmuFEAT.cu
Warning: Version 9.0 of the CUDA toolkit could not be found. If installed, set
MW_NVCC_PATH environment variable to location of nvcc compiler.
> In mexcuda (line 157)
Error using mex
No supported compiler was found. For options, visit
https://www.mathworks.com/support/compilers.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
getenv('MW_NVCC_PATH')実行時
>> getenv('MW_NVCC_PATH')
ans =
'/usr/local/cuda/bin'
一方、ローカルのデスクトップ(iMac, macOS)でParallel Command Windowを開き、ワーカー上でmexコマンドを実行した場合は、コンパイルを実行することができました。(mexcudaについては、iMacにNvidia製GPUが搭載されていないため、調査できてません)
上記のことから、MATLABワーカー上でmexコンパイルを実行すること自体は可能である様に見えますので、問題は原因は次の3つのいずれかではないかと考えています。
  • MDCSワーカー上では、そもそもmexコンパイルを実行できない
  • MDCSワーカー上でmexコンパイルを行うためには、特殊な設定が必要(主にパス周り)
  • MDCSのノードとなっているLinuxサーバーのコンパイラーのバージョンがMATLAB2018aに合っていない(nexcudaのエラー出力を見る限り、コンパイラーのバージョンは合っていそうですが...)
上記の様なMDCSクラスター上でのmexコンパイルは可能でしょうか?
  1 commentaire
c0maru
c0maru le 4 Déc 2018
Modifié(e) : c0maru le 4 Déc 2018
回答してくださった皆様、最終的な調査結果をアップロードするのが遅れてしまい申し訳ありません。
Mathworksのサポートの元調査した結果、以下の原因が判明しました。
・MATLABは環境変数"SHELL"を元に、systemコマンド実行用のシェルを探している
・今回のクラスターノードでは、MDCSをsystemdで起動していたが、この状態で環境変数"SHELL"をgetenvで取得すると、”%SHELL%”という値だけが返ってくる。このため、MDCSからsystemコマンドを実行すると、シェルを探す段階でエラー127が発生していた。
このため、MDCS用のsystemd unitファイル内で環境変数SHELLを明示的に指定することで、systemコマンドやmexが問題なく実行できることを確認しました。
様々なアドバイスをいただきありがとうございました。
最も近い回答を書いていただいていた、Kojiro Saito さんの回答を採用させていただき、この質問をクローズしたいと思います。

Connectez-vous pour commenter.

Réponse acceptée

Kojiro Saito
Kojiro Saito le 23 Mai 2018
mex及びmexcudaをMDCSで実行した際のエラー(No supported compiler was found)については、MDCS上での環境変数のPATHにgccのパスが無いためと思われます。
まず、CentOS 7の MATLABデスクトップ 上で以下のコマンドを実行して、gccのパスを確認してみてください。
!which gcc
ここでリターンされるgccのパス(例えば/usr/bin/gcc)がMDCS上にあるか確認してください。MATLABでMDCSのクラスタープロファイルがデフォルトになっている状態で、pmode openでParallel Command Windowを立ち上げ、
getenv('PATH')
または
!echo $PATH
でMDCSから見れている環境変数PATHが確認できます。gccがあるパス(例えば/usr/bin)がこの中にあるか確認してください。LinuxにログインしてからMATLABデスクトップを立ち上げると、ユーザー個別に設定したパスが~/.bashrcや~/.loginが読み取られますが、MDCS上からではそれが見えていない可能性がありますので、その場合はParallel Command Window上からsetenvでパスを追加できます。例えば、/workを追加する場合は
setenv('PATH', [getenv('PATH') ':/work']);
のように行います。setenvでgccのパスを追加してから、再度mexとmexcudaを試してみてください。
また、 MDCSからunixまたはsystemコマンドは実行できます 。MDCSワーカーのカレントディレクトリがワーカー毎に作られるディレクトリになります。Parallel Command Windowで以下のコマンドを実行すると、
unix('pwd')
/var/lib/mdce/ホスト名_ホスト名_worker01_mlworker_log/matlab/work のように出力されます。 このディレクトリは通常空ディレクトリですので、 unix('ls')
を実行しても何もファイルが表示されません。どこかファイルがあるディレクトリに対してlsを実行してみてください。例えば、
unix('ls /tmp')
  8 commentaires
c0maru
c0maru le 29 Mai 2018
Modifié(e) : c0maru le 29 Mai 2018
返信が遅れました。
以下が実行結果になります。(ちょうど互換性レイヤー無しで動くC++ファイルを作成したところでしたので、それでテストしています)
Linux ターミナル上での実行結果
which g++
/usr/bin/g++
ls -l /usr/bin/g++
-rwxr-xr-x. 4 root root 772688 Apr 10 15:03 /usr/bin/g++
MDCSのParallel Command Windowでの実行結果
mex -v GXX='/usr/bin/g++' XrandSeq.cpp
Verbose mode is on.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...No.
Did not find installed compiler 'g++'.
Error using mex
No supported compiler was found. For options, visit
https://www.mathworks.com/support/compilers.
"MEX options file(g++_glnxa64.xml等)"が読めないために、コマンドが実施できないという事でしょうかね。確かに、"MEX options file"はMDCSのインストールディレクトリ配下に存在しますが、システムの全ユーザーに読み取り権限を与えているので、権限的には読めるはずなのですが...。
Kojiro Saito
Kojiro Saito le 29 Mai 2018
Parallel Command Windowで下記のコマンドを実行してmexのコンパイラーのセットアップをしてみてはいかがでしょうか?
mex -setup C++

Connectez-vous pour commenter.

Plus de réponses (1)

Gowtham Uma Maheswari Jaganathan
Please be aware that CentOS is not one of the officially supported versions of OS for MATLAB to run.
Error using mex
No supported compiler was found. For options, visit
https://www.mathworks.com/support/compilers.
The above error message indicates that you do not have any compiler that is supported by MATLAB installed on your machine or it is not on path. For more information refer the pages below:
>> mexcuda -largeArrayDims mexMPmuFEAT.cu
Warning: Version 9.0 of the CUDA toolkit could not be found. If installed, set
MW_NVCC_PATH environment variable to location of nvcc compiler.
> In mexcuda (line 157)
Error using mex
No supported compiler was found. For options, visit
https://www.mathworks.com/support/compilers.
Error in mexcuda (line 157)
[varargout{1:nargout}] = mex(mexArguments{:});
This indicates that NVCC path is not pointing to 9.0 CUDA SDK. From the looks of the output doesn't look like the path is set correctly.
  1 commentaire
c0maru
c0maru le 23 Mai 2018
Sorry for late reply.
I have tested "mex" and "mexcuda" command on a CentOS7 workstation which has same compilers(gcc & nvcc) and MATLAB Desktop Application. In this situation, MATLAB can compile some source codes with no error. (However, some warnings appears like, "gcc 4.x was not supported compiler, please use gcc 6.x ...")
Then, I have tested "unix" command on MDCS, and I have noticed that I can't use any unix command on MDCS. Additionally, MDCS doesn't have any Linux system PATH. (ex. I can use "cd" command and "dir" command, but can't use "ls" and "unix(ls)" command. "ls" isn't MATLAB command, so I can't use it.)
So, I think that we can't use "mex" on MDCS because MDCS can't use unix commands including "gcc & nvcc".
So, I will use a Linux workstation to compile some source codes, and use its outputs on MDCS.
Thanks.

Connectez-vous pour commenter.

Catégories

En savoir plus sur GPU 計算 dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!