RuntimeError: Building llvmlite requires LLVM 11.x.x, got '7.0.1'.

 I researched recently transformers library, especially Wa2Vec2 model. The main goal was to build a prototype of automatic speech recognition (ASR) on RaspberryPI 4 (RSP). There were a few caveats how to make the whole ecosystem operational. However here I would like to describe how to deal with quite common error related to Numba installation. Numba and llvmlite packages are dependencies for sklearn package, which is quite often used in machine learning world. 

In this topic I will describe how to install Numba and llvmlite as well as how to deal with the next error:

RuntimeError: Building llvmlite requires LLVM 11.x.x, got '7.0.1'. Be sure to set LLVM_CONFIG to the right executable path.

First of all, let me explain what is the problem. While installing Numba Python compiles it's code and for this purpose it needs LLVM compiler. In the error message the build process notifies us that it has found not satisfying version of LLVM compiler.

To check your version you can run the next command:

lli --version

From the error message we clearly see that the installation process needs LLVM version 11.x.x. (be aware exactly version 11.x.x is expected).


Installation LLVM

So, let's download and install LLVM.

To download LLVM precompiled binary you have to follow this link. You can find multiple prebuilt LLVM binaries, as we discussed above, we will download the latest 11.x.x version. In our case it will be version 11.1.0 (if you do it for RSP 4 you can use this link). 

Finally you will get an archive, let's say with the next name clang+llvm-11.1.0-armv7a-linux-gnueabihf.tar.xz. We need extract files from the archive, and copy them to /usr/local/. Potentially you can place it in any place you like and add path to the folder to the PATH variable, however if you do not want to spend a time researching compilation arguments just copy the files into /usr/local.

 tar xvf clang+llvm-11.1.0-armv7a-linux-gnueabihf.tar.xz
 cd clang*
 sudo cp -R * /usr/local/
Now you can check LLVM version it should be 11.1.0:
lli --version

Installation llvmlite

I think if you reached this point you are 85% close to the goal.

If you have LLVM installed into the other location than /usr/local, you have to specify LLVM_CONFIG environment variable. You can add it into your .bashrc file.

# Open your ~/.bashrc file and add at the end
export LLVM_CONFIG="path to your's llvm-config file"     #  e.g. "/home/pi/llvm-13/clang+llvm-11.1.0-armv7a-linux-gnueabihf/bin"
Then apply you changes:
source ~/.bashrc

Now we can install llvmlite. On the current moment Numba requires pecial version of llvmlite, so the command is:

sudo -H /home/pi/venv8/bin/pip install -U "llvmlite<0.39,>=0.38.0dev0"

Why do I use "sudo -H ..."? The link on this StackOverflow answer can explain the question.

And now you should be able to install Numba and sklearn.

Comments

Popular posts from this blog

Install Kubeflow locally

RabbitMQ and OpenShift