MATLAB workers can't access files in network shared folder

13 visualizaciones (últimos 30 días)
My lab has a computer that acts as a parallel server that can be connected via LAN. I work on my laptop (client) and have shared a folder to be accessed by everyone in the local network. From the server, I can access the shared folder by typing the UNC in File Explorer, such as:
\\CLIENTPC\PATH\TO\FOLDER
Let say I am submitting a batch job from the client to server, and there is a function that needs access to the shared folder in the client, for example, savefig, such as:
plot(1:109, randn(1,100)
savefig('\\CLIENTPC\PATH\TO\FOLDER\Figure.mat')
I pass the script name that contains the above code to the batch function, and I expect that workers in the server can generate the figure, then save it directly to the sahred folder, so that I can easily get the saved figure from my laptop. However, the batch job generates an error, stating that the file/folder is not found.
What is the reason for this, and how do I fix this permission denied error? The savefig function is just an example; basically, any functions that involve writing/reading from a shared folder generates an error.
Also, how do I avoid this altogether? I mean, is there a way to obtain a figure generated from the server to the client, like by using load(Job). Because, if I just fetch the workspace variables from the server, I will just get the handle to the figure, not the figure itself (.fig).
Thanks for your help!

Respuesta aceptada

Edric Ellis
Edric Ellis el 3 de En. de 2024
You could try using FileStore for this. You'll first need to save your figure to a temporary location on disk, and then you can copy it to the FileStore, a bit like this:
%% On the worker
% Generate a file on the local disk
plot(1:100, randn(1,100));
tempFname = fullfile(tempdir, 'Figure.fig');
savefig(tempFname);
% Copy the file to the FileStore
store = getCurrentFileStore();
copyFileToStore(store, tempFname, "result");
%% On the client
j = batch(); % Run your batch job
wait(j);
store = j.FileStore;
localFile = fullfile(tempdir, 'Figure.fig');
copyFileFromStore(store, "result", localFile);
openfig(localFile)

Más respuestas (0)

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by