About Me

A Computer Enthusiast who's learning as much as I can, while attempting to share and re-distribute the knowledge! Enjoy! :D

Sunday, October 30, 2011

CUDA on Linux and OS X Lion - Updated

I wrote a quickstart sometime last year for CUDA on Linux and OS X. Here's an updated version covering CUDA 4.0 for Linux and OS X Lion. I will be installing the Toolkit and Example in my home directory. However, feel free to deviate and install in the normal system directories. Additionally, I'm using 64-bit version rather than 32-bit.

Please refer to NVIDIA's CUDA website to confirm your video card is CUDA ready. You can also check it here.

1.  Unless you have the proprietary NVIDIA Drivers already installed, download the appropriate Developer Drivers from here. Click on "Get Latest CUDA Toolkit".

2. Install the drivers as root. If you've installed Proprietary NVIDIA drivers before, the process is the same (for Linux).

Linux:
//**********
  • Ctrl-Alt-F2
  • Log in as root (as yourself on Ubuntu)
  • Stop your window manager: telinit 3 usually does it. For Ubuntu, try sudo service gdm stop (this assumes your running GNOME).
  • Become root (if not already) or utilize sudo for Ubuntu
  • Navigate to the directory where you've downloaded the NVIDIA graphic drivers
  • Run sh dev_driver_name.run. Try sudo sh dev_driver_name.run
//**********
 OS X:
//**********
  • Run devdriver.dmg
//**********

3. Download and install CUDA Toolkit.

Linux:
//**********

shell$ cd Downloads
shell$ sh cudatoolkit.run

For "enter install path", I used my home directory: /home/myname. You may utilize default path if needed.

//**********

OS X:
//**********
  • Run cudatoolkit.pkg
//**********

4. Update your PATH and LD_LIBRARY_PATH:

Linux:
//**********

PATH - /Path/To/Your/CUDA/Install/bin (my version --> /home/myname/cuda/bin)
LD - /Path/To/Your/CUDA/Install/lib (my version --> /home/myname/cuda/lib64:/home/myname/cuda/lib)

//**********

OS X:
//**********

PATH - /usr/local/cuda/bin
DYLD - /usr/local/cuda/lib

//**********

5. Download and install GPU Computing SDK

Linux:
//**********

shell$ cd Downloads
shell$ sh gpucomputingsdk.run

For "enter install path", I accepted the default. This is dependent upon where your CUDA Toolkit is installed. Additionally, you will be asked to confirm your CUDA installation directory.

//**********

OS X:
//**********
  • Run  gpucomputingsdk.pkg
//**********

6. Make the example programs.

Linux:
//**********

shell$ cd NVIDIA_GPU_Computing_SDK
shell$ cd C
shell$ make

//**********

OS X:
//**********

shell$ cd /Developer/GPU\ Computing/C
shell$ make

//**********

You have a fully functional CUDA environment. Run a few of the example programs to test your environment. Good luck!

Thursday, October 27, 2011

OpenMPI Quickstart - Updated

I wrote a quickstart sometime last year for OpenMPI on Linux. Here's an update for OpenMPI for Linux and OS X Lion.

1. Download the latest openmpi source files:
 2. Find out how many processors are available to utilize (optional).

Linux:
//**********

shell$ grep 'processor.*:' /proc/cpuinfo | wc -l

//**********

OS X:
//**********

shell$ system_profiler | egrep "Processors|Cores"
      Number of Processors: 1
      Total Number of Cores: 2

//**********

3. Move the downloaded file to your home directory, and untar the file.

Linux and OS X:
//**********

shell$ cp openmpi-1.4.4.tar.bz2 ~
shell$ cd
shell$ tar -xvjf  openmpi-1.4.4.tar.bz2

//**********

4. cd into the newly created openmpi directory and view the INSTALL file. Here you will find more information on how to install OpenMPI.

Linux and OS X:
//**********

shell$ cd openmpi-1.4.4
shell$ less INSTALL

//**********

5. Run configure and append the prefix option with your preference for the binary installation location.

Linux and OS X:
//**********

shell$ ./configure --prefix=$HOME/openmpi

//**********

6. Run 'make all install'

Linux and OS X:
//**********

shell$ make all install

//**********

7. cd into your home directory and edit your .bash_profile or .bashrc (.cshrc for c shell) to include the bin install location within your PATH. Don't forget to source it.

Linux and OS X:
//**********
shell$ cd
shell$ vi .bashrc

export PATH=$PATH:$HOME/openmpi/bin

shell$ source .bashrc
shell$ which mpic++
/home/username/openmpi/mpic++

//**********

You now have a fully functionally parallel processing environment! Good luck!