-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure_memory.py
56 lines (42 loc) · 2.09 KB
/
measure_memory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
cwd = os.path.abspath(os.path.dirname(__file__))
path_current = os.path.abspath(os.getcwd())
from live_wdd.prepare_resize_data import setup_data
import shutil
import subprocess
# This script is used to measure the memory allocation for each algorithm
# Note that we have to pass the idp.npy for different dimensions
# Here we store it in parfile_new, the result is generated in directory Result
if __name__ == '__main__':
# What dimension we want to increase
type_increase = 'detector' # detector or scan
# Here we fix memory evaluation
type_eval = 'Memory'
MC, path_store, list_dim, set_scan_det = setup_data(type_increase, type_eval)
# Create directory
os.makedirs(path_store, exist_ok = True)
# Choose Solver
solver = 'pyptychostem' # livewdd or pyptychostem
formt = '.json'
# Path file for original PyPtychoSTEM Dataset
# Here we have graphene (65,64,256,256)
parfile ='/Users/bangun/pyptychostem-master/parameters.txt'
total_result = []
for idx in range(len(list_dim)):
# Function to change the dataset w.r.t dimension for
# increasing scanning and detector dimension
print('Processing dimension ', str(list_dim[idx]))
path_data, path_json = set_scan_det(list_dim[idx],parfile)
# Load parameters data after resize to new dimension and run reconstruction
parfile_new = os.path.join(path_current,'LiveWDD_Data/parameters_new.txt')
# file name
fname = os.path.join(path_store, 'dim_idx_' + str(idx) + solver + formt)
# Generate datasets
print(os.getcwd())
py = shutil.which('python3')
command = [py, os.path.join(cwd, 'memtree.py'), '--save-json', fname, '--', py, os.path.join(cwd, 'main_memory.py'),
'--solver', solver, '--parfile-new', parfile_new , '--path-json', path_json,
'--path-data', path_data, '--mc', str(MC)]
print(f"running {command} in {cwd} (from {__file__})")
# Run Measurements
subprocess.run(command, check=True, cwd=cwd)