Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1804223
  • 博文数量: 290
  • 博客积分: 10653
  • 博客等级: 上将
  • 技术积分: 3178
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-24 23:08
文章存档

2013年(6)

2012年(15)

2011年(25)

2010年(86)

2009年(52)

2008年(66)

2007年(40)

分类: LINUX

2010-01-14 14:58:10

NVIDIA CUDA on Ubuntu Karmic Koala and GCC 4.4


NVIDIA’s currently released version of CUDA does not directly with Ubuntu 9.10 which uses GCC 4.4 as the default compiler. However, it is quite easy to make it work and the following guide goes through the entire installation process in some detail.

I use the 64bit version of CUDA, go here to get it:
http://www.nvidia.com/object/cuda_get.html
(I selected Linux 64 bit and  Ubuntu 9.04 .)

This lets you download the CUDA Drivers, the CUDA Toolkit and the CUDA SDK, and you will end up with three files:

cudadriver_2.3_linux_64_190.18.run
cudatoolkit_2.3_linux_64_ubuntu9.04.run
cudasdk_2.3_linux.run

Installing the NVIDIA driver:

Cuda needs at least version 190 of the linux driver

1.

Uninstall existing NVIDIA drivers and nvidia-glx. (Use gui or aptitude).

2.

Install driver:

Quit x (log out of your desktop, go to a virtual terminal (CTRL+ALT+F1), login, run

$ sudo service gdm stop

3.

Run

$ sudo cudadriver_2.3_linux_64_190.18.run

to install the driver, follow the prompts.
Say yes to install 32 bit compatibility libraries.
If you want you can let the installer overwrite the Xorg configuration file.

4.

Reboot and log back in.

5.

Run

 $ nvidia-settings

to verify that your driver version is at least 190.18. Look for the driver version in the window:

The 190.xx NVIDIA Driver for use with CUDA.

Installing the CUDA Toolkit:

After having installed the driver we now need to install the CUDA toolkit itself.

1.

Run:

$ sudo sh cudatoolkit_2.3_linux_64_ubuntu9.04.run

2.

Press enter to install at the

/usr/local/cuda

default location.

3.

Register the new library files, run:

$ sudo gedit /etc/ld.so.conf.d/cuda.conf

and add

/usr/local/cuda/lib64

to the otherwise empty file and save it. Then run:

$ sudo ldconfig

You can also add

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

to the end of your ~/.bashrc file.

(You should then login and out again of start a new bash with

bash --

to update your environment.

Installing the CUDA SDK and Compiling the Example Programs

We will now install the CUDA SDK to your own home directory so you can play with the supplied demos:

1.

Run:

$ sh cudasdk_2.3_linux.run

I chose to install it at the default location.

2.

As CUDA does not yet work with GCC 4.4 you will have to  install gcc-4.3:

$ sudo aptitude install gcc-4.3 g++-4.3

3.

Go to SDK source dir:

cd ~/NVIDIA_GPU_Computing_SDK/C$

4.

Create a directory and create symlinks to gcc-4.3/g++-4.3

$ mkdir mygcc
$ cd mygcc
$ ln -s $(which g++-4.3) g++
$ ln -s $(which gcc-4.3) gcc
$ cd ..

5.

Edit common makefile:

$ gedit common/common.mk

Find the lines that specify CC, CXX and LINK and change them to:

CXX        := g++-4.3
CC         := gcc-4.3
LINK       := g++-4.3 -fPIC

Add

#use gcc-4.3
NVCCFLAGS+=--compiler-bindir=${HOME}/NVIDIA_GPU_Computing_SDK/C/mygcc

Before the line that says “ifeq ($(nvcc_warn_verbose),1)”. This tells the nvcc computer that it should look in mygcc for gcc, which will cause it to pickup our gcc-4.3 compiler.

6.

You should now be able to compile everything by running

$ make

This should now compile all the examples in the SDK without errors.

Verify Installation

We can now verify that everything is working:

阅读(2461) | 评论(0) | 转发(0) |
0

上一篇:cuda编程总结 : 一

下一篇:GPU 硬件实现

给主人留下些什么吧!~~