Julia can not find libtiff (R 4.4.0, Julia 1.9.3) when running ResistanceGA in R

I’m running a ResistanceGA package in R incorporating work in R and Julia. When I run the jl.prep function it gives me this error. Note it runs fine on my laptop, but when I try to run it in ComputeCanada (remote access computer) it gives me the error, which I’m assuming means that the access to julia works somehow differently :

Error: Error happens in Julia.
InitError: could not load library “/home/varv/.julia/artifacts/4e48910b6d6946bcb2a95632700ecc7e12ff8a9a/lib/libgdal.so”
/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/lib64/libtiff.so.6: version `LIBTIFF_4.6.1’ not found (required by /home/varv/.julia/artifacts/4e48910b6d6946bcb2a95632700ecc7e12ff8a9a/lib/libgdal.so)
Stacktrace:
[1] dlopen(s::String, flags::UInt32; throw_error::Bool)
@ Base.Libc.Libdl ./libdl.jl:117
[2] dlopen(s::String, flags::UInt32)
@ Base.Libc.Libdl ./libdl.jl:116
[3] macro expansion
@ ~/.julia/packages/JLLWrappers/GfYNv/src/products/library_generators.jl:63 [inlined]
[4] init()
@ GDAL_jll ~/.julia/packages/GDAL_jll/YrNvh/src/wrappers/x86_64-linux-gnu-cxx11.jl:78
[5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
@ Base ./loading.jl:1115
[6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
@ Base ./loading.
Execution halted
Julia exit.

The code specifically that I’m running is:

jl.inputs ← ResistanceGA::jl.prep( # jl.prep runs in Julia, allows for speed and parallel processing (well with large data, instead of CS.prep) ()
n.Pops = length(sampleBGLoc_NAD83), # n.Pops will be the no. of indiv in spPoints object (4728 bytes)
response = lower(PropSharBG2CM), # extracts the lower triangular part of your genetic distance matrix. Use pairwise genetic distance matrix (3432 bytes)
CS_Point.File = sampleBGLoc_NAD83, # spatial points dataframe - locations of the individuals
parallel = TRUE, # use several cores
cores = 8, # Check your systems core, adjust
JULIA_HOME = JULIA_HOME)# where the Julia binary files are stored

What’s the output of the Julia function versioninfo() on the machine where this doesn’t work? What happens if you do

LD_LIBRARY_PATH_COPY="${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH=""

before running your code?

1 Like

Most likely this means that R has already loaded libtiff, but has unfortunately loaded a different and incompatible (probably older) version of the library. So then libgdal.so cannot be loaded, because it requires the newer libtiff.

Usually a workaround is to use the LD_PRELOAD environment variable to force R to load a newer version of the library. (Probably there is a newer libtiff.so in /home/varv/.julia/artifacts/4e48910b6d6946bcb2a95632700ecc7e12ff8a9a/lib that you should use.)

1 Like

Thank you for your advice.

I tried to do that:
LD_LIBRARY_PATH_COPY=“${LD_LIBRARY_PATH}”
export LD_LIBRARY_PATH=“”

and it still gives me the same error

For the versioninfo() I get this:
julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a (2023-08-24 14:43 UTC)
Build Info:
Note: This is an unofficial build, please report bugs to the project
responsible for this build and not to the Julia project unless you can
reproduce the issue using official builds available at Download Julia

Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: 40 × Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, skylake-avx512)
Threads: 1 on 40 virtual cores
Environment:
JULIA_DEPOT_PATH = ::

Thank you for your advice.
I tried to do this:
export LD_PRELOAD=/home/varv/.julia/artifacts/2efdb7b239e9f244a3a933925294ea27cc6a61c2/lib/libtiff.so.6

export LD_LIBRARY_PATH=/home/varv/.julia/artifacts/2efdb7b239e9f244a3a933925294ea27cc6a61c2/lib

and it still gives me the same error.

This is rather unfortunate. It seems like R and Julia both need different versions of libtiff, and there may not be an easy way to resolve it.

Also, it is quite likely neither of the packages actually need libtiff (neither ResistanceGA nor Circuitscape), but there is no easy way to do anything about it.

The only thing I can recommend is use a clean R install with the minimum number of packages you need for ResistanceGA (removing all other packages and everything from the LD_LIBRARY_PATH), and hopefully you can avoid the conflict.

1 Like

I’m surprised that LD_PRELOAD does not fix it.

1 Like

That may not be sufficient if libtiff itself needs other libraries which aren’t found automatically in default search paths.

1 Like

The problem with LD_PRELOAD, I think, is that I give the directory to the libtiff.so.6, which I could find a directory for. However, LIBTIFF_4.6.1 version just doesn’t exist. I was able to find LIBTIFF_4.7.0 or 4.6.0 only. Also, as I understand libtiff should be downloaded both for Julia and in my .bashrc and it’s a dependency package of GDAL, so I can either install GDAL and it will install libtiff as dependency, or separately install libtiff