Python API OpenGL Information
-
I wanted to try making a small python control panel to monitor viewport OpenGL memory usage. I was also going to explore methods to force a reduction in VRAM usage.
However, I've noticed several pieces that seem to be missing or non-functional in the Python API and was hoping I could get some info on them.
First it seems that several of the flags returned by
c4d.GeGetSystemInfo()
are missing from the python API. The only ones that appear to exist arec4d.SYSTEMINFO_NOGUI
andc4d.SYSTEMINFO_OSX
. I was hoping thatc4d.SYSTEMINFO_OPENGL
would be in there.Second and more importantly I can't seem to get any information that's useful in my case from
c4d.storage.GeGetMemoryStat()
. The BaseContainer returned seems to only have values forc4d.C4D_MEMORY_STAT_MEMORY_INUSE
andc4d.C4D_MEMORY_STAT_MEMORY_PEAK
. All of the other keys return 0 or the keys don't exist in the BaseContainer at all. The latter is the case forc4d.C4D_MEMORY_STAT_OPENGL_USED
andc4d.C4D_MEMORY_STAT_OPENGL_ALLOCATED
which are the ones I was hoping for. -
Hello @wuzelwazel,
thank you for reaching out to us. Regarding the first part of your question, you have to use
GeGetCinemaInfo()
in R21+ which is the replacement forGeGetSystemInfo()
, see end of the post for details.About the second part of your question. I can confirm that
c4d.storage.GeGetMemoryStat()
will indeed not properly populate the returned container. I will have to investigate why this is happening, which might take some time.Cheers,
Ferdinandimport c4d def main(): # GeGetSystemInfo() has been deprecated in R21, see: # https://developers.maxon.net/docs/cpp/2023_2/ # page_changes_in_r21.html#section_changesinr21022_getsysteminfo is_opengl = c4d.GeGetCinemaInfo(c4d.CINEMAINFO_OPENGL) print ("is_opengl:", is_opengl) if __name__=='__main__': main()
-
@zipit thank you so much!
c4d.GeGetCinemaInfo()
makes sense. Unfortunately the current Python documentation is a bit misleading asc4d.GeGetSystemInfo()
is not listed as deprecated and the description forc4d.GeGetCinemaInfo()
makes it sound like it's exclusively for determining if the current C4D session is NFR.Thank you very much for looking into
c4d.storage.GeGetMemoryStat()
. I'm excited to work on my little OpenGL control panel and stretch my GUI knowledge further -
Hi @wuzelwazel,
this is unfortunately a shortcoming of Python bindings at the moment and this issue will be fixed in an upcoming version of the Python API.
As a workaround you could use for now one of the 3rd party libraries listed in the Python Package Index (or anywhere else when you are brave) to get the gpu information you need. The first thing that comes up on PyPI is
gpuinfo
, but it does not instill much confidence, since it basically just runs a command line tool (see get_info()). Handling all the different GPU architectures is the problem here, and should be done by yourself if you want some sort of reliability. Or alternatively wait for a fix in Cinema's Python bindings.Cheers
Ferdinand -
Thanks again for the update. GPUtil came up as an option when I was researching external modules but it only works with NVIDIA hardware. That might not be so bad for now especially as the Python check for GPU hardware vendor in Cinema 4D does seem to be working.
I'll mark this as solved for now. I look forward to the API updates!
-
@ferdinand it looks like this hasn't changed in S24. Is there an expected timeline for a fix to these bindings?
Thanks!
-
Hello @wuzelwazel,
thank you for reaching out to us. I am sorry if I gave you the impression that this will be fixed with S24. This issue is still on our radar, but it does not have the highest priority. I am also unfortunately not a liberty to give you a time frame when this will be done.
Thank you for your understanding,
Ferdinand