5) GPGPU Computing
YARCC has a number of NVidia GPGPU nodes which are documented in 6) Using the nVidia GPU and XEON-phi nodes.
Access to the GPGPU cards is easily done through the 'gputools' package. You need to load the module "cuda" to use the package.
Package 'gputools'
gputools provides R interfaces to a number of common functions implemented using the NVidia CUDA language and toolkit.
function | equivalent R function | description |
|---|---|---|
chooseGpu |
| select GPU device to perform calculations |
cpuMatMult |
| perform matrix multiplication using R's BLAS library |
getGpuId |
| queries the GPU driver for the ID of the device being usedfor the computation |
gpuCor | cor with use="pairwisecomplete" | calculation correlation coefficients |
gpuCrossprod |
| matrix cross-product |
gpuDist | dist | compute distances between vectors |
gpuDistClust | hClust | compute distances and hierarchical clustering |
gpuGlm | glm, lm, loglin | fitting generalised linear models using QR decomposition |
gpuGranger |
| Granger Causality Tests |
gpuHclust | hclust | clustering on a set ofpoints |
gpuLm |
| fitting linear models |
gpuLm.defaultTol |
| switch tolerance depending on precision |
gpuLm.fit |
| fitter function for linear models |
gpuLs.fit |
| least sqares fit using QR decomposition |
gpuMatMult |
| perform matrix multiplication |
gpuMi |
| B spline based mutual information |
gpuQr |
| estimate the QR decomposition for a matrix |
gpuSolve |
| estimate the solution to a matrix vector equation |
gpuTcrossprod |
| perform matrix transposed cross-product |
gpuTtest |
| T-Test Estimator |
More detailed information on using the package can be found here:
Example YARCC jobs using 'gputools'
require(gputools)
test.gpuCrossprod <- function(x, y)
{
matA <- matrix(runif(x*y), x, y);
matB <- matrix(runif(x*y), x, y);
print(sprintf("Using GPU: %s for gpuCrossprod test", getGpuId()));
system.time(gpuCrossprod(matA, matB), TRUE);
}
test.cpuCrossprod <- function(x, y)
{
matA <- matrix(runif(x*y), x, y);
matB <- matrix(runif(x*y), x, y);
print("Using CPU for cpuCrossprod test");
system.time(crossprod(matA, matB), TRUE);
}
print("Testing GPU")
test.gpuCrossprod(3000,4000)
test.cpuCrossprod(3000,4000)
#$ -cwd -V
#$ -l h_rt=0:15:00
#$ -o logs
#$ -e logs
#$ -N gpu_test
#$ -l nvidia_k40=1
echo `date`: executing gputools R module on host ${HOSTNAME} with ${NSLOTS} slots
/usr/bin/nvidia-smi --list-gpus
R CMD BATCH --no-save gpu-test.R output/gpu-test.Rout
> print("Testing GPU")
[1] "Testing GPU"
>
> test.gpuCrossprod(3000,4000)
[1] "Using GPU: 0 for gpuCrossprod test"
user system elapsed
0.573 0.458 1.048
> test.cpuCrossprod(3000,4000)
[1] "Using CPU for cpuCrossprod test"
user system elapsed
131.222 0.092 131.170
>
>
> proc.time()
user system elapsed
135.548 0.901 136.414