Skip to content
Snippets Groups Projects
Commit 28470824 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Fix error with meminfo save fig.

parent 4f0ceb4d
No related branches found
No related tags found
2 merge requests!318[Upd] release verision 0.5.0,!276Rewrite memory manager log_info in Python.
......@@ -44,19 +44,6 @@ def compute_default_mem_info(scheduler: aidge_core.Scheduler) -> Tuple[int, List
mem_info[node] = [] # No meminfo for producer
return mem_size, mem_info
# TODO remove
def _gnuplot_installed():
try:
# Run gnuplot with the --version flag and capture the output
subprocess.run(["gnuplot", "--version"])
return True
except FileNotFoundError:
aidge_core.Log.warn("Gnuplot is not installed.")
return False
except subprocess.CalledProcessError:
aidge_core.Log.warn("Gnuplot command found but failed to run.")
return False
def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:bool):
"""Generate a graph representing the memory allocation of each ouputs.
......@@ -115,6 +102,8 @@ def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:b
ax = plt.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
folder_path = path.parent
folder_path.mkdir(parents=True, exist_ok=True)
plt.savefig(path)
plt.close()
aidge_core.Log.notice(f"Generated memory management info at: {path}")
......@@ -157,19 +146,6 @@ def generate_optimized_memory_info(scheduler: aidge_core.Scheduler, stats_folder
if stats_folder is not None:
log_meminfo(mem_manager, Path(stats_folder) / "memory_info.png", display_names)
# TODO remove
if _gnuplot_installed():
# Use gnuplot to generate the log
os.makedirs(str(Path(stats_folder) / "graph"), exist_ok=True)
mem_manager.log("memory_info")
os.chmod("memory_info_plot.gnu", 0o777)
os.system("./memory_info_plot.gnu")
shutil.move("memory_info", str(Path(stats_folder) / "graph" / "memory_info"))
shutil.move("memory_info_plot.png", str(
Path(stats_folder) / "graph" / "memory_info_plot.png"))
os.remove("memory_info_plot.gnu")
else:
aidge_core.Log.warn("Warning: gnuplot is not installed, could not generate stat folder.")
# In the export, we currently use an unified memory buffer whose size
# is determined by the memory peak usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment