6
OpenCL Installation Manual Index : About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Chapter 1 : How to install OpenCL and PyOpenCL ?! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2 : How to link the Python Interpreter to work with PyOpenCL ?! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

OpenCL and PyOpenCL Installation Manual

Embed Size (px)

Citation preview

Page 1: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

Index :

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Chapter 1 : How to install OpenCL and PyOpenCL ?! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

Chapter 2 : How to link the Python Interpreter to work with PyOpenCL ?! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6

Page 2: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

2 | O p e n C L I n s t a l l a t i o n M a n u a l © Copyright 2010, Hosain Ali “[email protected]”.

About the Author : Hosain Ali, undergraduate student at Faculty of Engineering (Alexandria University),

Computer and System Engineering department.

Introduction : This manual aims to let the ordinary people to install OpenCL API , and work with it. It

also may help to install PyOpenCL which lets you access the OpenCL parallel computation API

from Python.

Most of the material gathered from

http://mathema.tician.de/software/pyopencl

http://wiki.tiker.net/PyOpenCL/Installation/Windows

you can also find the complete PyOpenCL documentation which helps a lot in writing programs at

http://documen.tician.de/pyopencl/reference.html

I’m happy to receive your feedback at [email protected]

Page 3: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

3 | O p e n C L I n s t a l l a t i o n M a n u a l © Copyright 2010, Hosain Ali “[email protected]”.

How to install OpenCL and PyOpenCL ?!!

1- Microsoft Visual Studio C++ 2008 Express

Description : on which you will right your C/C++ programs that should be run using

OpenCl libraries

Download link : download VC

2- ATI Stream SDK v2 Beta or Nvidia's OpenCL GPU driver and OpenCL SDK

Nvidia's OpenCL GPU driver

Description : allow developers to harness the massive parallel computing power of

NVIDIA GPUs to create compelling computing applications (OpenCL).

Download link : download Nvedia driver

ATI Stream SDK v2 Beta

Description: The ATI Stream Software Development Kit (SDK) is a complete development

platform created by AMD to allow you to quickly and easily develop applications

accelerated by ATI Stream technology. The SDK allows you to develop your applications

in a high-level language, OpenCL™ (Open Computing Language).

Download link : download ATI stream SDK

Note : I prefer to install Nvidia's OpenCL GPU driver and OpenCL SDK cause it more stable and all

ATI versions are beta version, but in many cases it may not work with your PC if u have not least

specification of Nvidia hardware which is .

If you failed to install Nvidia driver, try ATI Stream-SDK.

With these steps and step(5) you can run OpenCL programs written in

C/C++

3- last version of Python

Download link : download python

Note : I prefer to download Python 2.6.4 as it is more existing third party software is compatible

with Python 2 than Python 3 right now.

Page 4: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

4 | O p e n C L I n s t a l l a t i o n M a n u a l © Copyright 2010, Hosain Ali “[email protected]”.

4- Numpy 1.3 and SciPy 0.7.1

Together, they run on all popular operating systems, are quick to install, and are free of charge. NumPy and SciPy are easy to use, but powerful enough to be depended upon by some of the world's leading scientists and engineers.

NumPy

Description : NumPy is the fundamental package needed for scientific computing with Python. It contains among other things:

a powerful N-dimensional array object sophisticated (broadcasting) functions tools for integrating C/C++ and Fortran code useful linear algebra, Fourier transform, and random number capabilities.

Besides its obvious scientific uses, NumPy can also be used as an efficient multi-dimensional container of generic data. Arbitrary data-types can be defined. This allows NumPy to seamlessly and speedily integrate with a wide variety of databases.

Download link : download Numpy (compatible with Python 2.6)

Choose preferred ver of Numpy

SciPy

Description : SciPy (pronounced "Sigh Pie") is open-source software for mathematics, science, and engineering. It is also the name of a very popular conference on scientific programming with Python. The SciPy library depends on NumPy, which provides convenient and fast N-dimensional array manipulation. The SciPy library is built to work with NumPy arrays, and provides many user-friendly and efficient numerical routines such as routines for numerical integration and optimization powerful N-dimensional array object

Download link : download Scipy 0.7.1 (compatable with Python 2.6)

Choose preferred ver of Scipy

5- Boost 1.39 precompiled version (Multithreaded DLLs and libraries, compiled against MSVC 9.0,

including DateTime, Python and Thread)

Description : "...one of the most highly regarded and expertly designed C++ library projects in

the world."

Use of high-quality libraries like Boost speeds initial development, results in fewer bugs,

reduces reinvention-of-the-wheel, and cuts long-term maintenance costs. And since Boost

Page 5: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

5 | O p e n C L I n s t a l l a t i o n M a n u a l © Copyright 2010, Hosain Ali “[email protected]”.

libraries tend to become de facto or de jure standards, many programmers are already

familiar with them.

Download link : The easiest way to get a copy of Boost is to use an installer.

BoostPro 1.40.0 Installer

choose your preferred Boost installer ver

Getting started with Boost

6- Python setuptools 0.6c9

Description : Download, build, install, upgrade, and uninstall Python packages -- easily!

Download link : download Python Setup tools

7- PyOpenCL

Description : PyOpenCL lets you access GPUs and other massively parallel compute devices

from Python.

Object cleanup tied to lifetime of objects : This idiom, often called RAII in C++, makes it much easier to write correct, leak- and crash-free code.

Completeness : PyOpenCL puts the full power of OpenCL's API at your disposal, if you wish. Every obscure get_info() query and all CL calls are accessible.

Automatic Error Checking : All CL errors are automatically translated into Python exceptions.

Speed : PyOpenCL's base layer is written in C++, so all the niceties above are virtually free.

Liberal license : PyOpenCL is open-source under the MIT license and free for commercial, academic, and private use.

Broad support : PyOpenCL was tested and works with Apple's, AMD's, and Nvidia's CL implementations.

Download link : download PyOpenCL

Page 6: OpenCL and PyOpenCL Installation Manual

OpenCL Installation Manual

6 | O p e n C L I n s t a l l a t i o n M a n u a l © Copyright 2010, Hosain Ali “[email protected]”.

How to link the Python Interpreter to work with PyOpenCL ??!!

After doing the previous steps, and if you still want to write OpenCL programs in Python, so you should make the python interpreter uses (see) the PyOpenCL libraries.

1- Make your dos(command line window) understand the “python” command, and this could be done by adding the python to the System variable

Copy the installed python directory (in most cases be ‘C:\Python26’). Mycompuer propertiesAdvancedEnvironment Variables Add the copied Python directory the “path” variable which is in System variables by

writing “;”then the copied Python path. Make sure that your dos window(command line) accept the “python” command

2- Open your dos window(command line) and change the directory to PyOpenCL directory. 3- Type “python configure.py” 4- You will found new files on the PyOpenCL folder, one of them is siteconf.py 5- Edit the siteconf.py , like adding the Boost lib directory and some other modification

EX: BOOST_INC_DIR = [r'C:\Program Files\boost\boost_1_40'] BOOST_LIB_DIR = [r'C:\Program Files\boost\boost_1_40\lib'] BOOST_COMPILER = 'gcc43' BOOST_PYTHON_LIBNAME = ['boost_python-vc90-mt-1_40'] BOOST_THREAD_LIBNAME = ['boost_thread-vc90-mt-1_40'] CL_TRACE = False CL_ENABLE_GL = False SHIPPED_CL_HEADERS = False CL_INC_DIR = [r'C:\Program Files\ATI Stream\include'] CL_LIB_DIR = [r'C:\Program Files\ATI Stream\lib\x86'] CL_LIBNAME = ['OpenCL'] CXXFLAGS = ['/EHsc', '/DBOOST_PYTHON_NO_PY_SIGNATURES'] LDFLAGS = ['/FORCE']

6- Type "python setup.py install" on your opened dos window. 7- After driver installation, copy all boost dlls into windows/system32 directory. You minimally

need “boost_python-vc90-mt-1_39.dll” and “boost_thread-vc90-mt-1_39.dll”.