Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No GPU Support (includes attempt code) #51

Closed
GM-Script-Writer-62850 opened this issue May 2, 2013 · 16 comments
Closed

No GPU Support (includes attempt code) #51

GM-Script-Writer-62850 opened this issue May 2, 2013 · 16 comments
Assignees

Comments

@GM-Script-Writer-62850
Copy link

Test:

                          ./+o+-
                  yyyyy- -yyyyyy+      chad@M4A79XTD-EVO
               ://+//////-yyyyyyo      OS: Ubuntu 13.04 raring
           .++ .:/++++++/-.+sss/`      Kernel: x86_64 Linux 3.9.0-030900-generic
         .:++o:  /++++++++/:--:/-      Uptime: 8h 37m
        o:+o+:++.`..```.-/oo+++++/     Packages: 1815
       .:+o:+o/.          `+sssoo+/    Shell: bash 4.2.45
  .++/+:+oo+o:`             /sssooo.   Resolution: 1920x1080
 /+++//+:`oo+o               /::--:.   DE: XFCE4
 \+/+o+++`o++o               ++////.   WM: Xfwm4
  .++.o+++oo+:`             /dddhhh.   WM Theme: Albatross
       .+.o+oo:.          `oddhhhh+    GTK2 Theme: Albatross
        \+.++o+o``-````.:ohdhhhhh+     Icon Theme: elementary-xfce-dark
         `:o+++ `ohhhhhhhhyo++os:      Font: Droid Sans 10
           .o:`.syhhhhhhh/.oo++o`      CPU: AMD Phenom II X4 965 @ 3.7GHz
               /osyyyyyyo++ooo+++/     GPU: NVidia GeForce GTX 550 Ti
                   ````` +oo+++o\:     RAM: 1534MB / 12017MB
                          `oo++.

My attempt at GPU support

# GPU Detection - Begin
detectgpu () {
    if [ -f /usr/bin/lspci ];then
        gpu_info=$(lspci | grep VGA)
        gpu=$(echo "$gpu_info" | sed 's/\[/\n/;s/\]/\n/' | head -2 | tail -1)

    elif [ -f /usr/bin/glxinfo ];then
        gpu_info=$(glxinfo)
        gpu=$(echo "$gpu_info" | grep "OpenGL renderer string")
        gpu=$(echo "$gpu" | sed 's/: /\n/;s/\//\n/' | tail -2 | head -1)
        gpu_info=$(echo "$gpu_info" | grep "OpenGL vendor string")
    fi
    if [ -n "$gpu" ];then
        if [ $(echo "$gpu_info" | grep -i nvidia | wc -l) -gt 0 ];then
            gpu_info="NVidia "
        elif [ $(echo "$gpu_info" | grep -i intel | wc -l) -gt 0 ];then
            gpu_info="Intel "
        elif [ $(echo "$gpu_info" | grep -i amd | wc -l) -gt 0 ];then
            gpu_info="AMD "
        elif [ $(echo "$gpu_info" | grep -i ati | wc -l) -gt 0 ];then
            gpu_info="ATI "
        else
            gpu_info=""
        fi
        gpu="$gpu_info""$gpu"
    else
        gpu="No idea, Sorry :("
    fi
    [[ "$verbosity" -eq "1" ]] && verboseOut "Finding current GPU...found as '$gpu'"
}
# GPU Detection - End

It will need support for hybrid GPUs and dual GPUs

Fuuzetsu added a commit to Fuuzetsu/screenFetch that referenced this issue May 2, 2013
@Fuuzetsu
Copy link
Contributor

Fuuzetsu commented May 2, 2013

Fails with integrated Intel graphics chip

GPU: No idea, Sorry :(

00:02.1 Display controller: Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller (secondary) (rev 0c)

Protip: it's far easier to get things tested and integrated if you include actual commits with the issue.

@GM-Script-Writer-62850
Copy link
Author

How is it even possible to get that fallback text if you have lspci installed? is it installed to /usr/sbin?
not that that make it better, still badly broken on intel

I know it would have a lot of issues, was hopeing it would be useful foe a starting point

as for making comits i can't even figure out how to update my repo without manually editing the code online via browser, and i have some code that really needs to be pushed to git

@Fuuzetsu
Copy link
Contributor

Fuuzetsu commented May 2, 2013

My lspci resides in /usr/sbin/lspci.

You can learn how to use git from the quite good git-scm book here: http://git-scm.com/book . The first couple of chapters should at least tell you how to push/pull/commit. Here are some GitHub specific instructions: https://help.github.com/articles/set-up-git .

Edit: changing the checks for glxinfo and lspci to something that doesn't have a hardcoded path, I get
gentoo

@KittyKatt
Copy link
Owner

Well, this is even more interesting.

I've been on the fence about GPU detection for quite some time. I've thought about doing it, but never really committed myself to putting it in.

I'll think about it a little harder and use this as a base for my code. Thanks for the contribution.

@GM-Script-Writer-62850
Copy link
Author

@KittyKatt Sorry for going offtopic, and sorry for my crappy code on this one, my cpu edit is much better

@ShanaTsunTsunLove
no idea how this works... it was much easier to just use the downloads page for holding .tar.gz archives...

chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git add README
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git commit -m 'please let this update all the things'
[master (root-commit) fa246a7] please let this update all the things
 1 file changed, 1 insertion(+)
 create mode 120000 README
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git remote add origin https://github.com/GM-Script-Writer-62850/Hello-World.git
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git push origin master
Username for 'https://github.com': GM-Script-Writer-62850
Password for 'https://GM-Script-Writer-62850@github.com': 
fatal: https://github.com/GM-Script-Writer-62850/Hello-World.git/info/refs?service=git-receive-pack not found: did you run git update-server-info on the server?
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git update-server-info
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ git push origin master
Username for 'https://github.com': GM-Script-Writer-62850
Password for 'https://GM-Script-Writer-62850@github.com': 
fatal: https://github.com/GM-Script-Writer-62850/Hello-World.git/info/refs?service=git-receive-pack not found: did you run git update-server-info on the server?
chad@M4A79XTD-EVO:~/.git-php-scanner-server$ 

@KittyKatt
Copy link
Owner

Also, you can use test instead of using -f in the if statements. Much more reliable than hardcoded paths.

@GM-Script-Writer-62850
Copy link
Author

If you are using proprietary nvidia drivers

~$ echo "NVidia$(nvidia-smi -q | grep -i 'product name' | cut -f 2 -d ':')"
NVidia GeForce GTX 550 Ti

@KittyKatt
Copy link
Owner

Ah, very nice. I mispoke before about test. type -p command is pretty reliable.

@GM-Script-Writer-62850
Copy link
Author

and yet another nvidia method, pretty sure is needs the proprietary nvidia driver
you could loop through all the folders in /proc/driver/nvidia/gpus/ and get every nvidia gpu's model

~$ cat /proc/driver/nvidia/gpus/0/information
Model:       GeForce GTX 550 Ti
IRQ:         18
GPU UUID:    GPU-cf9334b8-5fdc-293c-11b1-d88c44e3e490
Video BIOS:      70.26.20.00.00
Bus Type:    PCI-E
DMA Size:    40 bits
DMA Mask:    0xffffffffff
Bus Location:    0000:01.00.0

and i did find this script, pretty slow but...
http://pastebin.com/KTpJZTrf author did say it was incomplete

GM-Script-Writer-62850 referenced this issue in drewis/Ubuntu-Mainline-Kernel-Updater May 8, 2013
@KittyKatt
Copy link
Owner

...uh, dunno that that was related to this issue. But okay.

I've included the attempt code in screenfetch, but haven't included gpu by default in $display until I think it's ready for use by everyone.

@KittyKatt
Copy link
Owner

Have added a couple more things to it and ironed out a few other things.

@GM-Script-Writer-62850
Copy link
Author

I made some changes to the update you made 3 hrs ago, it was not working right, i have something in virtualbox and my nvidia system
hopefully i did not break your improvements, on what ever you did your changes for

# GPU Detection - Begin (EXPERIMENTAL!)
detectgpu () {
    if [ -n "$(type -p lspci)" ]; then
        gpu_info=$(lspci | grep VGA)
        gpu=$(echo "$gpu_info" | grep -oE '\[.*\]' | sed 's/\[//;s/\]//')
        gpu=$(echo "${gpu}" | sed -n '1h;2,$H;${g;s/\n/, /g;p}')
    fi
    if [[ -n "$(type -p glxinfo)" && -z "$gpu" ]]; then
        gpu_info=$(glxinfo 2>/dev/null)
        gpu=$(echo "$gpu_info" | grep "OpenGL renderer string")
        gpu=$(echo "$gpu" | cut -d ':' -f2)
        gpu="${gpu:1}"
        gpu_info=$(echo "$gpu_info" | grep "OpenGL vendor string")
    fi

    if [ -n "$gpu" ];then
        if [ $(echo "$gpu_info" | grep -i nvidia | wc -l) -gt 0 ];then
            gpu_info="NVidia"
        elif [ $(echo "$gpu_info" | grep -i intel | wc -l) -gt 0 ];then
            gpu_info="Intel"
        elif [ $(echo "$gpu_info" | grep -i amd | wc -l) -gt 0 ];then
            gpu_info="AMD"
        elif [ $(echo "$gpu_info" | grep -i ati | wc -l) -gt 0 ];then
            gpu_info="ATI"
        else
            gpu_info=$(echo "$gpu_info" | cut -d ':' -f2)
            gpu_info=${gpu_info:1}
        fi
        gpu="$gpu_info $gpu"
    else
        gpu="Not Found"
    fi

    [[ "$verbosity" -eq "1" ]] && verboseOut "Finding current GPU...found as '$gpu'"
}
# GPU Detection - End

@spaghetti2514
Copy link
Contributor

OS X-specific code to return the GPU is as follows

gpu=$(system_profiler SPDisplaysDataType | awk -F': ' '/^\ *Chipset Model:/ {print $2}')

I don't know how reliable that is, but it works consistently on my machine at least.
If you want to create your own parser for system_profiler's output instead of using that awk command, the output it gives (for me) is

Graphics/Displays:                       

    NVIDIA GeForce 320M:

      Chipset Model: NVIDIA GeForce 320M
      Type: GPU
      Bus: PCI
      VRAM (Total): 256 MB
      Vendor: NVIDIA (0x10de)
      Device ID: 0x08a0
      Revision ID: 0x00a2
      ROM Revision: 3533
      Displays:
        Color LCD:
          Display Type: LCD
          Resolution: 1280 x 800
          Pixel Depth: 32-Bit Color (ARGB8888)
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Built-In: Yes

Most of which was entirely unnecessary for this comment, but hey.

@KittyKatt
Copy link
Owner

This looks nice! Will give it a go.

See commit ea14d5b.

@GM-Script-Writer-62850
Copy link
Author

maybe we can go a step further and include the gpu driver and version
nvidia-smi -q | awk -F': ' '/^\ *Driver Version/ {print $2}'
given that command works nvidia's proprietary driver is installed its output is the version number

@ghost ghost assigned KittyKatt Oct 23, 2013
@KittyKatt
Copy link
Owner

detectgpu is pretty far along at this point. Any feature requests to it or bugs for it should be submitted as new issues! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants