Tagged: Fedora 15

nVidia CUDA on Linux (Fedora 15)

I recently updated my desktop with a new graphic card from nVidia — a pretty low-end GT440. It’s actually my first nVidia card. I owned three ATI Radeon cards (Sapphire 9550, 9600Pro and HD2600XT) before. The main reason for this was, that I needed CUDA enabled card in order to be able to work on my school project (I study computer graphics). On top of that, Gnome 3 has some issues with ATI drivers and the HD2600XT is like 5 years old today :-P. Anyway, I recently installed the nVidia CUDA SDK on Fedora 15 and I made a little howto along the way.

Installing gcc

One of the biggest issues in with CUDA is that it officially supports only gcc of version 4.4 and earlier. That’s a bummer, especially on Fedora, where there is gcc-4.6 by default and you need to compile the older version yourself. I posted series of steps to compile gcc from sources in a separate article Multiple Versions of gcc on Fedora 15.

Drivers

There is something called Developer Drivers for Linux available from the nVidia website. I don’t know what it is or how is it different from the original drivers, but I couldn’t make them work. The installation kept dying with some error with kernel headers.

Good news is, that you don’t need them. At least I was able to compile and run the CUDA SDK without installing these only with the standard nVidia proprietary driver (version 285.05.09). If you’re running them, you’re fine. In case you have the noveau open-source drivers you need to get rid of them and install the nVidia proprietary driver.

There is one little thing you need to do if you chose not to install the developer drivers: make a symlink for libcuda.so like this

su
cd /usr/lib
ln -s nvidia/libcuda.so libcuda.so

CUDA Toolkit

This is pretty straight-forward. Download and run shell script from the nVidia download page. Choose what’s closest to your distro. In this case it’s Fedora 13. Fedora 15 is officially unsupported due to the lack of old gcc. But we have sorted this earlier, so it’s fine to use the F13 pack.

wget http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/4_0/toolkit/cudatoolkit_4.0.17_linux_32_fedora13.run
sudo sh cudatoolkit_4.0.17_linux_32_fedora13.run

In case you’re prompted with question where to install the toolkit, just hitto keep the defaults.

GPU Computing SDK

Installing the SDK is as easy as the toolkit. Download and run the script from nVidia homepage. This time you won’t need root permissions, because it will install into your home folder.

Setting System Path

The tricky part is here, now you need to make sure all  the libraries and tools are present in the correct environment variables. Edit your ~/.bashrc file and add the following:

# CUDA
export PATH="$PATH:/usr/local/cuda/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib"

Reopen your shell and you should be able to run the nvidia C compiler. Make sure by trying this

 nvcc --version

The last step is trying to compile all the examples in the SDK. Change to that directory and simply run make.

 cd /NVIDIA_GPU_Computing_SDK
 make

Everything should be working. There will be a lot of warnings during the compilation, but we just have to ignore that …

Sources

Multiple Versions of gcc on Fedora 15

This post describes a way of building and installing additional versions of GNU gcc compiler on Fedora 15. The version shipped with Lovelock is gcc 4.6.1 which can sometimes be too new. Some apps such as nVidia CUDA SDK requires a specific version of compiler for some reason. In this howto I’ll be installing gcc-4.4.6.

Notice: There is an official installation guide that will help you if something doesn’t work (or I forgot to mention something here).

1. Getting the Source

I guess, nobody will be surprised when I say, that the first step is to obtain the sources. Go to http://gcc.gnu.com, pick a mirror and download the version you need. The best option is usually downloading the package with all languages included (e.g. gcc-4.4.6.tar.gz). We will unpack the archive and rename the directory to source/. It is also recommended to build the binaries into a separate directory from the sources, so we’ll create a build/ folder too:

 $ tar xzf gcc-4.4.6.tar.gz
 $ mv gcc-4.4.6/ source/
 $ mkdir build/

2. Configure

Now we have everything in place, we need to configure the build. Change into the build/ directory and call the configure script:

 $ cd build/
 $ ../source/configure --prefix=/opt/gcc4.4.6 \
                       --program-suffix=-4.4

As you can see, there are some parameters. --prefix option says where should be the gcc installed after the build. We will install it separately into the /opt directory, so it will be easily removable in the future only by deleting the respective directory. --program-suffix will be added to the name of the executable (in this case gcc-4.4), so it doesn’t collide with other installed versions of gcc on your system.

Warning: Be careful with the --program-suffix option. You might have to make some symlinks to use the compiler in some vendor Makefiles. It will be explained later in this post.

Optionally you can add --enable-languages=c,c++ to choose what languages support will be compiled. For more options, refer to the official guide above.

In case the configure script fails, you probably don’t have all the necessary packages installed to perform the build. See what’s missing and install it with yum. For me the following was enough:

 $ su
 # yum groupinstall "Development tools"
 # yum install mpfr-devel

The full list of prerequisites can be found here.

3. Build

The build is fairly simple, if you see some warnings, feel free to ignore them. To build gcc write the following inside the build/ directory:

 $ make

Now is the time to get some coffee, because it will take a while to build.

4. Installation

Installation is also quite easy. You can install gcc by writing

 $ su
 # make install

Then check whether the installation was correct and everything is in place

 $ /opt/gcc4.4.6/bin/gcc-4.4 --version

5. Using alternate compiler

Using the alternate compiler is a little tricky. You can it to your system path by appending this line to your ~/.bashrc file.

export PATH="/opt/gcc-4.4.6/bin:$PATH"

The alternate compiler is available through gcc-4.4 name (as we defined in the configuration phase). That is cool for your Makefiles, but some vendors hardcode compiler name into their Makefile which doesn’t help at all. If this is your case, the best way to get things to work is to make symlinks to the alternate gcc and append the directory to the begining of $PATH  string. Here are example symlinks for gcc and g++:

su
cd /opt/gcc-4.4.6/bin
ln -s gcc-4.4 gcc
ln -s g++-4.4 g++

Note, that the system look-up in the $PATH folder is sequential, so if you append the directory to the front of the variable, it will have higher priority. If you need to use the newer compiler again, simply remove the directory from path by commenting out the line in ~/.bashrc. Remember, you can always find out version of your current gcc by writing

 $ gcc --version

Sources

Installing Brother HL-2035 on Fedora 15

This is a step-by-step how-to on installing drivers for Brother HL-2035 printer. I installed it on Fedora 15 Linux, but it should work on most other distributions as well (with some alterations). Let’s get on with it.

Step 1: Download the official drivers

First and foremost you’ll need to download drivers for this printer from Brother’s website. They don’t supply HL-2035 drivers only HL-2030 so get those (download both files LPR driver and cupswrapper driver). For Fedora get the .rpm. On Ubuntu or any other Debian-based system you’ll probably want the .deb packages.

Step 2: Install the drivers

Now install the downloaded files either by double-clicking on them or from terminal. Make sure you install LPR driver first.

 $ sudo rpm -ihv brhl2030lpr-2.0.1-1.i386.rpm
 $ sudo rpm -ihv cupswrapperHL2030-2.0.1-1.i386.rpm

There is an installation guide for the drivers at Brother’s website. You can try following that if something goes wrong. Just omit the –nodeps option. When you’re done installing restart cups by writing

 $ sudo /etc/init.d/cups restart

Step 3: Add cups printer

Open your favourite web browser and go to http://localhost:631/. A nice cups homepage should show up. Go to Administration -> Manage printers and see if the printer is there. If not, you will need to add it.

CUPS Printers List

To add new printer go back to administration and click on add printer. A dialogue will pop-up asking for your credentials. Use root as user name and your system’s root password. Then select the Brother HL-2030 series (Brother HL-2030 series) from local printers and hit Continue. Leave defaults on the second screen, Continue again. On the last screen of the wizard you’ll be asked what drivers to use. We’ll do it by supplying the PPD file for HL-2035. Download the PPD, select it in the form and finish the wizard.

Done!

The printer should be working by now and you should see it among printers in cups and be able to print.

New to Fedora

Just yesterday, after a long time of evaluating all pro’s and con’s I finally decided to install Fedora 15 on my desktop machine. I’ve been using debian-like distros since high school and I’ve gotten used to it pretty hard over the years. I started with Ubuntu 7.04, then switched to Kubuntu to enjoy some KDE. Then by the time I went to college I was using Debian, which made me happy for some time. After Debian I switched back to Ubuntu.

Now, why did I decide for Fedora? Well, the Ubuntu on my machine was quite outdated and the new 11.04 comes with Unity and software centers. Well, I just wanted to try something different. On top of that, Fedora 15 comes with the new Gnome 3!

Gnome 3 Shell

Gnome 3 Shell

Now, after the install and some babysteps with Fedora, I have to say it’s pretty amazing :-). The Gnome 3 environment is FAR from perfect, but it’s usable. In my opinion it’s way better than the KDE4. It takes some getting used to, but not that much actually. I was pretty bummed out without a task bar, the top menu, but I see, that I don’t need those anymore :-).