Open franky180 opened 11 months ago
Thanks for posting. And sorry for not getting back before. Can you please wait for a few days until we look at this? We are currently preparing a new beta version (beta7). Maybe that will even solve your issues.
By the way: You might consider using the current master version from the github repo via the developer install: https://opengate-python.readthedocs.io/en/latest/developer_guide.html#installation-for-developers In that way, you always have the most up-to-date version with recent fixes. The beta tags sometimes significantly lag behind the current master.
There is now a brand new beta67 version. Just upgrade via pip and you should be good to go. Can you check if the error persists? Thanks
From the error log you shared that G4 has actually trouble tracking the particles, potentially due to a geometry overlap, yet it states it is only a warning. Does this G4 warning coincide with cases in which your simulation crash? Or does the simulation also crash without this G4 warning?
By the way (and you probably know this): The message "Exception: The queue is empty. The spawned process probably died." is specific to a simulation run with
sim.run(start_new_process=True)
.
If you set the keyword argument to False, you will not get this overlayed exception and only the underlying one.
The developer install seems to be related with too many potential pitfalls I may encounter during the process of compillation. Thus, I would prefer to stick with the beta version. As suggested by @tbaudier in https://github.com/OpenGATE/opengate/issues/245#issuecomment-1748960421_ I download the latest wheels and installed them. This way, with version 10.0b6 I tought to have been up to date. I actually installed version 10.0b7 but encounter a new error message with libGL when trying to use the visualization option. The initial error still persists with this version too.
`libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri) libGL error: failed to load driver: swrast 2024-01-12 16:56:33.283 ( 2.191s) [ 7FA64EB33800]vtkXOpenGLRenderWindow.:651 ERR| vtkXOpenGLRenderWindow (0x5e987f0): Cannot create GLX context. Aborting. ERROR:root:Cannot create GLX context. Aborting. Aborted (core dumped)`
Concerning the G4 overlap warning, if I run the same code with less activity I don't encounter the overlap warning. I'm not able to make sense out of it.
I actually did not know that, thanks for the info with start_new_process.
I only use this option to be able to run multiple simulations over night in a loop.
Is there any way to use the default opengate/contrib/GateMaterials.db
in my simulation?
I wrote a custom function add_default_material_database(sim)
in opengate/contrib/__init__.py
in my local installation of opengate. Is there a better way to use the default GateMaterials?
import pathlib def add_default_material_database(sim): # Assuming your base directory is where your script or application is located base_directory = pathlib.Path(__file__).resolve().parent # Define the path to the "opengate.contrib" folder opengate_contrib_folder = base_directory / "opengate.contrib" sim.volume_manager.add_material_database(pathlib.Path(__file__).resolve().parent / "GateMaterials.db")
Is there any way to use the default
opengate/contrib/GateMaterials.db
in my simulation? I wrote a custom functionadd_default_material_database(sim)
inopengate/contrib/__init__.py
in my local installation of opengate. Is there a better way to use the default GateMaterials?Function add_default_material_database(sim)
I moved this question to a separate issue as it seems an unrelated question.
Hello,
I met a similar error when I ran the alpha particle simulation. I have updated to the latest Gate version beta07. Does anyone have a solution to it? Thanks a lot.
WARNING: group: unknown groupid 1000001
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 1) > this->size() (which is 0)
/var/spool/slurm/slurmd/job124242/slurm_script: line 17: 359382 Aborted (core dumped) singularity run /home2/jzhang/image_gate10beta07.sif bash -c "source $HOME/set_environment.sh && python $PWD/mc_phantom_dose.py /home2/jzhang/cluster_mc/$SLURM_JOB_ID"
Here is my code:
import opengate as gate
import itk
from scipy.spatial.transform import Rotation
import numpy as np
import sys
def mc_dose_sim(path, ct_name, dose_name, source_name, total_act):
'''
General
'''
sim = gate.Simulation()
sim.g4_verbose = True
sim.g4_verbose_level = 0
sim.g4_verbose_level_tracking = 1
sim.visu = False
sim.number_of_threads = 32
sim.random_engine = "MersenneTwister"
sim.random_seed = 123456
sim.volume_manager.add_material_database(path + 'GateMaterials.db')
m = gate.g4_units.m
mm = gate.g4_units.mm
um = gate.g4_units.um
keV = gate.g4_units.keV
MeV = gate.g4_units.MeV
sec = gate.g4_units.second
Bq = gate.g4_units.Bq
kBq = 1000 * Bq
MBq = Bq * 1e6
'''
Geometry
'''
# world
world = sim.world
world.size = [2 * m, 2 * m, 2 * m]
world.material = "G4_AIR"
# CT image
ct = sim.add_volume('Image', 'ct')
ct.mother = 'world'
ct.image = path + ct_name
ct_info = gate.image.read_image_info(ct.image)
ct.voxel_materials = [
[0, 4, "G4_AIR"],
[5, 6, "G4_EYE_LENS_ICRP"],
[7, 7, "G4_SKIN_ICRP"],
[8, 43, "G4_BRAIN_ICRP"],
[44, 51, "G4_BLOOD_ICRP"],
[52, 54, "G4_LUNG_ICRP"],
[55, 61, "G4_MUSCLE_SKELETAL_ICRP"],
[62, 63, "G4_B-100_BONE"],
[64, 66, "G4_BONE_COMPACT_ICRU"],
[67, 111, "G4_TISSUE_SOFT_ICRP"]
]
'''
Sources
'''
# Activity image
source = sim.add_source("VoxelsSource", "activity")
source.mother = ct.name
source.image = path + source_name
source.particle = "alpha"
source.half_life = 857088 * sec # ac225
source.energy.type = "mono"
source.energy.mono = 0
source.activity = total_act * MBq / sim.number_of_threads
source.direction.type = "iso"
source.position.type = "sphere"
source.position.radius = 1 * mm
source.position.translation = gate.image.get_translation_between_images_center(ct.image, source.image)
'''
Physics
'''
sim.physics_manager.physics_list_name = "G4EmStandardPhysics_option3"
sim.enable_decay(True)
sim.physics_manager.apply_cuts = True
sim.physics_manager.set_production_cut("world", "all", 100 * um) # all means: proton, electron, positron, gamma
'''
Actors
'''
# add DoseActor
dose = sim.add_actor('DoseActor', 'dose')
dose.output = dose_name # dose, uncertainty, energy map
dose.mother = 'ct'
dose.size = ct_info.size
dose.spacing = ct_info.spacing
dose.img_coord_system = True
dose.uncertainty = True
dose.gray = True
# add stat actor
stats = sim.add_actor('SimulationStatisticsActor', 'stats')
stats.mother = 'world'
stats.track_types_flag = True
'''
Simulation
'''
sim.run_timing_intervals = [[0, 10 * 60 * sec]]
sim.start()
stats = sim.output.get_actor("stats")
print(stats)
print("-" * 80)
file_id = str(1)
data_path = '/home2/jzhang/python_code/opengate/data/'
ct_name = 'phantom/ct/' + file_id + '.mhd'
source_name = 'phantom/act_ac/' + file_id + '.mhd'
dose_name = str(sys.argv[1]) + '/' +file_id + '_ac.mhd'
total_act = 133191332.4 * 1e-9 # scaled total activity MBq
mc_dose_sim(data_path, ct_name, dose_name, source_name, total_act)
Thanks for posting. Can you share the terminal output generated by Gate/Geant4? I guess you are running the code on a cluster, but maybe you have access to the output? Otherwise, can you run and reproduce the error on a local machine where you have access to the terminal output?
Thanks for posting. Can you share the terminal output generated by Gate/Geant4? I guess you are running the code on a cluster, but maybe you have access to the output? Otherwise, can you run and reproduce the error on a local machine where you have access to the terminal output? Hi, I ran on local machine and set the thread number to 1, the error disppears. Maybe the thread number can not be set too large.
Thanks a lot!
The developer install seems to be related with too many potential pitfalls I may encounter during the process of compillation. Thus, I would prefer to stick with the beta version. As suggested by @tbaudier in #245 (comment)_ I download the latest wheels and installed them. This way, with version 10.0b6 I tought to have been up to date. I actually installed version 10.0b7 but encounter a new error message with libGL when trying to use the visualization option. The initial error still persists with this version too.
See full error message for libGL Concerning the G4 overlap warning, if I run the same code with less activity I don't encounter the overlap warning. I'm not able to make sense out of it.
I actually did not know that, thanks for the info with
start_new_process.
I only use this option to be able to run multiple simulations over night in a loop.
@franky180 : I was thinking: since you are having issues with the install, should we schedule a video meeting and look at a shared screen together to understand what's going on? Might be more efficient...
Drop us an email, if you want: nils.krah@creatis.insa-lyon.fr
Simulating small amounts of activity (<30 MBq) over 100 s works fine with my current simulation setup. Increasing the activity to 60 MBq and 100 s results in an error message namely
terminate called after throwing an instance of 'std::out_of_range'
and leads to the multiprocessing manager ExceptionException: The queue is empty. The spawned process probably died.
. Is there anything I can do do change this?Error message:
See full error message
Code
See code
System configuration:
I'm using a virtual server running Ubuntu 22.04.3 LTS, 2 physical processors, 16 cores, 16 threads, Intel(R) Xeon(R) Gold 6148 CPU @ 2.40 GHz, 32 GB RAM.
GATE version:
Gate version 10.0b6
See opengate_info