nlmixr2 / rxode2

rxode2
https://nlmixr2.github.io/rxode2/
GNU General Public License v3.0
24 stars 6 forks source link

How to enable OpenMP for Apple Silicon Macs (M1) #665

Closed BatheFu closed 3 months ago

BatheFu commented 3 months ago

I have enabled OpenMP for data.table package following the doc Issue. But for rxode2, it doesnt work for my Mac Mini M1. Could someone help?

Output now:

library(data.table) data.table 1.14.10 using 4 threads (see ?getDTthreads).
Latest news: r-datatable.com`

library(rxode2) Registered S3 method overwritten by 'data.table': method from print.data.table
rxode2 2.1.1 using 1 threads (see ?getRxThreads) no cache: create with rxCreateCache()

rxode2 has not detected OpenMP support and will run in single-threaded mode This is a Mac. Please read https://mac.r-project.org/openmp/

john-harrold commented 3 months ago

Hello BatheFu,

Did you install rxode2 from source as described here:

https://github.com/nlmixr2/nlmixr2/discussions/26

BatheFu commented 3 months ago

It failed at last steps: installing help indices copying figures building package indices installing vignettes ** testing if installed package can be loaded from temporary location Error: package or namespace load failed for ‘rxode2’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-rxode2/00new/rxode2/libs/rxode2.so': dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-rxode2/00new/rxode2/libs/rxode2.so, 0x0006): symbol not found in flat namespace 'dlsoda' Error: loading failed Execution halted ERROR: loading failed

mattfidler commented 3 months ago

It seems you may not have gnu fortran installed; while I'm not sure (since I don't have a mac), this could be the cause.

https://cran.r-project.org/bin/macosx/tools/

Talks about how to get fortran for the mac.

BatheFu commented 3 months ago

I installed fortran, reboot and try to install rxode2 from source again, but the issue still exists. Thanks for your help anyway. It is still efficient to simulation PK data with 1 thread lol.

mattfidler commented 3 months ago

Make sure you use the right file based on your distribution. A simple copy paste of the commands may not work.

BatheFu commented 3 months ago

It failed at first because the default installation location of gfortran-12.2-universal is /opt/gfortran/bin/gfortran. After copying the files to /usr/local/bin/gfortran. It worked finally.

mattfidler commented 3 months ago

I'm glad you figured it out :smile: