Thursday, August 31, 2017

Install Gurobi on Linux and Hello world Gurobi !


System requirements

Any linux flavour would work
Recent gcc version 


1. Register Gurobi Optimizer(64b-Linux) Download
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 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-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.

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


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

[1] -
[2] -
[3] -

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