Difference between revisions of "GPU610/DPS915 Ubuntu and CUDA Installation"

From CDOT Wiki
Jump to: navigation, search
(Part 3: Getting Ubuntu ready for CUDA Development)
(Part 3: Getting Ubuntu ready for CUDA Development)
Line 93: Line 93:
 
And put the following in the bash profile:
 
And put the following in the bash profile:
  
export CUDA_HOME=/usr/local/cuda-5.0  
+
export CUDA_HOME=/usr/local/cuda-5.0
 +
 
 
export LD_LIBRARY_PATH=${CUDA_HOME}/lib
 
export LD_LIBRARY_PATH=${CUDA_HOME}/lib
 
   
 
   
 
PATH=${CUDA_HOME}/bin:${PATH}  
 
PATH=${CUDA_HOME}/bin:${PATH}  
 +
 
export PATH
 
export PATH
  

Revision as of 22:30, 14 January 2013

Ubuntu 12.04 LTS and CUDA Toolkit 5 Environment Installation/Step Guide

Important Notes

This guide is still a work in progress. Expect revisions, changes, and additions on a frequent basis in the near future.

This guide is not a guide on how to use Ubuntu, Unix commands, github, or anything else except for getting CUDA and Ubuntu to play nicely together. You should be comfortable with executing Unix commands (the stuff you learned first-year should be entirely adequate.) If you have any questions or concerns as it relates to this guide, feel free to email me at stsang1@myseneca.ca and I'll do my best to address your issue...if it's within my knowledge.

This guide targets version 12.04 LTS of Ubuntu and CUDA Toolkit 5. While version 12.10 of Ubuntu has since been released, certain students have experienced trouble getting 12.10 and CUDA to play nicely together - hence the guide sticks with 12.04 LTS for the sake of less headaches. We also strongly recommend you install Ubuntu on an separate/external hard drive of which there is no existing OS installed to keep the installation process simple as possible. This guide assumes this. Ubuntu's installation footprint is very modest (well less than 10GB) so even a cheap small old hard drive will do.


Part 1 – Create bootable media for Ubuntu installation

While these instructions are for creating a bootable CD/DVD, you can also try alternate installation methods (such as bootable USB stick) if you so choose. See the documentation at https://help.ubuntu.com/12.04/installation-guide/i386/install-methods.html for more information.

Go to http://www.ubuntu.com/download/desktop and select the 32-bit version of Ubuntu 12.04 LTS, and download the ISO. Then use the image burning software of your choice and burn the ISO onto a CD or DVD.

Part 2 - Install Ubuntu 12.04 LTS

Boot using your installation media of choice. It will take up to several minutes for the Ubuntu installer to load and display on your screen, so be patient. During this time you should see a little man and a keyboard appear at the bottom of your screen briefly. Once the installer appears on your screen, follow the step-by-step instructions UP TO STEP 4 (stop at Step 4, then read the important note about Step 4 below first) at the official Ubuntu installation guide. Then proceed with the rest of the steps in the link provided.

During this process, I selected Download Updates while Installing. You can also safely download the third-party software if you want some extra convenience on Ubuntu.

IMPORTANT NOTE ABOUT STEP 4

In Step 4 you may have differing options depending on where you are installing Ubuntu (primary hard drive, second/external hard drive, whether or not there are existing OSes on your target hard drive, etc.) It is VERY important that you choose the correct device and/or partition for installation. As such, when the option presents itself in the drive/partition selection stage of the installation, I very strongly recommend you use the advanced partitioning tool instead of the graphical partitioning tool. Usage of the visual tool has resulted in disastrous consequences in a dual-boot environment (the author and others have had their Windows 7 MBR overwritten by Ubuntu when using the visual tool - this is a known problem with Ubuntu).

See this guide on how to properly set up your partitions using the advanced tool (skip to/search for 4. Something else (advanced) in that page). The guide suggests a size of 2048MB for the swap partition - I went up to 8000MB with no problem, so you don't have to follow the numbers exactly. The guide also creates a /home partition for easier reinstalling - you can skip the /home partition and just have a / partition. Your choice. In the "Device for boot loader installation" drop down menu, MAKE SURE you've selected the correct hard drive. Once you've configured your partitions correctly, proceed with the installation. Reboot your computer when prompted to.

Part 3: Getting Ubuntu ready for CUDA Development

1. The Ubuntu Update Manager will prompt you shortly after first boot about installing many updates. I recommend you proceed with the updates; they will take quite some time to download and install though.

2. Install all the vital development tools for Ubuntu. Open a Terminal and execute the following command:

sudo apt-get install libxi-dev libxmu-dev freeglut3-dev build-essential binutils-gold

If necessary for your project, get Git as well:

sudo apt-get install git

If you want to run the Toolkit samples, then you'll need some other things: OpenGL driver: sudo apt-get install freeglut3-dev libxi-dev libxmu-dev

OpenMPI: sudo apt-get install mpi-default-dev

Depending on which sample you run, you'll probably need other packages. Good luck.

3. The last two things we need to do now are install an appropriate proprietary NVIDIA display driver for Ubuntu and the CUDA 5 Toolkit. Depending on which driver you want to install; the driver version needs to be at least 304.54 for Linux. You can install the driver that comes with the CUDA 5 Toolkit package (which at the time of writing is 304.54), or install a newer driver from Ubuntu (namely 310.) Both methods require differing additional work and will slightly change the way you install the CUDA Toolkit.

Installing a driver from Ubuntu

Go to System Settings (click on the Cog icon on the top right corner of Ubuntu and go to System Settings), then Additional Drivers. You will see a list of nvidia display drivers; install the experimental-310 display driver as the other two are not recent enough. Reboot your computer.

Next, download CUDA 5 Toolkit with the following commands at a Terminal:

cd ~/Desktop

wget http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_linux_32_ubuntu11.10-1.run

Now we install the CUDA 5 toolkit.

chmod +x cuda_5.0.35_linux_32_ubuntu11.10-1.run'

sudo ./cuda_5.0.35_linux_32_ubuntu11.10-1.run

I suggest sticking with the default installation paths for simplicity's sake. Also, type 'n' when asked if you want to install NVIDIA drivers from the Toolkit.

Installing a driver from the CUDA Toolkit

cd ~/Desktop

wget http://developer.download.nvidia.com/compute/cuda/5_0/rel-update-1/installers/cuda_5.0.35_linux_32_ubuntu11.10-1.run

Logout your Linux desktop and switch to console mode with the Alt+Ctrl+F2 keystroke. You then login the text console, and stop the graphical display manager:

sudo service lightdm stop

You may have to enter the same Alt+Ctrl+F2 keystroke again to resume the text console. Now install the CUDA Toolkit:

sudo sh ./cuda_5.0.35_linux_64_ubuntu11.10.run

I suggest sticking with the default installation paths for simplicity's sake. Also, type 'y' when asked if you want to install NVIDIA drivers from the Toolkit. And reboot afterward:

sudo reboot

4. Setting Environment Variables

We'll need to set environment variables so that the compiler can find all the necessary CUDA libraries when compiling. In a terminal, type

gedit ~/.bash_profile

And put the following in the bash profile:

export CUDA_HOME=/usr/local/cuda-5.0

export LD_LIBRARY_PATH=${CUDA_HOME}/lib

PATH=${CUDA_HOME}/bin:${PATH}

export PATH

Note: If you installed an experimental driver from Ubuntu, you'll need to add it's path to LD_LIBRARY_PATH for libcuda.so. Look for the driver folder under /usr/lib/nvidia-experimental-XXX, where XXX is the driver number (e.g. 310). Thats the path you want. Then the export LD_LIBRARY_PATH line in the bash_profile file becomes

export LD_LIBRARY_PATH=${CUDA_HOME}/lib:/usr/lib/nvidia-experimental-310

You should now be ready to test your CUDA installation.

Part 4: Test CUDA Toolkit Installation

In a terminal, go to ~/NVIDIA_CUDA-5.0_Samples. Then enter the make command, and let all the samples compile (this will take some time). If you get no compilation errors right away, that's good! It is entirely possible that not all the samples will successfully compile as each sample has its own set of dependencies. There is definitely one sample you'll want to run, though. From the ~/NVIDIA_CUDA-5.0_Samples folder, go to /bin/linux/release subfolder, and run the deviceQuery sample (./deviceQuery). If it runs and you see information about your CUDA device, you've made it! :)