Env.step() slowly with xvfb-run

#1

Hello.

I ran the hello_world.py on my PC Windows 7 with python, the env.step() worked well, with FPS about 70.

But when I ran it on my headless Linux 18.04 with xvfb-run, the env.step() became slow, with FPS about 6.

Would xvfb-run influence the speed of MineRL Environment?

#2

Currently gpu acceleration is not in the default config for headless - @william_guss was working on this for the minerl package which should dramatically speed up rendering

#3

An FPS of 6 seems really slow. Could you tell me about the hardware of your linux machine?

#4

Are you running env.render()?

#5

After debugging, I found that this maybe a problem about Chainer and ChainerRL.

I ran the hello_world.py on http://www.minerl.io/docs/, the speed is fast, FPS 70+ both on PC and Linux. It proves that, there is no problem with MineRL Env. :slight_smile:

But when I ran the dqn_train.py, which is provided by https://github.com/minerllabs/baselines, the speed became slow. About FPS 70 on PC but 6 on Linux. The dqn_train.py is based on Chainer and ChainerRL.

As a result, xvfb-run may influence the speed of Chainer and ChainerRL, I guess.

1 Like
#6

@haozheng, I don’t think it has anything to do with xvfb, it’s probably the speed of the train loop on DQN as you had mentioned, but not an interaction between the two. It takes a bit of time to feed-forward/backprop a net etc.

#7

But the same program ran FPS 70 on my PC.

My PC: Windows 7, pycharm run, FPS 70.
My work-station: Ubuntu, xvfb-run, FPS 6.

Everything is the same, except for the running form.

#8

@haozheng_li Are you calling env.render()? Can you see how fast this runs:

import minerl
import gym
env = gym.make('MineRLNavigateDense-v0')


obs  = env.reset()
done = False
net_reward = 0

while not done:
    action = env.action_space.noop()

    action['camera'] = [0, 0.03*obs["compassAngle"]]
    action['back'] = 0
    action['forward'] = 1
    action['jump'] = 1
    action['attack'] = 1

    obs, reward, done, info = env.step(
        action)

    net_reward += reward
    print("Total reward: ", net_reward)
#9

@haozheng_li I wonder if ChainerRL doesn’t recognize your GPU on your Linux box?

#10

I dont call env.render() and this codes ran 70 FPS on Linux.

Finally I use the GPU mode of ChainerRL.

I set the args $gpu from -1 to 0 and the problem was solved.

By the way, the FPS:
PC – no GPU ChainerRL: 70 FPS.
PC – GPU ChainerRL: I dont know, my PC has no GPU.
Linux – no GPU ChainerRL: 6 FPS.
Linux – GPU ChainerRL: 70 FPS.

Whatever, I can do my research now. Thank you very much.

#11

Actually It can recognize.

But the CPU mode is 6 FPS and GPU mode is 70 FPS, on Linux.

But I dont know why – CPU mode on Win 7 is 70 FPS too, much faster than 6 on Linux.

#12

How are you running CPU mode on windows? The default config will use your gpu regardless …

#13

By just change the args %gpu from 0 into -1.