Search code examples
ubuntujuliaraspberry-pi4lightgbm

LightGBM on RPi 4B Ubuntu fails to load model


I am using Julia 1.5 on a raspberry pi 4b 8GB running Ubuntu 20.04 64 bit. I had created a lightGBM model on my Windows laptop and saved the model to a file. This loads fine on my windows laptop and executes properly. But when I am trying to load it in Raspberry PI, I get below error. I checked and found that the /home/pi/.julia/packages/LightGBM/My6MK/src/lib_lightgbm.so file exists. I have tried to remove the LightGBM Package and add it back again. But issue still persists. Please let me know if you need more details.

loadmodel(estimator, "/home/pi/softwares/julia/lightgbmModel.jld2")
ERROR: could not load library "/home/pi/.julia/packages/LightGBM/My6MK/src/lib_lightgbm.so"
/home/pi/.julia/packages/LightGBM/My6MK/src/lib_lightgbm.so: cannot open shared object file: No such file or directory
Stacktrace:
 [1] LGBM_BoosterCreateFromModelfile(::String) at /home/pi/.julia/packages/LightGBM/My6MK/src/wrapper.jl:101
 [2] loadmodel(::LGBMClassification, ::String) at /home/pi/.julia/packages/LightGBM/My6MK/src/utils.jl:72
 [3] top-level scope at REPL[16]:1

Solution

  • I had a similar problem building .Net project on MacOs and then running on Raspberry PI 4. It looks like the library 'lib_lightgbm.so' distributed with NuGet package manager works with other Linux distributions but it is not the right library for Raspberry.

    I compiled 'lib_lightgbm.so' on Raspberry using

    git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM
    mkdir build ; cd build
    cmake ..
    make -j4
    

    and then manually copied the compiled library 'lib_lightgbm.so' into your project directory (replace the existing one). That worked for me.