When you want to get the RAM capacity of the graphics card installed on the computer, It’s more simple to use WMI class.
You can give a look at the AdapterRAM attribute of Win32_VideoController.
The Win32_VideoController WMI class represents the capabilities and management capacity of the video controller. AdapterRAM is one of its attibute:
AdapterRAM
Data type: uint32
Access type: [...]