wimpysworld / desktopify

Convert Ubuntu Server for Raspberry Pi into a Desktop
https://www.youtube.com/watch?v=umtZuUJOU38
MIT License
518 stars 90 forks source link

Add gpu argument to specify gpu memory size, use fancy_message, and add emoji support to fancy message. #33

Closed russarmst closed 4 years ago

russarmst commented 4 years ago

I thought this would be a nice to have for some people wanting to specify the GPU memory size rather than having the value hard coded into the script. If the --gpu is not specified then the default is 128mb, if a value greater than 768mb is specified then default is 768mb.

Please check through thoroughly. This is my 1st time contributing to a project, the first time using git and github to fork and create a PR and first time scripting in bash.

russarmst commented 4 years ago

Perhaps some guidance as to the size of gpu_mem needs to be added to the usage function? Also lines 143 and 144 should be changed to 512 to reflect the recommended max as per the official docs:

total RAM       | gpu_mem recommended max
----------------|------------------------
256MB           | 128
512MB           | 384
1GB or greater  | 512

It is possible to set gpu_mem to larger values, however this should be avoided since it can cause problems, such as preventing Linux from booting. There is no performance advantage to specifying values larger than is necessary. The minimum value is 16, however this disables certain GPU features.

On the Raspberry Pi 4 the 3D component of the GPU has its own memory management unit (MMU), and does not use memory from the gpu_mem allocation. Instead memory is allocated dynamically within Linux. This may allow a smaller value to be specified for gpu_mem on the Pi 4, compared to previous models.
flexiondotorg commented 4 years ago

I like where this pull-request is headed :slightly_smiling_face:

Please can you rebase this pull request? May I also request that instead of having a --gpu option that gpu_mem is automatically derived from the available system RAM.

tssva commented 4 years ago

Please can you rebase this pull request? May I also request that instead of having a --gpu option that gpu_mem is automatically derived from the available system RAM.

* `<=` 1GB: 128Mb `gpu_mem`

* `>=` 2GB: 256Mb `gpu_mem`

* `>=` 4GB: 512Mb `gpu_mem`

* `>=` 8GB: 768Mb `gpu_mem`

The gpu memory is not used by the 3D components on the Raspberry Pi 4 but instead it uses the general system memory. There is no benefit to setting gpu_mem this high and in fact setting above 512 may cause your Pi not to boot. There may be slight speed improvements in some GPU tasks by setting it to 256MB but even that is debatable. The general recommendation given in the forums by members of the Raspberry Pi team for the RPi4 is to use 128MB and possibly 256MB under some circumstances but any more is just wasting memory which could be used by the general system.

russarmst commented 4 years ago

If gpu_mem is undefined in /boot/config.txt the default value is 74MB for all models except the Pi 1 and Pi Zero, in which case it is 64MB. From the RPi config.txt docs the maximum recommended value are as follows:

Total Mem       gpu_mem
256MB           128
512MB           384
>1GB            512

So based on nothing more than sticking my finger in the air could I suggest:

Total Mem       gpu_mem
1GB             128
2GB             256
4GB             384
8GB             512

There is still the question as to whether these gpu_mem sizes are sufficient for people running one or two HD / HiDPI monitors? Also looking back through RPi forum posts (2012/13) there seems to be some history of dynamic gpu_mem / arm_mem allocation through cma settings but this seems to be be no longer implemented or still experimental(?).

It is Wimpy's work on desktopify that inspired me to start my own (and first) opensource project (pishlib) which is (gradually) implementing a library of shell scripting functions to get and set various RPi config values. I will (or someone else can) take some of this work and produce a PR to implement the gpu_mem config values as suggested above. Bear with me though as I'm off on my holibobs.