[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
/stornext/System/data/nvidia/libtorch-gpu/libtorch-gpu-1.12.1/lib/libtorch_cpu.so
        linux-vdso.so.1 =>  (0x00007ffcab58c000)
        libgomp.so.1 =>
/stornext/System/data/apps/gcc/gcc-11.2.0/lib64/libgomp.so.1
(0x00007f8cb22bf000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8cb20a3000)
        libc10.so =>
/stornext/System/data/nvidia/libtorch-gpu/libtorch-gpu-1.12.1/lib/libc10.so
(0x00007f8cb1e2d000)
        libnuma.so.1 => /lib64/libnuma.so.1 (0x00007f8cb1c21000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f8cb1a19000)
        libgcc_s.so.1 =>
/stornext/System/data/apps/gcc/gcc-11.2.0/lib64/libgcc_s.so.1
(0x00007f8cb1801000)
        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:

>
dyn.load("/stornext/System/data/nvidia/libtorch-gpu/libtorch-gpu-1.12.1/lib/libtorch_cpu.so",
now=FALSE)
Error in
dyn.load("/stornext/System/data/nvidia/libtorch-gpu/libtorch-gpu-1.12.1/lib/libtorch_cpu.so",
 :
  unable to load shared object
'/stornext/System/data/nvidia/libtorch-gpu/libtorch-gpu-1.12.1/lib/libtorch_cpu.so':
  libmkl_intel_lp64.so.2: cannot open shared object file: No such file or
directory

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