source: sasmodels/doc/guide/gpu_setup.rst @ d5014e4

Last change on this file since d5014e4 was 59485a4, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

doc tweaks

  • Property mode set to 100644
File size: 5.6 KB
RevLine 
[c0d7ab3]1.. _gpu-setup:
2
3********************
4GPU Setup
5********************
6
[59485a4]7SAS model evaluations can run on your graphics card (GPU) or they can run
8on the processor (CPU). In general, calculations performed on the GPU
9will run faster.
10
11
[c0d7ab3]12OpenCL Installation
13*******************
14*Warning! GPU devices do not in general offer the same level of memory
15protection as CPU devices. If your code attempts to write outside allocated
16memory buffers unpredicatable behaviour may result (eg, your video display
17may freeze, or your system may crash, etc). Do not install OpenCL drivers
18without first checking for known issues (eg, some computer manufacturers
19install modified graphics drivers so replacing these may not be a good
20idea!). If in doubt, seek advice from an IT professional before proceeding
21further.*
22
23Check if you have OpenCL already installed
24==========================================
25
26**Windows**
27
28The following instructions are based on
29http://web.engr.oregonstate.edu/~mjb/cs475/DoIHaveOpenCL.pdf
30
31* Go to: Start -> Control Panel -> System & Security -> Administrative Tools
32* Double Click on Computer Managment
33* Click on Device Manager
34* Click open Display Adapters
35* Right-click on available adapter and select Properties
36* Click on Driver
37* Go to Driver Details
38* Scroll down and see if OpenCL is installed (look for OpenCL*.dll files)
39
40**Mac OSX**
41
42For OS X operating systems higher than 10.6 OpenCL is shipped along with
43the system.
44
45However, OpenCL has had a rocky history on Macs. Apple provide a useful
46compatibility table at https://support.apple.com/en-us/HT202823
47
48
49Installation
50============
51
52**Windows**
53
54Depending on the graphic card in your system, drivers
55can be obtained from different sources:
56
57* NVIDIA: https://developer.nvidia.com/opencl
58* AMD: http://developer.amd.com/tools-and-sdks/opencl-zone/
59
60
61**Mac OSX**
62
63N/A
64
65You cannot download OpenCL driver updates for your Mac. They are packaged
66with the normal quarterly OS X updates from Apple.
67
68
69.. note::
70    Intel provides OpenCL drivers for Intel processors at
71    https://software.intel.com/en-us/articles/opencl-drivers
72    These can sometimes make use of special vector instructions across multiple
73    processors, so it is worth installing if the GPU does not support double
74    precision. You can install this driver alongside the GPU driver for NVIDIA
75    or AMD.
76
77
78GPU Selection
79*************
80
[59485a4]81The logic for choosing the compute platform is a little bit complicated.
[c0d7ab3]82If the model has the line *single=False* then it requires double precision.
83If the GPU is single precision only, then it will try running via OpenCL
84on the CPU.  If the OpenCL driver is not available for the CPU then
85it will run as a normal program on the CPU.
86
87For models with a large number of parameters or with a lot of code,
[59485a4]88the GPU may be too small to run the program effectively. In this case, you
89should try simplifying the model, maybe breaking it into several different
90models so that you don't need *IF* statements in your code. If it is still
91too big, you can set *opencl=False* in the model file and the model will
92only run as a normal program on the CPU. This will not usually be necessary.
[c0d7ab3]93
94Device Selection
95================
96If you have multiple GPU devices you can tell the program which device to use.
97By default, the program looks for one GPU and one CPU device from available
98OpenCL platforms. It prefers AMD or NVIDIA drivers for GPU, and
99prefers Intel or Apple drivers for CPU. Both GPU and CPU are included on
100the assumption that CPU is always available and supports double precision.
101
102The device order is important: GPU is checked before CPU on the assumption that
103it will be faster. By examining ~/sasview.log you can see which device
104was used to run the model.
105
106**If you don't want to use OpenCL, you can set** *SAS_OPENCL=None*
107**in your environment settings, and it will only use normal programs.**
108
109If you want to use one of the other devices, you can run the following
110from the python console::
111
112    import pyopencl as cl
113    cl.create_some_context()
114
115This will provide a menu of different OpenCL drivers available.
116When one is selected, it will say "set PYOPENCL_CTX=..."
117Use that value as the value of *SAS_OPENCL*.
118
119Device Testing
120==============
121Unfortunately, not all vendors provide working OpenCL implementations
122for their GPU devices.  For example, the HD 6000 Intel GPUs with
123double precision support fail for some of the double precision models.
124
125The SasView user interface provides a Fitting OpenCL Options dialog
126for selecting amongst and testing the available devices.  After a
127few minutes of seeming to freeze, the application will return a list
128of model tests which have passed.  The same tests can be run directly
129from the python console using::
130
131    from sasmodels.model_tests import main as model_tests
132    model_tests("-v", "opencl", "all")
133
134Compiler Selection
135==================
136For models run as normal programs, you may need to specify a compiler.
137This is done using the *SAS_COMPILER* environment variable, and the
138*SAS_OPENMP* environment variable if OpenMP support is available for
139the compiler.
140
141On Windows, set *SASCOMPILER=tinycc* for the tinycc compiler,
142*SASCOMPILER=msvc* for the Microsoft Visual C compiler,
143or *SASCOMPILER=mingw* for the MinGW compiler. If TinyCC is available
144on the python path (it is provided with SasView), that will be the
145default. If you want one of the other compilers, be sure to have it
146available in your *PATH* so we can find it!
147
148On Mac OS/X and Linux, set *SAS_COMPILER=unix* for the compiler.  This
149will use the unix cc command to compile the model, with gcc style
150command line options.  For OS/X you will need to install the Xcode
151package to make the compiler available.
152
153
154*Document History*
155
156| 2017-09-27 Paul Kienzle
Note: See TracBrowser for help on using the repository browser.