Playing R with GPU accelerated in CentOS 7

Download R packages

Download packages from cran:gputools_1.0.tar.gz

wget https://cran.r-project.org/src/contrib/gputools_1.0.tar.gz

Install R Packages

First goto R and set work directory:

setwd("~")
config.status: creating src/Makefile
** libs
** arch - 
/usr/local/cuda/bin/nvcc -c -Xcompiler "-fpic -I/usr/local/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic" -I. -I"/usr/local/cuda-7.5/include" -I"/usr/lib64/R/include" rinterface.cu -o rinterface.o
gcc: error: unrecognized command line option ‘-Wp’
make: *** [rinterface.o] Error 1
ERROR: compilation failed for package ‘gputools’

So, we need to hack the source code:

edit the Makefile, and change CFLAGS to :

CFLAGS = -O2 -g -pipe -Wall -Wp\,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic

Then

tar cvzf gputools_1.0.tar.gz /gputools_1.0.tar.gz

go into R and install the package:

install.packages("~/gputools.tar.gz", repos = NULL, type = "source")

Verify the installation

library(gputools)
N <- 1e3
m <- matrix(sample(100, size = N*N, replace = T), nrow = N)
system.time(dist(m))
system.time(gpuDist(m))

Results:

> library(gputools)
> N <- 1e3
> m <- matrix(sample(100, size = N*N, replace = T), nrow = N)
> system.time(dist(m))
   user  system elapsed 
  6.289   0.005   6.293 
> system.time(gpuDist(m))
   user  system elapsed 
  0.242   0.713   1.775 

When using gpu, it saves much time.

[Reference]

Nvidia Blogs: accelerate-r-applications-cuda
Installing cuda toolkit and related R packages

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值