[R] dyn.load(now = FALSE) not actually lazy?

Michael Milton ttm|gue|tt @end|ng |rom gm@||@com
Wed Feb 1 04:16:54 CET 2023

On Linux, if I have a .so file that has a dependency on another .so, and I
`dyn.load(now=FALSE)` the first one, R seems to try to resolve the symbols
immediately, causing the load to fail.

For example, I have `libtorch` installed on my HPC. Note that it links to
various libs such as `libcudart.so` and `libmkl_intel_lp64.so.2` which
aren't currently in my library path:

➜  ~ ldd
        linux-vdso.so.1 =>  (0x00007ffcab58c000)
        libgomp.so.1 =>
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8cb20a3000)
        libc10.so =>
        libnuma.so.1 => /lib64/libnuma.so.1 (0x00007f8cb1c21000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f8cb1a19000)
        libgcc_s.so.1 =>
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f8cb15fd000)
        libmkl_intel_lp64.so.2 => not found
        libmkl_gnu_thread.so.2 => not found
        libmkl_core.so.2 => not found
        libm.so.6 => /lib64/libm.so.6 (0x00007f8cb12fb000)
        libcudart.so.11.0 => not found

Then in R, if I try to load that same file:

Error in
  unable to load shared object
  libmkl_intel_lp64.so.2: cannot open shared object file: No such file or

Is this a bug in the `dyn.load` implementation for R? If not, why is it
behaving like this? What should I do about it?

For reference, I'm on CentOS 7, with Linux
kernel 3.10.0-1160.81.1.el7.x86_64.

	[[alternative HTML version deleted]]

More information about the R-help mailing list