Compiled .NET assembly cannot start parpool if run from "Program Files" directory as non-administrator (Windows 10, Matlab 2017b)

3 次查看(过去 30 天)
Hi. We are using Matlab 2017b on a Windows 10 desktop, with parallel computing toolbox and its "parfor" function.
We have written a *.m file and compiled it into a .NET assembly "parforfunction.dll/etc." using Matlab complier.
Then the assembly is used in a C# project (Visual Studio 2017) and compiled into a standalone application "prj.exe".
What we found is that, if "prj.exe" is executed from "C:\Program Files\<>" (our default install path), it always fails to start the parallel pool (parpool).
Alternatively, parpool can be started successfully in either cases below:
  1. "prj.exe" is executed from "C:\Program Files\<>" as Administrator;
  2. "prj.exe" is executed from a directory other than "C:\Program Files\<>". E.g., C:\project\.
However, if we package a *.m file into a standalone application using Matlab compiler "prj2.exe", and execute it from "C:\Program Files\<>", it can start parpool successfully, even without administrator privilege.
This code must be deployed as .NET assembly, and we cannot require users to run as Administrator. Does anyone know a workaround for the above issue ?
Below are console message when running "prj.exe" from "C:\Program Files\<>".
Starting parallel pool (parpool) using the 'local' profile ...
Warning: Unable to write to requested folder 'C:\Users\<name>\AppData\Local\Temp\<name>\mcrCache9.3\<>project name>\local_cluster_jobs\R2017b'. Perhaps you do not have the correct access permissions. You will be unable to store any job and tasks here.
> In parallel.internal.cluster.FileStorage>iDirectoryIsReadOnly (line 1149)
In parallel.internal.cluster.FileStorage (line 102)
In parallel.internal.cluster.FileStorage.createFileStorage (line 127)
In parallel.cluster.CJSCluster (line 543)
In parallel.cluster.Local (line 366)
In parcluster (line 54)
In parallel.internal.pool.argumentsParser>iGetClusterAndNumWorkers (line 128)
In parallel.internal.pool.argumentsParser (line 48)
In parallel.internal.pool.doParpool (line 13)
In parpool (line 98)
In parallel.internal.pool.PoolArrayManager.getOrAutoCreateWithCleanup (line 60)
In pctTryCreatePoolIfNecessary (line 23)
In distcomp.remoteparfor.tryRemoteParfor
In parallel_function
In testParallelExample (line 3)

回答(1 个)

Prasad Parameswaran
Prasad Parameswaran 2019-10-21
This issue is due a bug with multiple MATLAB Compiler Rintime(MCR) contexts and has been fixed in R2019b.
The possible workarounds are:
  1. Compile all the MATLAB code in a single .NET assembly to avoid multiple MCR contexts.
  2. Replace "FileStorage.m" file in "%MATLABROOT%\toolbox\distcomp\cluster\+parallel\+internal\+cluster\" with the "FileStorage.m" found in the link https://customerartifacts.mathworks.com/SalesForce/IN/03707478/outgoing/FixedVersion/FileStorage.m and recompile.

类别

Help CenterFile Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by