Install Nvidia Driver and CUDA Toolkit on CentOS 6

( Update: have posted a MUCH simpler method of driver install. Steps for CUDA toolkit install have to be followed as given in this post, i.e. , bulleted step # 10 – 19 )

Although the topic has been addressed succinctly in a CentOS forum post, there are certain things like plymouth configuration post Nvidia driver install, etc. which I felt needed to be jotted down for reference. So, here we go describing the Nvidia CUDA toolkit installation on a CentOS system:

  • Download the appropriate toolkit, driver and SDK from Nvidia’s website.
  • RHEL, and its derivatives come with the open source Nvidia driver called nouveau. Before installing Nvidia drivers, we need to ensure nouveau drivers dont get loaded. For this, append the following in the line starting with ‘kernel’ in the file /etc/boot/grub.conf:

rdblacklist=nouveau nouveau.modeset=0

  • Install the Development Tools and Development Libraries group packages, and a few extra packages listed below:

sudo yum groupinstall ‘Development Tools’ ‘Development Libraries’

sudo yum install kernel-devel gcc-c++ freeglut freeglut-devel libX11-devel mesa-libGLU-devel libXmu-devel libXi-devel gcc* compat-gcc* compat-glibc* compat-lib*

  • Restart the system. Upon restart, you’ll see that the resolution of the display would have gone for a toss. Thats due to blacklisting the nouveau driver, and is a sign that we are on track! Open terminal and type the following to goto non-GUI mode (called, runlevel 3):

sudo init 3

  • Above command takes us to text mode. Change directory to /usr/src/kernels/ and note down the complete path of the kernel folder present. In our scenario, it shows up as:


  • Change directory to the folder containing the downloaded files from Nvidia’s website (say ~/Downloads). Mark the 3 downloaded files as executables:

cd ~/Downloads

chmod a+x NV*; chmod a+x cuda*; chmod a+x gpu*

  • Now finally, we are ready to run the installer. First is the Nvidia Driver install :

sudo sh –kernel-source-path=/usr/src/kernels/2.6.32-220.13.1.el6.x86_64/

  • NOTE : there’s a double minus sign before the word kernel above. During the above install, accept the licence agreement shown. Reboot upon completion:

sudo reboot

  • You’ll notice that the GUI resolution is back to normal, indicating successful Nvidia driver install. Now, cudatoolkit has to be installed.
  • Open terminal and change directory to ~/Downloads. Run the cudatoolkit*.run file:

sudo sh

  • During the install, you’ll be asked to supply installation path. Enter the default path itself (/usr/local/cuda).
  • Once completed, few more steps are needed, like adding /usr/local/cuda to default path environment variable, etc. :

sudo nano /etc/

  • Add the following lines to the above created file :


  • Save the above file by pressing Ctrl+x, followed by ‘y’ and pressing Enter. Now run:

sudo ldconfig

  • For adding cuda install path to enviroment path variable, edit ~/.bash_profile file using a text editor (say, nano ~/.bash_profile) :

export CUDA_INSTALL_PATH=/usr/local/cuda
export PATH=($PATH: /usr/local/cuda/bin)
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
export PATH=($PATH: /usr/local/cuda/lib)

  • Finally, gpucomputingsdk needs to be installed. For that :


  • During the install , you’ll be asked for install path. Keep in mind that the sdk can take around 400-500MB. Say, we install it to ~/Documents/NVIDIA_GPU_Computing_SDK.
  • Once done, we need to compile the files in the SDK:

cd ~/Documents/NVIDIA_GPU_Computing_SDK/C/


  • To check whether everything is working fine, we’ll run the deviceQuery file, provided by the SDK just installed:

cd ~/Documents/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/


  • You should see something similar to what is shown at this link .

Congrats for successfully installing the Nvidia driver and the cudatoolkit on your CentOS system. I know, things should be much simpler. I wish someday Nvidia open-sources their drivers and CUDA toolkit to make things simpler for Linux enthusiasts. All that is left now, is to fix the ugly white-blue scrolling bar that shows up instead of the beautiful Plymouth at boot.

  • Reboot system. At the grub prompt, press ‘e’ against the first item on the grub menu to edit its kernel arguments (this mode is called kernel edit mode).
  • Out the the three lines being shown (starting with : root; kernel; initrd ), scroll to kernel line and press ‘e’ again. Type in the following at the end of that line:


  • Press Enter after typing the above and press ‘b’. You’ll see a tabulated list of keywords against several screen-resolutions. Note down the number being shown against the  most appropriate screen resolution. Say, the number is 361. Now, reboot system. Again, enter the kernel edit mode described in the previous two list items. The only difference being that instead of vga=ask, enter vga=0x361. Now press ‘b’ and you’ll see the beautiful Plymouth back in its glory!
  • To make this change permanent, open terminal and open /boot/grub/grub.conf as sudo (sudo nano /boot/grub/grub.conf).
  • Find the line saying ‘kernel’ against your most recent kernel version and add vga=0x361. Save the file (Ctrl+x, y, Enter)

Plymouth theme will now show up everytime that you’ll reboot. Enjoy!

15 thoughts on “Install Nvidia Driver and CUDA Toolkit on CentOS 6

  1. I was wondering if you ever thought of switching the page layout of your website? Its very well written; I really like what youve got to state. But maybe you could include a little more in the way of written content so people can connect to it better. You have got an awful lot of text for only having one or two photographs. Maybe you could space it out better?

  2. Thanks for your suggestions.. now that you’ve pointed it out, i too feel its way too much of text, especially this post! I’ll try changing layout over the next few days.. Thanks anyways!

  3. thanks for the information, everything worked fine, but the file deviceQuery is missing i dont see it in the NVIDIA_GPU_Computing_SDK/C/bin/linux/release/…. can you suggest on this

  4. I want the CUDA version for cent OS 6 not for the ubantu, RHEL and fedora. Can you provide the link for that one

  5. CentOS is a RHEL clone. The rpm meant for RHEL 6 will work perfectly fine with CentOS 6. Hope this helps.

  6. I will try your instructions later today, it looks really promising, though I hate having to fix something else again first (El repo). Will this do the ‘optimus’ bit as well so my Nvidia GPU can fully focus on tractography?

    Maybe you could have a chat with the guys from FSL to create a dummies guide to get it working for all of us picking grey matter. Because I’ve been fighting with the whole deal for a day and a half before finding your guide(fixing an internet connection through VMware player (Centos6.x), failing, getting VMworkstation trial, then getting GCC), next reading through Nvidia instructions for CUDA installation that I simply don’t get, only to speed up the white matter analyses.

  7. Hello, I tried to install cuda on my centos 6, I installed the drivers based on kmod method from the other tutorial, then reboot, then installed cuda toolkit, succeed to compile deviceQuery example and got a similar result when I launched it.
    But then, I reboot again and I can’t start the GUI interface (I go to the login screen, log and then, a fast black screen and come back to the login screen).
    I tried to remove “nouveau modeset=0 blacklist nouveau” from the kernel boot command, but then I got these errors :
    nouveau E[ PGRAPH][0000:03:00:0] ROP0 ch 1 [0x000007fb12 DRM] 0x00000000 0x00000001
    nouveau E[ PGRAPH][0000:03:00:0] ROP1 ch 1 [0x000007fb12 DRM] 0x00000000 0x00000001
    and I don’t go to the login screen.
    I tried to use the init 3 mode to try to reinstall, but all the commands are not available (it said “no such file …” when I try the ls, cat, nano,vi,… command, only cd command works).

    What can I do? (if possible, I would prefer not reinstall centos (I don’t have full access to the machine (I have root access, but the sysadmin has also access to the machine) and the sysadmin will not be happy if he must reinstall all)


  8. Hi! I finally found what makes boot impossible, it’s the add of
    export CUDA_INSTALL_PATH=/usr/local/cuda
    export PATH=($PATH: /usr/local/cuda/bin)
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64
    export PATH=($PATH: /usr/local/cuda/lib)
    to the .bash_profile, I don’t know why (the paths are correct, but I can build and run examples without that)

  9. for those of you who can not log in after making changes in .bashrc file:
    DO NOT EDIT .bashrc FILE! INSTEAD MAKE CHANGES AT /etc/profile.d as root:
    cd /etc/profile.d
    nano (make sure you have nano installed : yum install nano)
    this will creat a .sh file, what ever you need to type in .bashrc, type in this new file, then reboot. I do not know what causes this but do not edit your .bashrc file NEVER!

  10. Am not sure why making changes in bashrc affected your system! ~/.bashrc is a user-specific file that is often used to define environment variables. The only difference that could be there in Fedora is that we generally make the changes in ~/.bash_profile, while in the Ubuntu-family the corresponding file is ~/.bashrc.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s