Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FPS is too low #12

Open
obadul024 opened this issue Apr 27, 2022 · 4 comments
Open

FPS is too low #12

obadul024 opened this issue Apr 27, 2022 · 4 comments

Comments

@obadul024
Copy link

Hi there,
I cloned the your fantastic repo and started to run some experiments. There is an issue I am facing however, the FPS is stuck at 2. No matter what I tried it simply cannot run any faster. I tried it on an evaluation and training experiment.

I can manage to run Carla as a server at 60 FPS no issues. But when I run the main script, it just simply doesn't work.

I would love to have some pointers.
Thanks for your help.
Cheers

@Luca96
Copy link
Owner

Luca96 commented Apr 29, 2022

Hi, thanks for the compliment.

Yeah, I know FPS is an issue. With the hardware I had (i9 + RTX 6000), I was able to achieve about 10-15 fps, which is still low (probably due to some poorly optimized code..)
Anyway, you could try these:

  • If your GPU has enough memory, you can try to run the neural networks on that: just comment this line. It it fails, try to reduce the batch_size and/or the timesteps, e.g. here.
  • You can start the CARLA simulator with these flags: -windowed -ResX=32 -ResY=32 --quality-level=Low; see the repo README at the installation section.
  • In learning.stage_xyz(...) you can add the repeat_action argument. For example you can pick 2, 3, or even 4 (default is 1). This will "duplicate" the model's predictions for 2, 3, or 4 frames, thus reducing the calls to the model. So, you should call learning.stage_xyz(..., repeat_action=2), for example. See main, but you can also do this for evaluation: by adding the argument here.
  • If you're training from scratch, you can opt for a smaller network: try to reduce the number of units, and/or the number of channels in the shufflenet backbone. See here.
  • Again if training from scratch, you should first try to halve (or more) the window_size (it just reduces the pygame window - you can do the same also for evaluation), or you can even reduce the resolution of the input images by setting image_shape. See here.

I guess it's all you can try, hope it helps a bit.

@obadul024
Copy link
Author

obadul024 commented Apr 29, 2022 via email

@adhocmaster
Copy link
Contributor

Hi Luca!

I am running the model in one GPU and carla in another. Both GPU utilization is under 6%, CPU under 60%. I have RTX 2070 and i7. I am getting 1-3 FPS max.

I was wondering if it's possible to run pygame client in another process and process the sensor data parallelly.

@Luca96
Copy link
Owner

Luca96 commented May 11, 2022

Hi, apology for the late response..

In principle it should be possibile but in practice is useless since the agent makes sequential decisions: it has to first wait for the sensor data, which are then fed to the neural nets, that finally outputs the action for time t.

I have to check the code and see if it's possible to optimize the neural nets (e.g. use more @tf.function), and look for eventual bottlenecks that prevent full GPU utilization (probably due to data transfer between CPU and GPU, related to the memory buffer).

The fact is that RL is mainly sequential (at most you can have a bunch of environments in parallel): you run your environment/simulator for N steps (but at each step you use your NN to predict on a batch of size 1 - the state - and so here you can't fully leverage vectorization and data parallelism), then the N experience tuples are stored into a memory buffer, from which you later retrieve a batch of B examples to train the NN to improve. Basically, all of this repeats until convergence or when the maximum amount of steps is exceeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants