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/

Saturday, November 24, 2018

Challenges in installing Linux Mint 19 to dual boot along side windows


 WARNING: There is an updated Install notes. Check out  the recent post
Had a tough time setting/installing up Linux mint 19 on my existing dual boot machine to solve these 2 problems:
1. grub-efi-amd64-signed' package failed to install into /target
2. Hash Sum mismatch.
3. shim-signed and grub-efi-amd64-signed failure to configure.
Huh. Nearly 6 hours trying to figure out.

As it happened:

I had a Linux mint 18 and a rusted windows. So I wanted to refresh my machine. So I reset factory/recovery settings on windows. And wished to install Linux mint afresh. So, I have downloaded the ISO file named linuxmint-19-cinnamon-64bit-v2.iso from the official website and verified. I have made necessary partitions while installing and installation went smooth. However, right after installing and just before grub installation, this error came up.



"GRUB Installation Failed.
The 'grub-efi-amd64-signed' package failed to install into /target/. Without the GRUB boot loader, the installed system will not boot".


To rectify this.
1. install boot-repair
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair 

Open boot repair and run the recommended things. [it took 20mins; be patient] It will FAIL badly. Never mind go ahead and restart it. It worked. Because it has successfully reinstalled grub.

2. apt-get update would not completed it will show error like "Hash Sum mismatch"


E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/binary-i386/by-hash/SHA256/a70a891ed73362c0a3966c9c6c790096f5aba663389ab578a6b991b698ae43c6  Hash Sum mismatch
   Hashes of expected file:
    - Filesize:393124 [weak]
    - SHA256:a70a891ed73362c0a3966c9c6c790096f5aba663389ab578a6b991b698ae43c6
    - SHA1:4e0cfabaaf47b0cbf6ecc284e5281430bbe530d2 [weak]
    - MD5Sum:94742010fa630d152bbff1445f6369b4 [weak]
   Hashes of received file:
    - SHA256:ea9bf28ed7d57e5bd739fc63485459130475026c35a84f25e57d2f5ca0521ec7
    - SHA1:af7bad4e086d5e768c450c77032ee520d58afeda [weak]
    - MD5Sum:aa28e356c8a66b4838a83ab18e10e2d5 [weak]
    - Filesize:393124 [weak]
   Last modification reported: Fri, 23 Nov 2018 12:50:34 +0000
   Release file created at: Fri, 23 Nov 2018 13:51:10 +0000

To resolve this:

sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/partial
sudo apt-get update -o Acquire::CompressionTypes::Order::=gz
sudo apt-get update
 



Resolve steps 2:
I am not sure above steps did resolve it completely. because I was still getting. Hash sum mismatch even after doing that.

Changing the main mirrors to different URL in Software source actually fixed in.

3. New problems:
Everytime I installed some pkg
It would try install some failed installed packages such as
shim-signed
grub-efi-amd64-signed



Resolve steps

sudo rm /sys/firmware/efi/efivars/dump-*
sudo update-grub
sudo apt-get -f install

References
Linux mint and askubuntu forums.

Thursday, November 9, 2017

sed, awk and bash it

Edit the files in folder

1. Chop off few words from the 1st line
2. Reads a particular word from the 1st line and then replaces that with some other word.

More particularly 
1. Removes "p tw" from the 1st line.
2. Replace the 3rd word(in line 1) with "0" in all the lines except line 1.

$cat sample
p tw 5 4
1 2
5 2
3 4
1 5

$cat required-sample
5 4
1 2
0 2
3 4
1 0


#!/bin/bash
for file in `ls *.gr`
do
    nodes=`awk 'NR==1{print $3}' $file` #takes the 3rd word which is n or |V|
    sed -i "1s/p tw //" $file             #chops the p and tw from the 1st line
    echo $file - done $nodes
    sed -i '2,$ s/$nodes/0/g' $file     #f   
done

Thanks to Vijay R



Thursday, September 7, 2017

Resolving expired GPG key and Github signing

My GPG key during creation had default expiry date which I didn't bother to change it at that time. One fine day it got expired. I was using that same key to sign commits on Github . In all my commits it was showing signed with unverified / expired key. However later from "password and keys" i was able to revoke the expiry. Even then after signing it was showing signed with unverified / expired key.

Here are the steps to resolve:
1. Github setting delete the existing GPG key
2. gpg --list-keys
3. gpg --armour --export  YOUR-KEY-ID
4. Copy it to Github GPG settings as new GPG key
5. Try committing and pushing on github!

All your commits have a verified and have a non-expired signature. :-)

Thursday, August 31, 2017

Install Gurobi on Linux and Hello world Gurobi !

Installation

System requirements

Any linux flavour would work
Recent gcc version 

Steps

1. Register Gurobi Optimizer(64b-Linux) Download http://www.gurobi.com/downloads/download-center
2. Register and get an academic licence from the same (note the cmd grbgetkey 36-digit-key )
3. Extract tar file to /opt
4. Generate licence file using the cmd

rajz@warriorwithin :/opt/gurobi751/$ ./linux64/bin/grbgetkey whatever-is-your-key

Note the license file must have got generated!!

6. append at the last line of .bashrc at $HOME/.bashrc using a texteditor

export GUROBI_HOME="/opt/gurobi751/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
export GRB_LICENSE_FILE="/opt/gurobi751/gurobi.lic"

If any useraccount of the machine wants to use it, then they just have to perform step 6 on their ~/.bashrc

Hello World Gurobi Program!

// coming soon

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/

Saturday, May 13, 2017

Installing Gitlab Server

Let me walk through the steps.
  1. sudo apt-get install curl openssh-server ca-certificates
  2. curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 
  3. sudo apt-get install gitlab-ce
  4. In file /etc/gitlab/gitlab.rb
    1. nginx['listen_port'] = 8081
    2. external_url 'http://mithun.cse.iitm.ac.in' 
  5. sudo gitlab-ctl reconfigure
  6. Go to localhost or mithun.cse.iitm.ac.in to set to root's password.
  • Note: We tried setting up as gitlab.mithun.cse.iitm.ac.in but wasn't able to as mithun.cse.iitm.ac.in was already running an apache2 webserver from 80 port.
  • Note: We decided to run on 8081 instead
  • Note: We could have setup as "http://mithun.cse.iitm.ac.in/gitlab" --  I was not in favour of it.
If someone knows how to setup gitlab it as subdomain without affecting the existing webserver. Do let us know. Thank you.

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 ...