[R-SIG-Mac] Can R on a Mac use the GPU

William R Revelle reve||e @end|ng |rom northwe@tern@edu
Wed Feb 22 05:14:19 CET 2023


Simon,

That is very helpful.  Your advice about the memory management is what I do in bigCor to allow me to find covariances that would otherwise blow up.  It takes advantage of multiple cores that we have on Macs and allows me to solve problems that I could not handle directly.  I had the hope that some magic would help me in using the GPU to speed things up and I had just missed finding the approrpriate package.  From your note, I have not. 

Many of us R for Mac users are forever in your debt for your support of R for Macs.  

Bill

> On Feb 21, 2023, at 4:31 PM, Simon Urbanek <simon.urbanek using r-project.org> wrote:
> 
> Bill,
> 
> to answer the general part of you question, there are quite a few packages that allow you to use your GPU. At the low level you can use OpenCL which allows you to write code directly on the GPU and turn it into R functions. At a higher level there are frameworks like Torch and Tensorflow that support GPUs and there are packages like keras or rTorch that provide interfaces to that, e.g. for machine learning models. All those support Apple silicon GPUs.
> 
> However, you mentioned bigCor which is orthogonal to that. There are papers (such as https://doi.org/10.1134/S1995080219050068 ) that describe some approaches to using GPUs to compute covariance matrices, but in general GPUs don't really give you a large benefit on their own since it is a lot more about memory management and using smart algorithms/data structures to reduce the necessary computation. You may have more luck asking in HPC forums about that since is not really Mac-specifc (and the answer may depend on what you are actually trying to do so may need more details).
> 
> Cheers,
> Simon
> 
> 
>> On 22/02/2023, at 6:12 AM, William R Revelle <revelle using northwestern.edu> wrote:
>> 
>> Dear R-Mac users.
>> 
>> In trying to speed up a large correlation problem (600K subjects, 6k variables,)  which I can do using my bigCor function, I decided it was time to learn how to use GPU on my Mac book with its M1 Max gpu.  
>> 
>> Having spent a day searching the web and trying  various approaches, I give up.
>> 
>> Are there any packages I can use to do calculations on the GPU part of my Mac using R?
>> 
>> Thanks.
>> 
>> Bill
>> 
>> William Revelle   personality-project.org/revelle.html
>> Professor          personality-project.org
>> Department of Psychology www.wcas.northwestern.edu/psych/
>> Northwestern University   www.northwestern.edu/
>> Use R for psychology         personality-project.org/r
>> It is 90 seconds to midnight   www.thebulletin.org
>> 
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>> 
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

William Revelle    personality-project.org/revelle.html
Professor           personality-project.org
Department of Psychology www.wcas.northwestern.edu/psych/
Northwestern University    www.northwestern.edu/
Use R for psychology         personality-project.org/r
It is 90 seconds to midnight   www.thebulletin.org



More information about the R-SIG-Mac mailing list