[6e0c7b2] | 1 | .. _models-complitation: |
---|
| 2 | |
---|
| 3 | **************** |
---|
| 4 | GPU Computations |
---|
| 5 | **************** |
---|
| 6 | SasView model evaluations can run on your graphics card (GPU) or they can run |
---|
| 7 | on the processor (CPU). |
---|
| 8 | |
---|
| 9 | To run on the GPU, your computer must have OpenCL drivers installed. |
---|
| 10 | For information about OpenCL installation see the |
---|
| 11 | :ref:`opencl-installation` documentation |
---|
| 12 | |
---|
| 13 | Where the model is evaluated is a little bit complicated. |
---|
| 14 | If the model has the line *single=False* then it requires double precision. |
---|
| 15 | If the GPU is single precision only, then it will try running via OpenCL |
---|
| 16 | on the CPU. If the OpenCL driver is not available for the CPU then |
---|
| 17 | it will run as a normal program on the CPU. |
---|
| 18 | For models with a large number of parameters or with a lot of code, |
---|
| 19 | the GPU may be too small to run the program effectively. |
---|
| 20 | In this case, you should try simplifying the model, maybe breaking it |
---|
| 21 | into several different models so that you don't need if statements in your code. |
---|
| 22 | If it is still too big, you can set *opencl=False* in the model file and |
---|
| 23 | the model will only run as a normal program on the CPU. |
---|
| 24 | This will not usually be necessary. |
---|
| 25 | |
---|
| 26 | If you have multiple GPU devices you can tell SasView which device to use. |
---|
| 27 | By default, SasView looks for one GPU and one CPU device |
---|
| 28 | from available OpenCL platforms. |
---|
| 29 | |
---|
| 30 | It prefers AMD or NVIDIA drivers for GPU, and prefers Intel or |
---|
| 31 | Apple drivers for CPU. |
---|
| 32 | Both GPU and CPU are included on the assumption that CPU is always available |
---|
| 33 | and supports double precision. |
---|
| 34 | |
---|
| 35 | The device order is important: GPU is checked before CPU on the assumption that |
---|
| 36 | it will be faster. By examining ~/sasview.log you can see which device SasView |
---|
| 37 | chose to run the model. |
---|
| 38 | If you don't want to use OpenCL, you can set *SAS_OPENCL=None* |
---|
| 39 | in the environment, and it will only use normal programs. |
---|
| 40 | If you want to use one of the other devices, you can run the following |
---|
| 41 | from the python console in SasView:: |
---|
| 42 | |
---|
| 43 | import pyopencl as cl |
---|
| 44 | cl.create_some_context() |
---|
| 45 | |
---|
| 46 | This will provide a menu of different OpenCL drivers available. |
---|
| 47 | When one is selected, it will say "set PYOPENCL_CTX=..." |
---|
| 48 | Use that value as the value of *SAS_OPENCL*. |
---|
| 49 | |
---|
| 50 | For models run as normal programs, you may need to specify a compiler. |
---|
| 51 | This is done using the SAS_COMPILER environment variable. |
---|
| 52 | Set it to *tinycc* for the tinycc compiler, *msvc* for the |
---|
| 53 | Microsoft Visual C compiler, or *mingw* for the MinGW compiler. |
---|
| 54 | TinyCC is provided with SasView so that is the default. |
---|
| 55 | If you want one of the other compilers, be sure to have it available |
---|
| 56 | on the path so SasView can find it. |
---|