[R-SIG-Mac] Can R on a Mac use the GPU
Taras Zakharko
t@r@@@z@kh@rko @end|ng |rom uzh@ch
Thu Feb 23 10:05:00 CET 2023
Dear Bill,
I think this warning comes from a time when Apple’s implementation of these libraries were severely neglected. From what I understand, this is less of an issue today, as Apple has improved their efforts in this domain, even though some of the routines are still a bit outdated. And of course, this is still closed source, so it is unknown what kind of bugs or accuracy issues are there.
Then again, using Apple’s Accelerate is pretty much the only way to officially access the numerical coprocessor. I’d recommend that you give it a try and validate it on some data you already have results for. Could be a nice boost in performance that you re looking for, could be a few wasted hours. One never knows :)
Best,
Taras
> On 22 Feb 2023, at 16:54, William R Revelle <revelle using northwestern.edu> wrote:
>
> Dear Taras et al.
>
> I currently use
>
> BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
> LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
>
> In the help page for R-mac developers it says:
>
> The BLAS library used by R depends on the way R was compiled (see ‘R Installation and Administration’ manual for details). Current R binaries supplied from CRAN provide both vecLib-based BLAS and reference BLAS shipped with R. vecLib is a part of Apple’s Accelerate framework which provides an optimized BLAS implementation for Mac hardware. Although fast, it is not under our control and may possibly deliver inaccurate results.
>
> The CRAN binary uses --enable-BLAS-shlib option and two Rblas shared libraries are supplied: libRblas.vecLib.dylib which uses vecLib BLAS and libRblas.0.dylib which uses reference BLAS from R. A symbolic link libRblas.dylib determines which one is used. Currently the default is to use the R BLAS: this is recommended for precision.
>
> The statement: "Although fast, it is not under our control and may possibly deliver inaccurate results” worries me. Should it?
>
> My routines that are most matrix heavy are finding correlations, doing factor analysis using my fa function, and using the CFA function in Lavaan. Accuracy in these results is important,
>
> But spending several hours finding large correlation matrices has driven me to search for speed.
>
>
>
> Bill
>
>
>
>
>
>
>
>
>
>
>> On Feb 22, 2023, at 12:46 AM, Taras Zakharko <taras.zakharko using uzh.ch> wrote:
>>
>> H Bill,
>>
>> I am not aware of any packages that do this for you directly. While it is certainly possible to write a Metal shader that will get the job done, it will likely take a substantial amount of non-trivial effort. To further complicate the issue Apple GPUs do not support double-precision computation (used by R).
>>
>> Maybe it would be possible for you to accelerate computation used Apple-provided routines from the Acceleration framework (e.g. BLAS and LAPACK)? Many of those routines have access to the hardware matrix accelerators present on Apple hardware and can result in major performance improvements.
>>
>> Best,
>>
>> Taras
>>
>>> On 21 Feb 2023, at 18:12, 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
>
>
>
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-SIG-Mac
mailing list