Get information on your graphics card on linux (such as graphics memory size)

lspci -v -s `lspci | awk '/VGA/{print $1}'`
probably only works if you have one graphics card. used this: http://www.cyberciti.biz/faq/howto-find-linux-vga-video-card-ram/ as reference can be expanded, for example: lspci -v -s `lspci | awk '/VGA/{print $1}'` | sed -n '/Memory.*, prefetchable/s/.*\[size=\([^]]\+\)\]/\1/p' will just get the amount of prefetchable memory compare to: lshw -C display which does not give the size (it does give byte ranges and you could calculate the size from that, but that's a pain) Also uses a command which is not standard on linux; wheras lspci is a core utility provided by most systems
Sample Output
01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 9800 GTX] (rev a2) (prog-if 00 [VGA controller])
        Subsystem: XFX Pine Group Inc. Device 2373
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at e6000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=512M]
        Memory at e4000000 (64-bit, non-prefetchable) [size=32M]
        I/O ports at a000 [size=128]
        [virtual] Expansion ROM at e7000000 [disabled] [size=128K]
        Capabilities: <access denied>
        Kernel driver in use: nvidia
        Kernel modules: nvidia, nouveau, nvidiafb

if runs as super-user you get extra info:
01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 9800 GTX] (rev a2) (prog-if 00 [VGA controller])
        Subsystem: XFX Pine Group Inc. Device 2373
        Flags: bus master, fast devsel, latency 0, IRQ 16
        Memory at e6000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=512M]
        Memory at e4000000 (64-bit, non-prefetchable) [size=32M]
        I/O ports at a000 [size=128]
        [virtual] Expansion ROM at e7000000 [disabled] [size=128K]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Kernel driver in use: nvidia
        Kernel modules: nvidia, nouveau, nvidiafb

1
By: infinull
2010-10-26 17:45:14

1 Alternatives + Submit Alt

  • Loop is needed if you have more then one card. Show Sample Output


    4
    for I in `/sbin/lspci |awk '/VGA/{print $1}'`;do /sbin/lspci -v -s $I;done
    houghi · 2010-10-26 19:02:26 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: