-
Notifications
You must be signed in to change notification settings - Fork 73
GPU
How to use GPU estimators
Demos > GPU
JIDT now ships with GPU implementations for the KSG estimators (for mutual information and conditional mutual information, and measures using these such as transfer entropy and active information storage).
In order to use these, there are three steps to follow:
- Install CUDA toolkit;
- Compile the JIDT GPU estimator library;
- Call the JIDT GPU estimators from your code.
These are outlined in the following:
Before making or using the JIDT GPU estimators, you need to have the NVIDIA CUDA toolkit installed. This may be packaged for your platform, e.g. the nvidia-cuda-toolkit
package on Ubuntu, or else obtained from NVIDIA.
On each platform you install JIDT and wish to run the GPU estimators, you should build the JIDT GPU library, by running ant gpu
and then re-packaging the jar file by running ant jar
. You can test the GPU library with ant gputest
.
Alternatively, to turn GPU compilation on by default, you can set the enablegpu
flag to true
in build.xml
, and then clean and recompile by running ant clean jar
.
By default the GPU code is compiled as a dynamic (.so
) library, packaged into the jar and then loaded through a temporary directory at run-time. If you wish to modify this library you can set the path manually through the GPU_LIBRARY_PATH
property (javadoc).
In order to use the JIDT GPU estimators, you simply set the property "USE_GPU"
to true
on the KSG estimator that you want to run in GPU mode rather than in CPU. That's all!
There are several ways to see the code for this in more detail:
- Simple Java demos: see the
Example10GPUBenchmark.java
in thedemos/java/infodynamics/demos
folder; you can run this withdemos/java/example10GPUBenchmark.sh
and thenplotExample10BenchmarkResults.sh
- Unit tests: see the three JUnit tests
GPUCondMutualInfoTester.java
,GPUMutualInfoTester.sh
andGPUPerformanceTester.sh
in the folderjava/unittests/infodynamics/measures/continuous/kraskov
; you can run these withant gputest
from the top level folder -
AutoAnalyser: For any of the relevant KSG estimators, set the property
"USE_GPU"
totrue
using the drop-down property menus; generate the code in your language of choice (Java, Matlab or Python) and then run the generated code in that language.
To get the most out of the GPU library, it is useful to understand what GPUs are good at, and what they're bad at: in general, GPUs are good at solving massively parallel problems, but they lag behind CPUs when it comes to sequential computation. In JIDT, GPU parallelisation is implemented at the level of surrogates -- which means that calls with few or no surrogates won't exploit the full potential of the GPU.
If you only use a single call to computeAverageLocalOfObservations
you will likely not benefit from the GPU library (unless your GPU is disproportionately more expensive than your CPU!). Instead, you should be calling the computeSignificance(int)
method implemented by all relevant GPU-enabled calculators, and will return the observed value of the quantity being measured (e.g. MI, TE) as well as the null distribution.
Please read the relevant section of the javadocs and section A5 of the JIDT paper for more information on surrogates and significance testing.
JIDT -- Java Information Dynamics Toolkit -- Joseph Lizier et al.
- Home
- Getting started
- ImplementedMeasures
- Demos
- Course (long)
- Tutorial (short)
- Non-Java environments
- FAQs
- Miscellaneous
- For serious developers!
- Publications resulting