llvmlite 0.36.0 on Graviton2 - qyjohn/AWS_Tutorials GitHub Wiki

A lot of people said they were unable to install llvmlite (0.36.0) on Graviton2. The real issue here seems to be llvmlite requires LLVM 10.0.x or 9.0.x, but is not able to work with a higher version (currently 11.1.0). As such, customer needs to install LLVM 10.0.x instead of the latest version. I have tested the following approach and I was successful in installing llvmlite with pip on Amazon Linux 2 on c6g.xlarge.

(1) Launch a c6g.xlarge instance withAmazon Linux 2, with 100 GB EBS volume. The large EBS volume is needed to build LLVM from source code.

(2) Download LLVM source code and checkout version 10.0.1.

sudo yum install gcc gcc-c++ cmake3 git
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
git tag -l
git checkout llvmorg-10.0.1

(3) Build and install LLVM. Here we use 2 threads to speed up the build process. If you use a bigger instance type, further speed-up can be achieved by setting a bigger number of concurrent threads.

cd ~
mkdir mybuilddir
cd mybuilddir
cmake3 ~/llvm-project/llvm
cmake3 --build . -- -j 2
sudo cmake3 --build . --target install

(4) Create a virtual environment and install llvmlite with pip.

[ec2-user@ip-172-31-18-2 ~]$ python3 -m venv test

[ec2-user@ip-172-31-18-2 ~]$ source test/bin/activate

(test) [ec2-user@ip-172-31-18-2 ~]$ pip install pip --upgrade
Collecting pip
  Using cached pip-21.1.3-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-21.1.3

(test) [ec2-user@ip-172-31-18-2 ~]$ pip install llvmlite
Collecting llvmlite
  Using cached llvmlite-0.36.0.tar.gz (126 kB)
Using legacy 'setup.py install' for llvmlite, since package 'wheel' is not installed.
Installing collected packages: llvmlite
    Running setup.py install for llvmlite ... done
Successfully installed llvmlite-0.36.0