gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

GAMA crashes when displaying a chart with opengl on windows with a radeon graphic card setup #3425

Closed LBIRE closed 2 years ago

LBIRE commented 2 years ago

Describe the bug When running an experiment which displays a chart using opengl, GAMA crashes.

To Reproduce Run the following code, which is incremental model 2 from Library models with the display changed to opengl:

/**
* Name: Charts
* Author: GAMA team
* Description: Second part of the tutorial : Incremental Model
* Tags: chart, tutorial
*/
model SI_city

global {
    int nb_people <- 500;
    float agent_speed <- 5.0 #km/#h;        
    float step <- 1 #minutes;
    geometry shape <- envelope(square(500 #m));
    float infection_distance <- 2.0 #m;
    float proba_infection <- 0.05;
    int nb_infected_init <- 5;
    int nb_people_infected <- nb_infected_init update: people count (each.is_infected);
    int nb_people_not_infected <- nb_people - nb_infected_init update: nb_people - nb_people_infected;
    float infected_rate update: nb_people_infected / nb_people;

    init {
        create people number: nb_people {
            speed <- agent_speed;
        }

        ask nb_infected_init among people {
            is_infected <- true;
        }
    }

    reflex end_simulation when: infected_rate = 1.0 {
        do pause;
    }
}

species people skills: [moving] {
    bool is_infected <- false;

    reflex move {
        do wander;
    }

    reflex infect when: is_infected {
        ask people at_distance infection_distance {
            if (flip(proba_infection)) {
                is_infected <- true;
            }
        }
    }

    aspect default {
        draw circle(5) color: is_infected ? #red : #green;
    }
}

experiment main_experiment type: gui {
    parameter "Infection distance" var: infection_distance;
    parameter "Proba infection" var: proba_infection min: 0.0 max: 1.0;
    parameter "Nb people infected at init" var: nb_infected_init;
    output {
        monitor "Current hour" value: current_date.hour;
        monitor "Infected people rate" value: infected_rate;
        display map {
            species people;
        }

        display chart refresh: every(10 #cycles) type:opengl {
            chart "Disease spreading" type: series style: spline {
                data "susceptible" value: nb_people_not_infected color: #green marker: false;
                data "infected" value: nb_people_infected color: #red marker: false;
            }
        }
    }
}

Desktop (please complete the following information):

Additional context We tried the 4 values for the flags : use_old_animator use_native_opengl_window with no difference

lesquoyb commented 2 years ago

To add more information: I tried the example on Ubuntu with an AMD RADEON and everything worked well

hqnghi88 commented 2 years ago

Hi, I explain something in https://github.com/gama-platform/gama/issues/3398#issuecomment-1120661720 regard my experience on windows, some case of using GPU can cause crash. Hope it help.

AlexisDrogoul commented 2 years ago

Can you try testing again with the new changes made to the display infrastructure in the 1.8.2 branch ? Thanks

lesquoyb commented 2 years ago

I tried on Windows+amd radeon and it's still crashing

AlexisDrogoul commented 2 years ago

I did some changes in #3442 to the way charts are displayed and compute their images. Can you try if it changes anything ?

lesquoyb commented 2 years ago

Tested again on Windows, it's still crashing. I tried with and without AMD software: adrenalin edition as it solved some problems related to my radeon before, but no difference. In eclipse I get this error message:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffce03a4486, pid=1636, tid=12044
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.2+8 (17.0.2+8) (build 17.0.2+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (17.0.2+8, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# C  0x00007ffce03a4486
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Program Files\eclipse\hs_err_pid1636.log
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

And here is the log: hs_err_pid1636.log

AlexisDrogoul commented 2 years ago

Things to test :

lesquoyb commented 2 years ago

Here is a minimal (non-)working experiment:


model crash_radeon

experiment main_experiment {
    output {
        display chart type:java2D {
            chart "hop"  {}
        }
    }
}

The problem really seem to come from the chart + opengl as commenting the chart inside the display or switching to java2D solves the problem.

to sum up what was already tried:

For the question about memory used by gama : no more memory usage than usual

lesquoyb commented 2 years ago

A few updates on that issue: there seem to have been a windows update that makes things a bit better (maybe also helped by the changes in the code), in my particular case most models work now at the exception of displaying an empty chart (adding data fixes it) and zooming. I conducted a few different test on my computer and @LBIRE's and the issue seems to be related to performances, as it's still not working on leo's computer (which is less performant than mine) though it can now work a few seconds in some cases. Another thing that makes me think it's performance related is that it crashes way less on the release than on the git version run through eclipse

lesquoyb commented 2 years ago

After further investigations the bug really seems to be rooted in the code of the gpu driver, so not much we can do on our side. And other softwares having the same issue all just recommend the user to play with the computer settings (energy settings, switch to an other gpu etc.) to try and make the software more stable, but none seem to have solved it. The good news is that last week AMD released a new update of AMD software: adrenaline edition and it solved the bug completely on my computer. So I'll wait a bit to try more complex models and scenarios, but it's possible that the solution to it could simply be "download the latest AMD software version".

AlexisDrogoul commented 2 years ago

@lesquoyb that would be a fantastic good news !

lesquoyb commented 2 years ago

Tried on another computer with the same issue, installing AMD Software: Adrenalin edition version 22.10.1 solved it. I thus consider the problem solved and added a few lines about it in the Troubleshooting page of the wiki.

hqnghi88 commented 1 year ago

In https://github.com/gama-platform/gama/wiki/Troubleshooting/b4b827633ef4aa7567d94442fbd0b3e5dc24a1ca "solved the problem but at the cost of very slower rendering". If it is slow rendering, it is not using 3D card or even the installation is not right.

lesquoyb commented 1 year ago

Yes, it is slow precisely because it is not using a proper gpu but an integrated chipset. Basically that's a last resort solution

hqnghi88 commented 1 year ago

Yes, that's what i want to say: installing the Adrenalin supposed to fix the GPU driver, not to prevent OS to use properly the GPU.