Matlab 编译器和启动脚本
Matlab Compiler and Startup script
所以我正在尝试使用 Matlab 编译器来构建一个独立的应用程序,该应用程序可以 运行 在使用 MCR 的单独机器上。实际应用遵循这个guide to benchmark GPU. When I open matlab following this我做了以下命令:
mcc -mv -o gpuTest mainBench.m benchFcn.m executeBenchmarks.m getData.m paralleldemo_gpu_backslash.m timeSolve.m waitForCpu.m waitForGpu.m
输出为:
Compiler version: 5.1 (R2014a)
Dependency analysis by REQUIREMENTS.
Parsing file "/media/hdd/work/matlab/gpuBench/mainBench.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/benchFcn.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/executeBenchmarks.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/getData.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/paralleldemo_gpu_backslash.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/timeSolve.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForCpu.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForGpu.m"
(Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/deployprint.m"
(Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/printdlg.m"
(Referenced from: "Compiler Command Line").
比起在其他机器上,鉴于设置了环境变量我只是执行命令
./gpuTest
产生的错误是:
Cannot CD to /media/hdd/work/matlab (Name is nonexistent or not a directory).
Error in startup (line 1)
问题是没有 "startup" 本应编译的脚本。但是我确实有一个 "startup.m" 脚本,它在我的启动文件夹中,实际上它正好执行 "cd /media/hdd/work/matlab" 和其他一些东西。
我有两个问题:
- 为什么它还要编译我的启动脚本?
- 如何解决此问题以仅执行主脚本?
将您的启动脚本更改为:
if ~isdeployed
cd /media/hdd/work/matlab
end
为什么 - 我真的不知道 - 我猜是这样你可以初始化一些东西但它不是我曾经使用过的 "feature"....
回答你的两个问题:
- 它正在编译您的
startup.m
脚本,以确保您的主脚本 运行 与您的常规 MATLAB 会话中的脚本完全相同。您会发现它还包括许多其他需要的东西,例如您的首选项文件夹,再次需要它来确保它 运行 与在常规 MATLAB 会话中所做的相同。
- @matlabgui 已经提供了类似的答案,即在您的启动脚本中应用
isdeployed
以阻止部署版本中您不想 运行 的任何内容。就个人而言,我通常将以下内容放在启动脚本的顶部,以阻止所有内容。
startup.m
if isdeployed
return
end
所以我正在尝试使用 Matlab 编译器来构建一个独立的应用程序,该应用程序可以 运行 在使用 MCR 的单独机器上。实际应用遵循这个guide to benchmark GPU. When I open matlab following this我做了以下命令:
mcc -mv -o gpuTest mainBench.m benchFcn.m executeBenchmarks.m getData.m paralleldemo_gpu_backslash.m timeSolve.m waitForCpu.m waitForGpu.m
输出为:
Compiler version: 5.1 (R2014a)
Dependency analysis by REQUIREMENTS.
Parsing file "/media/hdd/work/matlab/gpuBench/mainBench.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/benchFcn.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/executeBenchmarks.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/getData.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/paralleldemo_gpu_backslash.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/timeSolve.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForCpu.m"
(Referenced from: "Compiler Command Line").
Parsing file "/media/hdd/work/matlab/gpuBench/waitForGpu.m"
(Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/deployprint.m"
(Referenced from: "Compiler Command Line").
Parsing file "/opt/MATLAB/R2014a/toolbox/compiler/deploy/printdlg.m"
(Referenced from: "Compiler Command Line").
比起在其他机器上,鉴于设置了环境变量我只是执行命令
./gpuTest
产生的错误是:
Cannot CD to /media/hdd/work/matlab (Name is nonexistent or not a directory).
Error in startup (line 1)
问题是没有 "startup" 本应编译的脚本。但是我确实有一个 "startup.m" 脚本,它在我的启动文件夹中,实际上它正好执行 "cd /media/hdd/work/matlab" 和其他一些东西。
我有两个问题:
- 为什么它还要编译我的启动脚本?
- 如何解决此问题以仅执行主脚本?
将您的启动脚本更改为:
if ~isdeployed
cd /media/hdd/work/matlab
end
为什么 - 我真的不知道 - 我猜是这样你可以初始化一些东西但它不是我曾经使用过的 "feature"....
回答你的两个问题:
- 它正在编译您的
startup.m
脚本,以确保您的主脚本 运行 与您的常规 MATLAB 会话中的脚本完全相同。您会发现它还包括许多其他需要的东西,例如您的首选项文件夹,再次需要它来确保它 运行 与在常规 MATLAB 会话中所做的相同。 - @matlabgui 已经提供了类似的答案,即在您的启动脚本中应用
isdeployed
以阻止部署版本中您不想 运行 的任何内容。就个人而言,我通常将以下内容放在启动脚本的顶部,以阻止所有内容。
startup.m
if isdeployed
return
end