Remove/Add nvidia drivers ubuntu 14.04.2

45

Firstly,

sudo apt-get remove --purge nvidia*

Enable the Universe and Multiverse repositories - you need to do this to allow the bumblebee and nvidia packages respectively to be installed. Then:

sudo add-apt-repository ppa:bumblebee/stable

sudo apt-get update

sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic

sudo reboot

To run your application with the discrete NVIDIA card run in the terminal:

optirun [options] <application> [application-parameters] 

Example:

optirun firefox 

For a list of options for optirun run:

optirun --help

You can also use prime-select option e.g.

sudo prime-select nvidia

sudo prime-select intel

To check:

prime-select --query
Share:
45

Related videos on Youtube

Natasha
Author by

Natasha

Updated on September 18, 2022

Comments

  • Natasha
    Natasha over 1 year

    I'm trying to populate a blank 2d array (matrix) with a character D put onto a random position.

    This is the code which works properly:

    #define RIGHE 10
    #define COLONNE 10
    
    void drawMap(char[][COLONNE]);
    
    int main()
    {
        char mappa[RIGHE][COLONNE] = {" "}; // blank, as an empty chess board
    
        drawMap(mappa);
    
        return 0;
    
    }
    
    /* Disegna la mappa da gioco */
    void drawMap(char mappa[][COLONNE])
    {
        int rigaDestinazione, colonnaDestinazione;
    
        srand(time(NULL)); // Randomizza numeri
    
        rigaDestinazione = rand() % RIGHE;
        colonnaDestinazione = rand() % COLONNE;
    
        mappa[rigaDestinazione][colonnaDestinazione] = 'D';
    
        for (int i = 0; i < RIGHE; i++) {
            for (int j = 0; j < RIGHE; j++) {
                printf("[ %c ]", mappa[i][j]);     
            }
            printf("\n");
        }
    
    }
    

    Unfortunately when I print it, it seems to be asymmetric as you can see, the output is:

    [   ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][ D ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    [  ][  ][  ][  ][  ][  ][  ][  ][  ][  ]
    

    How can I fix?

    • Eraklon
      Eraklon over 4 years
      Some quick solution: if (mappa[i][j] != 0) printf("[ %c ]", mappa[i][j]); else printf("[ ]", mappa[i][j]);
  • Admin
    Admin over 4 years
    Works. Is there another solution without using string.h?
  • Ruslan
    Ruslan over 4 years
    @anastaciu sizeof(char) is by definition 1, no need in this tautology. And it's better to let the compiler find out the size automatically by using sizeof mappa instead of doing the calculation manually.
  • anastaciu
    anastaciu over 4 years
    @ItsGhost, there is, like Ruslan said, in a loop, you can do it in the loop you already have.
  • anastaciu
    anastaciu over 4 years
    @Ruslan, yes, sizeof(mappa) is better.
  • anastaciu
    anastaciu over 4 years
    @ItsGhost, glad to help