Skip to content
run4flat edited this page Jun 27, 2011 · 7 revisions

At the moment, this wiki page holds information about installing ExtUtils::nvcc. The currently documented operating systems are Ubuntu (need a link). (Windows should hopefully follow soon.)

Installing on Ubuntu

Right now, Ubuntu 10.10 is the only known platform for which the system successfully builds. This only works with a full installation---not a liveCD---because you will need to install drivers from nVidia and restart your system. Windows users will have an easy time taking Ubuntu for a drive using Wubi. If you don't use windows and want to take ExtUtils::nvcc for a drive, you'll probably have the best luck installing Ubuntu onto a USB stick. (I'm not sure how big it needs to be, but I'll bet you'll need 2GB, maybe more.)

Once you have a working version of Ubuntu 10.10, follow these steps.

Install the nVidia drivers

I attempted to install Canonical's packaged version of the drivers and my display didn't work. To avoid this hassle, I recommend downloading and running nVidia's driver software directly from nVidia. Save that in a place where you won't delete it, because whenever Ubuntu brings in a kernel update, you'll need to recompile the kernel module.

In order to install the driver modules, you will need to have single-access root. To do this, log out of your system and go to a virtual terminal to by pressing CTRL-ALT-F2. Then:

$ sudo su
  # gets you into administrator mode
$ init 3
  # gets you into single-use mode
$ cd Downloads
  # navigate to wherever you downloaded the drivers
$ sh NVIDIA-Linux-x86-275.09.07.run
  # install the drivers (your version number may differ)
$ reboot
  # reboot your system

This creates and installs the kernel modules for your drivers, so whenever Ubuntu issues a kernel update, you'll need to do this again.

Install the nVidia Toolkit and the Build Tools

Having installed the drivers, you'll need the nVidia toolkit. You can download that by going to nVidia's CUDA download page, choosing the Latest CUDA Toolkit, scrolling down to find the Linux downloads, and in particular finding the Ubuntu download. Download and run that installation process as root (note the version number may differ):

$ sudo sh Downloads/cudatoolkit_4.0.17_linux_32_ubuntu10.10.run

That will tell you to update your environment variables to include the various paths. To do that, edit /etc/environment:

$ suda nano /etc/environment

Change the path assignment by adding "/usr/local/cuda/bin:" to the front. Then create and edit a CUDA linker configuration file:

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

and add these lines:

# CUDA lib path:
/usr/local/cuda/lib

Apply them by running the ldconfig command:

$ sudo ldconfig

Note that all the paths I use here are the defaults. If you used a different path in your installation, you'll need to modify them accordingly.

The debian build tools are packaged under build-essential. You'll need to install those in order to compile your modules:

$ sudo apt-get install build-essential

Install ExtUtils::nvcc

With everything in place, you can now install ExtUtils::nvcc. Since this is moving target, you might want to keep everything up-to-date by working directly with the source code from git. However, the module should get periodic updates on CPAN and you should be able to install it that way if you prefer.

Using git

To follow the development, you'll need to have git installed:

$ sudo apt-get install git

Then clone this repository into a working directory:

$ git clone git://github.com/run4flat/perl_nvcc.git

Once you've pulled that in, you can build the system with the normal incantation.

$ cd perl_nvcc
$ perl Build.PL
$ ./Build
$ ./Build test
$ sudo ./Build install

If the tests fail complaining about libcudart.so.4 or some such file, you probably didn't set up your paths correctly. Try this:

$ export PATH="usr/local/cuda/bin:$PATH"
$ export LD_LIBRARY_PATH="/usr/local/cuda/lib"
$ ./Build test

If you have Inline::C installed, you can begin playing with ExtUtils::nvcc by copying examples/InlineCUDA.pl to your own directory.

Using CPAN

If you prefer to install your module from CPAN, that's as easy as:

$ sudo cpan ExtUtils::nvcc

If you get trouble with libcudart.so.4, try this:

cpan> look ExtUtils::nvcc
$ export PATH="usr/local/cuda/bin:$PATH"
$ export LD_LIBRARY_PATH="/usr/local/cuda/lib"
$ ./Build test

If the tests pass now, it means you didn't set up your paths correctly. Go ahead and install the module (if they pass) with a './Build install' and be sure to set up /etc/environment as described above. You may to sign out and sign back in, or possibly reboot your system, for these settings to take effect.

If you have Inline::C installed, you can begin playing with ExtUtils::nvcc by saving the example in examples/InlineCUDA.pl to a file on your local hard drive.

Installing on Windows

ExtUtils::nvcc does not work on Windows yet, but I am working on it actively. I have worked with this on Windows XP, so if you're using a different version of Windows, your mileage may vary.

The most important caveat when working with Windows is that nvcc only works with cl.exe, Microsoft's Visual C++ compiler. It does not work with gcc, which means that ExtUtils::nvcc will not work with Strawberry Perl or Cygwin. Sorry. As such, you have two options. First, you can install ActivePerl, or you can build your own Perl. These instructions assume you build your own Perl. If you have experience doing this with ActivePerl, feel free to update the wiki!

As if that weren't bad enough, I wrote this documentation from memory. I may have missed a thing or two. Please update the wiki or send me an email with your corrections if you find mistakes!

Install the nVidia Developer Drivers and CUDA Toolkit

You can find nVidia's drivers and the CUDA toolkit by going to nVidia's CUDA download page, choosing the Latest CUDA Toolkit, and scrolling down to find the Windows downloads. You'll need to download and install both the developer drivers and the CUDA toolkit.

Install Microsoft Visual Studio

You can download a version of Microsoft Visual C++ Express for evaluation purposes here.

Download, Build, and Install Perl

You should be able to work with ActvePerl, but I recommend downloading and building your own Perl. It's not hard and this way you'll have the latest Perl available, as well as a fully consistent build environment. (I'll say it again: this does not work with Strawberry Perl or Cygwin.)

Before we get going, you'll need to download an unzipping utility. I went with 7zip because in Windows I prefer to work with GUI stuff, but you should work with whatever makes you most comfortable. Once you have something that can decompress .tar.gz files, download the Perl source code. Unzip that to a working directory.

At this point we will begin the command-line process. Open the Visual Studio Command Prompt via Start -> All Programs -> Microsoft Visual Studio -> Visual Studio Command Prompt. Change to the directory where you unzipped your Perl source code (for me that was C:\Documents and Settings\david\My Documents\5.14.1, for example). It wouldn't be a bad idea to read the Windows README file (try 'more README.win32'), but it'll probably be a lot easier to read that online on CPAN. It's a good document to read, but the most important points are these. First, the make process will execute from the win32 directory. Second, you'll need to edit the (thoroughly documented) Makefile so that it knows all the details about your build setup. Finally, when that's all set, run nmake:

> cd win32
> edit Makefile
> nmake
> nmake test
> nmake install

The test phase is not strictly necessary, but it's always good to test, right?

Install ExtUtils::nvcc

With everything in place, you can now install ExtUtils::nvcc. Since this is moving target, you might want to keep everything up-to-date by working directly with the source code from git. However, the module should get periodic updates on CPAN and you should be able to install it that way if you prefer.

Using git

To follow the development, you'll need to install msysgit. Once you've completed that, clone this repository into a working directory:

> git clone git://github.com/run4flat/perl_nvcc.git

Once you've pulled that in, you can build the system with the normal incantation.

> cd perl_nvcc
> perl Build.PL
> Build
> Build test
> Build install

If you have Inline::C installed, you can begin playing with ExtUtils::nvcc by copying examples/InlineCUDA.pl to your own directory. However, it will almost certainly fail if you are working in your "My Documents" folder. See Issues with Spaces in Directory Names, below.

Using CPAN

If you prefer to install your module from CPAN, that's as easy as:

> cpan ExtUtils::nvcc

However, be sure to setup CPAN's build_dir to a directory without spaces (which you'll have to put in your root directory):

cpan> o conf build_dir C:\builddir
cpan> o conf commit

If you have Inline::C installed, you can begin playing with ExtUtils::nvcc by saving the example in examples/InlineCUDA.pl to a file on your local hard drive.

Issues with Spaces in Directory Names

The working directories for normal users are in the folder "Documents and Settings" and unfortunately the makefile does not properly quote these directories. You will be well served if you create a root directory on your harddrive that does not have spaces, and make sure that your CPAN configuration works there by setting build_dir to it. See the section above on CPAN. Note that this will likely impose limitations on where you can use Inline scripts, unless you manage to coerce Windows into using the 8.3 forms (which I've never figured out how to do.)