-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from SANDAG/ABM3_develop_skim_mem
Load skims into shared memory to be accessed by later models
- Loading branch information
Showing
8 changed files
with
145 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from multiprocessing import shared_memory | ||
import time | ||
|
||
# Find and hold on to skims in shared memory so memory is not released | ||
|
||
if __name__ == '__main__': | ||
shared_mem_name = "skim_shared_memory__taz" | ||
|
||
try: | ||
test_mem = shared_memory.SharedMemory(name=shared_mem_name) | ||
raise Exception("Skims already exist in shared memory") | ||
except FileNotFoundError: | ||
pass | ||
|
||
# Try to get skim from shared memory every 10 minutes | ||
# Timeout after one hour | ||
mem = None | ||
for i in range(6): | ||
time.sleep(600) | ||
try: | ||
mem = shared_memory.SharedMemory(name=shared_mem_name) | ||
print("Skims found in shared memory") | ||
break | ||
except FileNotFoundError: | ||
continue | ||
if mem is None: | ||
print("Timed out, skims not found in shared memory") | ||
else: | ||
# Wait for asim models to complete, then release memory | ||
input() | ||
print("Releasing skims from shared memory") | ||
mem.close() | ||
mem.unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
ECHO ON | ||
|
||
set PROJECT_DRIVE=%1 | ||
set PROJECT_DIRECTORY=%2 | ||
|
||
%PROJECT_DRIVE% | ||
cd /d %PROJECT_DIRECTORY% | ||
|
||
SET ANACONDA3_DIR=%CONDA_PREFIX% | ||
|
||
SET PATH=%ANACONDA3_DIR%\Library\bin;%PATH% | ||
SET PATH=%ANACONDA3_DIR%\Scripts;%ANACONDA3_DIR%\bin;%PATH% | ||
|
||
:: setup paths to Python application, Conda script, etc. | ||
SET CONDA3_ACT=%ANACONDA3_DIR%\Scripts\activate.bat | ||
|
||
SET CONDA3_DEA=%ANACONDA3_DIR%\Scripts\deactivate.bat | ||
|
||
SET CONDA3=%ANACONDA3_DIR%\Scripts\conda.exe | ||
|
||
SET PYTHON3=%ANACONDA3_DIR%\envs\asim_baydag\python.exe | ||
|
||
ECHO Activate asim_baydag.... | ||
CD /d %ANACONDA3_DIR%\Scripts | ||
CALL %CONDA3_ACT% asim_baydag | ||
|
||
set MKL_NUM_THREADS=1 | ||
set MKL=1 | ||
|
||
cd /d %PROJECT_DIRECTORY% | ||
|
||
%PYTHON3% python/skim_shared_mem_manager.py |