tambetm / gym-minecraft

Minecraft environment for Open AI Gym, based on Microsoft's Malmo.
272 stars 29 forks source link

very slow performance #2

Closed pavitrakumar78 closed 7 years ago

pavitrakumar78 commented 7 years ago

Hi,

I have been trying to run a multi-agent setup on my local PC. But, for even 1 agent(mc client), the CPU utilization is very high (80-100%), is this normal or do I need to play around with the render settings? (I am running this on a desktop i5 4670 3.4 GHz and nVidia 660 GTX) Also, is it possible to run this on an ec2 instance? is full off-screen render possible?

tambetm commented 7 years ago

The CPU utilization depends a lot on the resolution you are using. I've been able to successfully train agents with 40x30 resolution. CPU utilization 80-100% is still expected, you would need full core for each Minecraft instance. I haven't played with multi-agent yet - do you need full Minecraft instance for each agent?

To run it on EC2 I think the easiest option would be to use docker image, see https://github.com/tambetm/gym-minecraft/wiki/Docker. Dockerfile also gives hints how to set up full offscreen rendering using xvfb. Beware of the network latencies though.

pavitrakumar78 commented 7 years ago

If each agent is going to independently make moves (ex. a3c-dqn), then I would need separate instances, right?

Yes. I will look into the docker image for ec2.

Thank you!

Edit: I don't want to make a separate issue for this, but here, you have not included the env.configure() call in the code, directly calling env.reset() gives a 'forceWorldReset' no attribute error. But if I include env.configure(), everything works fine!

tambetm commented 7 years ago

Yes, with A3C you would need separate instances. What I meant by multi-agent is where the agents act in the same world, but I bet you might need separate instances there as well. I attached two scripts I'm using to create and destroy envs.

create_minecraft_envs.sh:

#!/bin/bash

if [ -n "$2" ]; then
  start_port=$2
else
  start_port=10000
fi

for i in `seq 1 $1`;
do
    port=$(($start_port + $i))
    docker run -d --network=host --name minecraft_$port quay.io/tambet/malmo:0.18 -port $port
done

kill_minecraft_envs.sh:

#!/bin/bash

if [ -n "$2" ]; then
  start_port=$2
else
  start_port=10000
fi

for i in `seq 1 $1`;
do
    port=$(($start_port + $i))
    docker kill minecraft_$port
    docker rm minecraft_$port
done