Showing posts with label CUDA. Show all posts
Showing posts with label CUDA. Show all posts

Sunday, November 25, 2018

Install CUDA 10 on Linux mint 19 or Ubuntu 18.04

Assuming that you have nvidia GPU with cuda compatibility.
 
These are the steps for installing CUDA 10 on Linux mint 19 or Ubuntu 18.04
  • Install Linux mint 19/Ubuntu 18.04 fresh
  • Use the ppa nvidia drivers repo from lauchpad here
    • sudo add-apt-repository ppa:graphics-drivers/ppa
      sudo apt-get update
      
      
  • The version 410 is the current long term version as on date
  • From "Driver Manager" install the current stable version


  •  


    • Reboot; verify the driver installed from terminal using "nvidia-smi" command


    • Install these packages
      • sudo apt-get install build-essential dkms
        sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
        
    • Download the deb file and follow the below steps


    • sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
      sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
      sudo apt-get update
      sudo apt-get install cuda

    • That's it.
    • Default location of installation is /usr/local/cuda
    • "cuda-install-samples-10.0.sh ~/install" installs sample files
    • cd into the folder "NVIDIA_CUDA-10.0_Samples"
    • make -j2
    • Add the "PATH=$PATH:/usr/local/cuda/bin"  to your "~/.bashrc" as a last line.
      (or)
      PATH=$PATH:/usr/local/cuda/bin:/home/rajz/install/NVIDIA_CUDA-9.2_Samples/bin/x86_64/linux/release
    • run "deviceQuery" to verify the cuda installation.  And do the post installation formalities
    • sudo apt-get install g++ freeglut3-dev build-essential libx11-dev \
          libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
       
       
       
      References
      1. https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/
      2. https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-together-with-9-2-on-Ubuntu-18-04-with-support-for-NVIDIA-20XX-Turing-GPUs-1236/

Tuesday, August 1, 2017

Installing CUDA on Linux Mint and Hello CUDA Program

CUDA® is a parallel computing platform and programming model invented by NVIDIA. In case you wanted to write parellel programs that runs on GPU. CUDA will be helpful. 
 Things that are need for CUDA programming.
  1. A machine with Nvidia Graphics Card
  2. A Supported Linux, Kernel and GCC  [refer here]
  3. NVIDIA CUDA Toolkit
My System Specs is the following: 

Dell Inspiron. It has a Nvidia Geforce grapics card.


Installation steps:
WARNING- Read the step completely before starting. I ran into issues with some of these step. Only for expert users or else you may have to endup reinstalling you OS.

1. Go here and download NVIDIA CUDA Toolkit deb/runfile. I am using the deb file. It is about 2GB. So, be careful if you got lesser bandwidth or Internet quota.


2. To check if you have a CUDA compatible GPU, version of kernel and gcc.  
rajz@warriorwithin ~ $ lspci | grep -i nvidia
08:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 840M] (rev a2)
rajz@warriorwithin ~ $ uname -a
Linux warriorwithin 4.4.0-71-generic #92-Ubuntu SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
rajz@warriorwithin ~ $ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

3. If nouveau is enabled, then we need to disable it. If the below command prints details which means that it is active. So, just disable it by doing the steps below.
rajz@warriorwithin ~ $ lsmod | grep nouveau
rajz@warriorwithin ~ $ sudo vi /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
add above two lines and run the below command.
sudo update-initramfs -u
4. Reboot!!
5.  lsmod | grep nouveau to check if it is active.
6.  Then run the following command based on your file in Step 1. Mine was the following
rajz@warriorwithin ~/install $ dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
7. Run this sudo apt-get update
8. Run this sudo apt-get install cuda
9. Reboot!!
10. Open  ~/.bashrc file and Add the two lines at the end of file
11. Created a folder under Documents(or wherever you wish) to Install sample files and Run the below
rajz@warriorwithin ~/Documents $ cuda-install-samples-8.0.sh cuda-samples/
12. cd into ~/Documents/cuda-samples/NVIDIA_CUDA-8.0_Samples and do make
13.  Then do the following



14. If it shows up like in the figure. Then it is all fine. 
15. So, far so good. Next up is Hello World CUDA program  


I am unsure if the step 3, 4, 5 are really necessary. But still did it for completeness sake.

ALERT!!!
After Doing these steps. My system went blank after a restart!!!!!
I figured it out that My display is by Intel Graphics Controller.  Where as after NVIDIA Driver installation it set nvidia as my default display or card. So, I was getting a blank screen; Grub loaded. Linux mint Logo appeared. Even login happened. but I can't see any thing. even TTY didn't work. 

Workaround to fix this.
1. During Grub loading. Press 'e'. search a line and prefix nomodeset before quick splash and press enter.
2. It will take you to login. But cinnamon may crash. 
3. Using terminal Uninstall all drivers of nvidia sudo apt-get remove nvidia** 
4. reboot. I reverted the changes I did in step 3,4 of prev installation.
5. Get to know you GPU model from lspci cmd
6. Download http://www.nvidia.com/Download/index.aspx?lang=en-us your driver based on your MODEL, and OS; Mine was this
7. Go to TTY by pressing CTRL+ALT +F1
8. Use cmd to stop display using Card[on Linuxmint] using sudo service mdm stop 
8.1 For ubuntu OS; use sudo service lightdm stop 
9. sudo ./NVIDIA-Linux-x86_64-384.59.run --no-opengl-files
 follow instruction
9.1 I said no only for 32 bit libs; Rest say positively. IMPORTANT.!
10. sudo service mdm start will get you back to GUI mode.
11. Reboot! huh! Hoping that it won't go blank!

Cheers,

Let me know if these steps doesn't work or even if it works! Hope it helps!

References
[1] - www.docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
[2] - https://askubuntu.com/questions/799184/how-can-i-install-cuda-on-ubuntu-16-04
[3] - https://kislayabhi.github.io/Installing_CUDA_with_Ubuntu/

Last Post !! Moved to new site

As I am getting old 😋, it seem like I can not remember many of my earlier tech encounters. This is the place I was logging so that I refer ...