Skip to content

Instantly share code, notes, and snippets.

@dapperfu
Last active July 1, 2020 13:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dapperfu/ba40ff83523296bc8355f05befb28da9 to your computer and use it in GitHub Desktop.
Save dapperfu/ba40ff83523296bc8355f05befb28da9 to your computer and use it in GitHub Desktop.
Installing Numba (requiring llvm) on Ubuntu 16.04

Installing Numba from pip fails since Ubuntu 16.04 only has up through llvm-3.8 in its repositories.

As of version 0.16.0, llvmlite requires LLVM 3.9. It does not support earlier or later versions of LLVM.

Install LLVM-3.9 through the LLVM's Debian/Ubuntu packages (http://apt.llvm.org/).

Add:

deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main

to /etc/apt/sources.list or /etc/apt/sources.list.d/llvm.list.

Add the PGP key, update package list and install llvm-3.9.

wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
apt-get update
apt-get install llvm-3.9

Export the path to llvm-config-3.9 so the compiler llvmlite compiler can find it:

export LLVM_CONFIG=$(which llvm-config-3.9)

Install numba:

pip install numba
@Shreeyak
Copy link

Hey, as of today, llvmlite depends on LLVM 6.0, and installing llvm-config installed via apt-get does not work. LLVM will have to be built from source. Here are instructions:

  1. Download the sources from here: http://www.linuxfromscratch.org/blfs/view/svn/general/llvm.htmld

Full build is around 29Gb, not enough space in inbuilt memory on TX2. However, by passing the flags as shown below, the build size can come down to 1.3Gb.

  1. Make a "build" directory inside the llvm source directory and from the build directory, run cmake:
$ cd llvm-6.0.1.src
$ mkdir build
$ cd build
 
# Configure to build only the Release version and only for the ARM, x86 and AArch64 architectures
$ cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="ARM;X86;AArch64"

#Start the build from the build directory
$ cmake -j4 --build .

This is compile the package. It should take around 3hrs or more.

  1. Install llvm:
#install it from the build directory:
$ sudo cmake --build . --target install

LLVM will be installed to: /usr/local/include/llvm

@padraic00
Copy link

padraic00 commented Nov 29, 2018

Slightly broken link in @Shreeyak response (source is here). Build works great. No need for usb's to expand storage.

@mtshikomba
Copy link

I managed without a USB or External Storage.

Thanks!

@MiaoDX
Copy link

MiaoDX commented Dec 10, 2019

Hi, xavier with 18.04 seems can use apt-get by updating source.list from http://apt.llvm.org/

@mtshikomba
Copy link

Okay, Thanks @MiaoDX

@IbrahimBond
Copy link

how do i package my llvm build from source for fast install if i needed to?

@bara495
Copy link

bara495 commented Feb 18, 2020

Hi, xavier with 18.04 seems can use apt-get by updating source.list from http://apt.llvm.org/

Can you please be more specific? I am not sure what you mean by that? @MiaoDX

@bara495
Copy link

bara495 commented Feb 18, 2020

Hi, xavier with 18.04 seems can use apt-get by updating source.list from http://apt.llvm.org/

Can you please be more specific? I am not sure what you mean by that? @MiaoDX

So to answer my own question: he meant /etc/apt/sources.list, I edited that and added these four lines (first 9 and then 10):

for llvm-10

When I tried apt installing llvm-9 it did install (as it have also before this change) but it doesn't let me pip install llvmlite what was the prerequisite for numba (and numba is for librosa)

Here's the output I get when I did apt update with these changes:
N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'http://apt.llvm.org/bionic llvm-toolchain-bionic-9 InRelease' doesn't support architecture 'arm64'

(I am also using Xavier and Ubuntu 18.04 just to be clear)

@MiaoDX
Copy link

MiaoDX commented Feb 19, 2020

Hi,
@bara495 I am not that sure, but the numba should still support llvm-8 (llvm-7)?
@IbrahimBond as for build from source, I copied the install directory of llvm, but later found out after succeeding pip install numba, it is even not necessary to keep the install at all.

@bara495
Copy link

bara495 commented Feb 19, 2020

Hello @MiaoDX,
I don't really care which llvm it is, I just want to get numba (librosa) working.
If it is possible without building which takes a long looong time, please give a bit more detailed description it would help a lot of people struggling with librosa!!
Kind regards!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment