RAM usage
How can i check the RAM usage per simulation?
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
It depends on actual need and use case.
From python? from terminal? ... ?
search something like
linux process ram usage
Cheers
Jan
Revision history for this message
|
#2 |
You can find a Python function dedicated to this purpose at
https:/
Revision history for this message
|
#3 |
From the Terminal not from python.
I tried adding the script to my python code, it did not show the RAM usage. This is my script:
# -*- coding: utf-8 -*-
"""
Created on Thu May 18 15:08:40 2023
@author: Carine
"""
from __future__ import print_function
from yade import plot, polyhedra_utils, qt
import numpy as np
wire = False
#######
# Need to define polyhedral material for Ip2_PolyhedraMa
m = PolyhedraMat() #defines polyhedral properties
m.density = 2600 #kg/m^3
m.Ks = 130E3
m.Kn = 160E3 #N/m
m.frictionAngle = 0.54 #tan(31)=0.6, so 31 is 0.54 rad and the input is in rad
O.materials.
#######
# Defining polyhedra shapes in terms of their vertices so technically defining vertices, dimaters are 1 mm
t1_coords = (
(0.
(0.
(-0.
(-0.
(0.
(0.
(-0.
(-0.
)
t2_coords = (
(-0.
(0.
(0.
(0.
(0.
(-0.
(-0.
(-0.
(0.
(-0.
)
t3_coords = (
(0.
(0.
(-0.
(-0.
(-0.
(-0.
(-0.
(-0.
(0.
(0.
(0.
(0.
(0.
(0.
(-0.
(-0.
(-0.
(-0.
(0.
(0.
(0.
(-0.
(-0.
(0.
(0.
(0.
(-0.
(-0.
)
t4_coords = (
(0.
(0.
(0.
(0.
(-3.
(-0.
(-0.
(-0.
(-0.
(-3.
(0.
(0.
(0.
(0.
(-0.
(-3.
(-0.
(0.
(0.
(0.
(-3.
(0.
(-0.
(-0.
(-0.
(-0.
(-0.
(-0.
)
shapes = [t1_coords, t2_coords, t3_coords, t4_coords]
bottom = polyhedron(
leftside = polyhedron(
rightside = polyhedron(
back = polyhedron(
front = polyhedron(
#######
# Setting polyhedra positions in terms of their centers of mass
part_list = [] # Creates an empty list
i = 0 # counter
for x in np.linspace(1.5E-3, 8.5E-3, num=1): # (min coordinate, max coordinate, number of points) box width is 10 mm
for y in np.linspace(
for z in np.linspace(1.5E-3, 8.5E-3, num=3): # width is 10 mm
shape = shapes[shape_id] # uses the random number to pick one of the 4 shapes
i = i + 1
# centroid location
bottom.state.pos = (22.5E-
leftside.state.pos = (-0.1E-
rightside.state.pos = (10.1E-
back.state.pos = (5E-3,4.
front.state.pos = (5E-3,4.
part_list = part_list + [bottom] + [leftside] + [back] + [front]
#######
# Adding the bodies to the simulation, to see how to assign material properties to different polyhedra check O.bodies.append used in free-fall.py
O.bodies.
ThisID = O.bodies.
#######
# Simulation loop
O.engines=[
# Reset forces
ForceResetter(),
# Appropriate collision detection, create interactions
InsertionSor
# Handle interaction
InteractionLoop(
[
[
[
),
# GravityEngine(
NewtonIntegr
# save data from Yade's own 3d view
qt.SnapshotE
#VTKRecorder
# this engine will be called after 20000 steps, only once
PyRunner(
]
#######
# Time step
O.dt = 4.03E-7
'''
#######
# remove Box Side
escapeNo=0
def myAddPlotData():
global escapeNo
uf=utils.
if isnan(uf):
uf = 1.0
KE = utils.kineticEn
if O.iter>9000000:
removeThisID()
'''
# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy[
O.trackEnergy = True
# collect history of data which will be plotted
def addPlotData():
# each item is given a names, by which it can be the unsed in plot.plots
# the **O.energy converts dictionary-like O.energy to plot.addData arguments
plot.addData(
# define how to plot data: 'i' (step number) on the x-axis, unbalanced force
# on the left y-axis, all energies on the right y-axis
# (O.energy.keys is function which will be called to get all defined energies)
# None separates left and right y-axis
plot.plots = {'i': ('unbalanced', None, O.energy.keys)}
# show the plot on the screen, and update while the simulation runs
plot.plot()
'''
def removeThisID():
global ThisID
if (O.bodies[ThisID]):
O.bodies.
'''
def ramFP():
'''Returns the RAM footprint in MB = 1024 kB'''
import resource
mem = resource.
2
] # maximum resident set size used in kB (see ru_maxrss https:/
return mem / 1024. # returns MB
from yade import qt
qt.Controller()
v=qt.View()
O.saveTmp()
Revision history for this message
|
#5 |
If the Python workflow is still an option for you, you naturally need to call somewhere "ramFP()" in your script (and not only define that function with the def .. block).
Can you help with this problem?
Provide an answer of your own, or ask Carine Tanissa for more information if necessary.