BuildingsPy icon indicating copy to clipboard operation
BuildingsPy copied to clipboard

ERROR:cache_util_win.cc(20), Unable to move the cache: Access is denied.

Open Elfangor93 opened this issue 1 year ago • 1 comments

First of all, thank you very much for this very great python library!!

But I am facing a problem when simulating a model with different parameter values. I am strictly following the guide at https://simulationresearch.lbl.gov/modelica/buildingspy/examples.html#simulating-a-model-with-two-different-parameter-values. If the list of cases contains more than one simulator object using the same model I get the following error:

*** Standard error stream from simulation:
b'[3584:8732:0229/082518.845:ERROR:cache_util_win.cc(20)] Unable to move the cache: Access is denied. (0x5)\r\n[3584:25392:0229/082518.868:ERROR:disk_cache.cc(205)] Unable to create cache\r\n[3584:25392:0229/082518.868:ERROR:gpu_disk_cache.cc(673)] Gpu Cache Creation failed: -2\r\n'

A quick google search tells me that this error is related to a file which is already in use by another progam and is therefore blocked.

If the outputDirectory is set to be different for each simulator the simulation seems to be successful even with the above error appearing. If I set the outputDirectory to be the same, but set different names for the result file only one of the simulations in the cases list seems to be simulated successfully. In this case I see only one .mat file beeing created.

s.setResultFile('different-file-names')

System information

OS: Microsoft Windows 10 Home OS Version: 10.0.19045 N/A Build 19045 Python: v3.11.3 buildingspy: v5.0.0 Dymola: Version 2024x, 2023-10-06

Elfangor93 avatar Feb 29 '24 07:02 Elfangor93

@Elfangor93 : You will need to make sure that the outputDirectory is unique for each Simulator object. The reason is that a run creates these file (on Linux, and similar on Windows):

├── case1
│   ├── BuildingsPy.log
│   ├── buildlog.txt
│   ├── dsfinal.txt
│   ├── dsin.txt
│   ├── dslog.txt
│   ├── dsmodel.c
│   ├── dymosim
│   ├── FlatPlateWithTank.mat
│   ├── run.mos
│   └── simulator.log
├── case2
│   ├── BuildingsPy.log
│   ├── buildlog.txt
│   ├── dsfinal.txt
│   ├── dsin.txt
│   ├── dslog.txt
│   ├── dsmodel.c
│   ├── dymosim
│   ├── FlatPlateWithTank.mat
│   ├── run.mos
│   └── simulator.log

Hence, if the outputDirectory is not unique, then the two processes write to the same files. They also both write the same dsmodel.c file, and it is not predictable what actually gets compiled. Hence the directory need to be unique.

I cannot reproduce the Access is denied error on Linux; this may be related to Windows permission as each job in the pool runs in its own directory.

mwetter avatar Mar 01 '24 16:03 mwetter