Wednesday, December 22, 2010

Installing pyCUDA-0.94.2 on CentOS 5.5

Installing pyCUDA-0.94.2 can be quite a hassle on CentOS 5.5 Linus OS. As per couple of my posts to the pyCUDA list, I did use the correct parameters while configuring pyCUDA. However CentOS 5.5 ships with gcc-4.1.2 and that gives an error while installing pyCUDA. So I have posted my steps on how I installed pyCUDA-0.94.2 on CentOS 5.5:

Step 1: Change your default gcc to gcc-4.4 and g++ to g++-4.4. I used yum to install them.

$ cd /usr/bin
$ sudo rm /usr/bin/gcc
$ sudo ln -s /usr/bin/gcc44 /usr/bin/gcc
$ sudo rm /usr/bin/g++
$ sudo ln -s /usr/bin/g++44 /usr/bin/g++

Check your installation:

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux6E
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,fortran --disable-libgcj --with-mpfr=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/mpfr-install/ --with-ppl=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/ppl-install --with-cloog=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/cloog-install --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux6E
Thread model: posix
gcc version 4.4.0 20090514 (Red Hat 4.4.0-6) (GCC) 

$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux6E
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,fortran --disable-libgcj --with-mpfr=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/mpfr-install/ --with-ppl=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/ppl-install --with-cloog=/builddir/build/BUILD/gcc-4.4.0-20090514/obj-x86_64-redhat-linux6E/cloog-install --with-tune=generic --with-arch_32=i586 --build=x86_64-redhat-linux6E
Thread model: posix
gcc version 4.4.0 20090514 (Red Hat 4.4.0-6) (GCC)

Step 2:  Unzip pycuda-0.94.2 to your directory and install numpy, pytest and pytools

$ tar xzf pycuda-0.94.2.tar.gz
$ sudo easy_install numpy
install_dir /usr/local/lib/python2.6/site-packages/
Searching for numpy
Best match: numpy 1.5.1
Processing numpy-1.5.1-py2.6-linux-x86_64.egg
numpy 1.5.1 is already the active version in easy-install.pth
Installing f2py script to /usr/local/bin

Using /usr/local/lib/python2.6/site-packages/numpy-1.5.1-py2.6-linux-x86_64.egg
Processing dependencies for numpy
Finished processing dependencies for numpy

$ sudo easy_install pytest
install_dir /usr/local/lib/python2.6/site-packages/
Searching for pytest
Reading http://pypi.python.org/simple/pytest/
Reading http://pytest.org
Best match: pytest 2.0.0
Downloading http://pypi.python.org/packages/source/p/pytest/pytest-2.0.0.zip#md5=f07c521dfd5a540f3dfea1846e58dab7
Processing pytest-2.0.0.zip
Running pytest-2.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-5pyoXO/pytest-2.0.0/egg-dist-tmp-ssbYCg
Adding pytest 2.0.0 to easy-install.pth file
Installing py.test script to /usr/local/bin
Installing py.test-2.6 script to /usr/local/bin

Installed /usr/local/lib/python2.6/site-packages/pytest-2.0.0-py2.6.egg
Processing dependencies for pytest
Finished processing dependencies for pytest


$ sudo easy_install pytools
install_dir /usr/local/lib/python2.6/site-packages/
Searching for pytools
Best match: pytools 11
Processing pytools-11-py2.6.egg
pytools 11 is already the active version in easy-install.pth
Installing runalyzer-gather script to /usr/local/bin
Installing runalyzer script to /usr/local/bin
Installing logtool script to /usr/local/bin

Using /usr/local/lib/python2.6/site-packages/pytools-11-py2.6.egg
Processing dependencies for pytools
Finished processing dependencies for pytools

Step 3: Configure siteconf.py


$ python configure.py --cuda-root=/usr/local/cuda --cudadrv-lib-dir=/usr/lib64/nvidia --boost-inc-dir=/usr/include --boost-lib-dir=/usr/local/lib CXXFLAGS=-DBOOST_PYTHON_NO_PY_SIGNATURES

Step 4: Install
$ sudo make install


Step 5: Test your installation
$ python test/test_driver.py 
=============================================================== test session starts ===============================================================
platform linux2 -- Python 2.6.6 -- pytest-2.0.0
collected 18 items 

test/test_driver.py ..................

============================================================ 18 passed in 4.58 seconds ========================================


If you see the message above, pyCuda should be working now. Enjoy :)


FYI: For installing pyCuda on Ubuntu 10.10, refer to http://wiki.tiker.net/PyCuda/Installation/Linux/Ubuntu



1 comment:

  1. Will I be able to perform image processing using pycuda if I follow all these steps?

    ReplyDelete