V-REP gradually slows down in Docker

Typically: "How do I... ", "How can I... " questions
Post Reply
mthor13
Posts: 29
Joined: 03 Jul 2017, 08:32

V-REP gradually slows down in Docker

Post by mthor13 » 08 Apr 2019, 14:06

Dear Coppelia and fellow programmers,

I am planning to use V-REP for Reinforcement Learning and I would, therefore, like to run several v-rep instances in parallel. For that, I use Docker to create v-rep containers. However, my simulation is gradually getting slower as it is being stopped and started again (i.e. reset).

As an example see the following lines of code from a python script that resets the simulation 10 times:

Code: Select all

while trails < 10
    vrep.simxStopSimulation(clientID,blocking)
    vrep.simxGetPingTime(clientID)
    vrep.simxStartSimulation(clientID,blocking)
    vrep.simxGetPingTime(clientID)
    CODE THAT WAITS FOR THE SIM TIME TO REACH 5s
    trails = trails+1
Trail 1 takes 2s to execute while trail 5 takes 6s to execute, and it looks the execution time is increasing exponentially.
Is there anything I have forgotten to clean between trails? Or something that I need to include in the python script? Any help and suggestions are well received!

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: V-REP gradually slows down in Docker

Post by coppelia » 09 Apr 2019, 08:15

When you stop a simulation, you usually need more than one simulation step, so simply waiting one ping is probably not enough. Better would be to wait for the simulation to be stopped with simxGetInMessageInfo. Also, if you start data streaming with the simx_opmode_streaming operation mode, you should end it with simx_opmode_discontinue when not used anymore (stopping a simulation will not be enough).

Cheers

mthor13
Posts: 29
Joined: 03 Jul 2017, 08:32

Re: V-REP gradually slows down in Docker

Post by mthor13 » 09 Apr 2019, 09:12

Dear Coppelia,

Thank you for answers. I do not use simx_opmode_streaming and the simulation is also getting slower when using ROS to start and stop the simulation (where I also check that the simulation, in fact, is stopped and started). Is there anything else that I should be aware of when resetting the simulation multiple times?

Best Regards,
Mathias Thor

mthor13
Posts: 29
Joined: 03 Jul 2017, 08:32

Re: V-REP gradually slows down in Docker

Post by mthor13 » 09 Apr 2019, 12:05

On closer inspection, it looks like vrep is using more and more memory+CPU after each reset.
What could that be?

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: V-REP gradually slows down in Docker

Post by coppelia » 11 Apr 2019, 11:43

Can you check that this is or is not a problem related to the remote API or ROS, by starting/stopping the simulation by pasting following into the sandbox script, using your specific simulation scene?

Code: Select all

function sysCall_nonSimulation()
    sim.startSimulation()
end
function sysCall_actuation()
    sim.stopSimulation()
end
Cheers

mthor13
Posts: 29
Joined: 03 Jul 2017, 08:32

Re: V-REP gradually slows down in Docker

Post by mthor13 » 15 Apr 2019, 13:14

Hi Copellia,

I tried this and got the same result. Both the CPU usage and memory usage keeps increasing.
Note that this only happens when running in a docker container. Any ideas for what to test next?

Best Regards,
Mathias Thor

coppelia
Site Admin
Posts: 7150
Joined: 14 Dec 2012, 00:25

Re: V-REP gradually slows down in Docker

Post by coppelia » 16 Apr 2019, 06:39

hum... I am at a loss here...

Post Reply