Page 1 of 1

Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 12:34 pm
by cruster
If possible, I'd like to set aside 1024Mb of the 4Gb memory available for GPU memory use.

I've tried adding the 'gpu_mem_1024' command in config.txt which then sees me with 64Mb on reboot.
I've tried setting the maximum setting in Raspberry Pi Configuration for GPU memory, which is "896"
which doesn't work either. On a couple of occassions I have had the system lock on reboot which required me to take the SD card out and edit config.txt externally.

Can some helpful person advise me how to go about this, as I don't know why either of these methods don't appear to work?

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 12:43 pm
by rpiMike
I believe the Pi4 allocates memory to the GPU as necessary.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 12:56 pm
by cruster
Thanks Mike.

If that's the case, is there an upper bound? If so, what sets it? and what should the settings be in the Raspberry Pi Configuration for GPU memory and the entry (if any) in config.txt?

Running 'vcgetcmd get_mem gpu' returns gpu=256M when GPU mem is set to 256 in Raspberry Pi configuration. But setting anything larger does not work.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 1:18 pm
by jodesi
I'm not sure if it's a fault but I set mine to max and Raspian failed to boot. I edited the config.txt via a Windows PC back to 64 and the Pi booted ok again.

Maybe it's a thing on the "to do" list but my Pi 4 (4GB) didn't play nice with high settings.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 1:54 pm
by jamesh
You don't need to allocate that much to the GPU, 512 at the very most I would have thought.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 2:03 pm
by cruster
Hi Jamesh

How do I go about allocating 512Mb?

Neither altering the GPU memory setting (above 256Mb) in Raspberry Pi Configuration or editing config.txt appear to work for me.
What's the correct procedure?

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 2:12 pm
by 6by9
You need to distinguish between what resources you actually mean:

- gpu_mem in config.txt sets up the memory reserved for the VideoCore VPU. This is used for the camera and H264 video codec only. Some camera modes require 160MB, or if you try doing lots of simultaneous video decodes you'll want more, but generally you shouldn't need to increase this from defaults (64MB without the camera, or 128MB with it).
- cma= in /boot/cmdline.txt or via device tree sets up the Contiguous Memory Allocator (CMA) heap within the Linux kernel. This is used for framebuffer objects as the display rendering hardware requires contiguous memory blocks
- The new V3D hardware has an IOMMU, therefore textures are allocated from the general system memory and mapped as required.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 3:06 pm
by cruster
Ah

Thank you for the explanation 6by9. I'd thought it was a simple split between "GPU ram" and "CPU ram"

What I'm after is as smooth playback as I can achieve in Youtube @ 1080p (actually 1280 x 800) as this Pi4 is pretty much going to be used as a media center. So whatever I can tweak to help the playback, I'd like to do!

Am I right in assuming it will make no difference to video playback what I set GPU mem to in Raspberry Pi configuration?
-and ditto-
in config.txt - as that effects the amount of memory used only by the camera? (there isn't one)

Are there any other settings that would benefit from a little manual intervention? If so, could you point me in the rght direction?

Many thanks for all the help guys !

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 3:11 pm
by jamesh
If you use LibreElec you get all this optimally set up for you. And get a funky UI as well.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 3:16 pm
by 6by9
cruster wrote:
Wed Jul 03, 2019 3:06 pm
Thank you for the explanation 6by9. I'd thought it was a simple split between "GPU ram" and "CPU ram"

What I'm after is as smooth playback as I can achieve in Youtube @ 1080p (actually 1280 x 800) as this Pi4 is pretty much going to be used as a media center. So whatever I can tweak to help the playback, I'd like to do!

Am I right in assuming it will make no difference to video playback what I set GPU mem to in Raspberry Pi configuration?
-and ditto-
in config.txt - as that effects the amount of memory used only by the camera? (there isn't one)

Are there any other settings that would benefit from a little manual intervention? If so, could you point me in the rght direction?
Chromium as packaged in Raspbian has patches to use the hardware video decoder where possible.
Rendering performance at the moment has a slight hiccup, but should be fixed very soon. Chromium always renders through X which isn't double buffered, therefore tearing is almost always unavoidable.
None of the settings should really require any tweaking.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 3:30 pm
by cruster
Thank you all for the answers and suggestions

:)

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 4:16 pm
by jodesi
Thanks for the information.

When I set it to max, it was via the Pi settings in Raspian. The highest was 800 plus. I'll just leave it at stock going by the above explinations. A bit curious what you meant by "codecs" are these the same codecs used for playing/enconding types of video/audio?

Thanks

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 4:25 pm
by 6by9
jodesi wrote:
Wed Jul 03, 2019 4:16 pm
When I set it to max, it was via the Pi settings in Raspian. The highest was 800 plus. I'll just leave it at stock going by the above explinations. A bit curious what you meant by "codecs" are these the same codecs used for playing/enconding types of video/audio?
Edited my post above to clarify that it is the H264 video codec only (both encode and decode).
Audio codecs run almost solely on the ARM.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 4:37 pm
by jodesi
6by9 wrote:
Wed Jul 03, 2019 4:25 pm
jodesi wrote:
Wed Jul 03, 2019 4:16 pm
When I set it to max, it was via the Pi settings in Raspian. The highest was 800 plus. I'll just leave it at stock going by the above explinations. A bit curious what you meant by "codecs" are these the same codecs used for playing/enconding types of video/audio?
Edited my post above to clarify that it is the H264 video codec only (both encode and decode).
Audio codecs run almost solely on the ARM.
Thanks for clearing that up.

It seems as though the software options at the moment need to catch up a bit, it's understandable given how new the Pi4 is.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 5:35 pm
by hardwaremack-orginal
Tearing is unavoidable huh.... darn.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Wed Jul 03, 2019 6:36 pm
by 6by9
hardwaremack-orginal wrote:
Wed Jul 03, 2019 5:35 pm
Tearing is unavoidable huh.... darn.
If x is rendering the main desktop, then yes as it doesn't double buffer. Run something like neverball full screen and that does double or triple buffer. Whether you can convince chromium to do that is a very different question. Possibly in kiosk mode, but I don't know.

Re: Pi4 with 4Gb Ram. Setting max mem for GPU ?

Posted: Thu Aug 22, 2019 10:06 am
by dboyr