Last active
March 22, 2021 00:43
-
-
Save ConstantineLignos/6128448 to your computer and use it in GitHub Desktop.
Set up OpenBLAS with NO_AFFINITY=1 to make it most useful for applications such as R.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Check out OpenBlas from https://github.com/xianyi/OpenBLAS and check out the master branch. | |
2. Build and install to /opt: | |
a.) Multi-threaded: | |
make NO_AFFINITY=1 | |
b.) Single-threaded: | |
sudo make PREFIX=/opt install | |
3. Configure it as your BLAS of choice: | |
sudo update-alternatives --install /usr/lib/libblas.so.3gf libblas.so.3gf /opt/lib/libopenblas.so.0 50 | |
4. Check the configuration to make sure it's selected | |
update-alternatives --config libblas.so.3gf | |
5. You can confirm that R is using it by launching R in the background, getting its pid, and making sure that the blas you want is the one listed: | |
lsof -p <pid> | grep blas | |
6. If you've built multi-threaded, set $OMP_NUM_THREADS to the number of threads you want to be used for parallelization. (You can also set the OpenBLAS or GotoBLAS equivalent variable; I set the OpenMP one so I can only set one variable for both OpenMP and OpenBLAS. See the OpenBLAS README for details.) | |
Here are the timings on my system using R Benchmark 2.5 (http://r.research.att.com/benchmarks/R-benchmark-25.R): | |
1. Default BLAS (/usr/lib/libblas/libblas.so.3gf) | |
> proc.time() | |
user system elapsed | |
150.165 1.720 152.264 | |
2. Ubuntu package libopenblas-base (/usr/lib/openblas-base/libopenblas.so.0) | |
> proc.time() | |
user system elapsed | |
66.792 7.472 55.680 | |
3. OpenBLAS as compiled above for Sandy Bridge (/opt/lib/libopenblas.so.0) | |
> proc.time() | |
user system elapsed | |
55.727 17.557 46.894 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After installing OpenBLAS (Ubuntu 16.04) the stats package will no longer load:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/lib/R/library/stats/libs/stats.so':
/usr/lib/liblapack.so.3: undefined symbol: gotoblas
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found