17

How do I restart the GPU from command line?

Using a HP DV6 laptop with Ubuntu 12.04-64 and an ATI mobile GPU. Installed the standard ATI propriety drivers suggested by Ubuntu. When I close the lid, the computer goes down to suspend mode. When open the lid, everything but the screen resumes again. Just black. I'll guess I have to put a GPU reset script in /etc/pm/sleep.d. But how do I restart/reset the GPU?

Braiam
  • 67,791
  • 32
  • 179
  • 269
LapBuntu
  • 171
  • 1
  • 1
  • 4
  • 1
    Your best bet would be using the scripts that control sleep and resume. You could do it theoretically by unloading the kernel module for fglrx and then loading it again (using rmmod and modprobe), but it would be kind of impossible with nothing on the screen (unless you ssh in) ;) – RolandiXor Jun 22 '13 at 18:29

3 Answers3

19

Run one of the next commands in terminal or, better, in TTY# using Ctrl+Alt+F#, where # is a number from 1 to 6:

sudo /etc/init.d/lightdm restart

or

sudo service lightdm restart

This will restart the graphics environment.

I don't know yet from what reason, but these commands worked for me only in TTY. Anyway, if you are stuck in a black screen after you are running one of these commands in terminal, just go in TTY and run next command:

sudo service lightdm start

From http://en.wikipedia.org/wiki/LightDM:

LightDM is the default display manager for Ubuntu, Edubuntu, Xubuntu and Mythbuntu since 11.10 release, for Lubuntu since 12.04 release, and for Kubuntu beginning with 12.10.

So, restarting LightDM entail restarting the GDM without rebooting the machine

Radu Rădeanu
  • 169,590
4

Try if switching back and forth from the graphic screen to a virtual tty works. I mean, when you have the black screen, try to press Ctrl+Alt+F1 and, if and when you have the login screen, Alt+F7. If the graphic screen doesn't come back, stop reading...

If the screen comes back you can try to add this to your sleep scripts (kudos to the forum entry http://ubuntuforums.org/showthread.php?t=1978290:)

#!/bin/sh
# 

case "${1}" in
        hibernate|suspend)

        chvt 1 
        ;;
        resume|thaw)

        chvt 7
        ;;
esac

Put this script in a file in your /etc/pm/sleep.d/ directory, for example 99_vthack, and make it executable:

sudo chmod 755 /etc/pm/sleep.d/99_vthack 

The 99_ means that this script is run at the end of the resume sequence.

This hack seems to work in a series of AMD-based laptops. YMMV...

Olathe
  • 4,240
Rmano
  • 31,947
1

After installing this package, you should be able to use this script to resolve your issue. I am using a Dell Vostro 1000.

As the screen is messed, you will have to bind a key to start this script, I suggest Shift+Ctrl+Alt+F. Also, for each try fix step, it will speak what it is doing, so you will know what is happening. When the screen gets fixed, hit Ctrl+C to stop the script (it should be started using xterm to be interactive).

What it does is basically change between all possible screen resolutions, and may also open a new X session to try to force the workaround to work.

It wont work if the screen is locked though, so you will have at least to blind login.. OR maybe if run on the text console vt 1, with DISPLAY=:0, may do the trick too.

Olathe
  • 4,240