Skip to content

Creating an Ubuntu LXC lovelace image from scratch

Ali Ramadhan edited this page Jan 5, 2019 · 1 revision

Instructions assume you're on Ubuntu 18.10.

  • lxd init
  • lxc launch ubuntu:18.10 tmp-container
  • lxc exec tmp-container -- /bin/bash
  • sudo apt update
  • sudo apt dist-upgrade
  • sudo apt install python3-pip
  • pip3 install numpy
  • sudo apt install julia
  • sudo apt install nodejs curl
  • curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
  • sudo apt install -y nodejs
  • lxc publish tmp-container --alias lovelace-image
  • lxc image edit lovelace-image
    • Add description: Project Lovelace Image (20181230) under Properties
  • lxc image export lovelace-image lovelace-image-20181230
  • scp lovelace-image-20181230.tar.gz [email protected]:/root/
  • ssh [email protected]
  • lxc image import /root/lovelace-image-20181230.tar.gz
  • lxc image alias delete lovelace-container
  • lxc image list
  • lxc image alias create lovelace-image <new-image-fingerprint>
  • lxc image delete <old-image-fingerprint>
  • lxc launch lovelace-image tmp-container
  • lxc exec test-container -- /bin/bash
  • python3 --version
  • node --version
  • julia --version
  • python3 -c 'import numpy'
  • ping google.com

Using Miniconda

  • TODO: Figure out how to get a Python installation that is dynamically linked to libpython so PyJulia works without having to use python-jl.

    • If you install python from conda-forge there is no need for python-jl.
  • Install Python and Miniconda from https://conda.io/miniconda.html

  • After installing miniconda: conda install -c conda-forge python

Using pyenv

Okay so trying to use pyenv to get a dynamically linked Python installation:

export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
  • We'll need some packages to build Python.

  • Use pyenv to install the latest version of Python: PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.2.

    • The -enable-shared option ensures to build both static and dynamic Python libraries.
    • Double check that it dynamically links against libpython:
$ ldd ~/.pyenv/versions/3.7.2/bin/python3.7 | grep libpython
       libpython3.7m.so.1.0 => /root/.pyenv/versions/3.7.2/lib/libpython3.7m.so.1.0 (0x00007f340cfb9000)
  • Switch to the custom-built Python: pyenv global 3.7.2
  • Double check that we're using the correct pip:
$ pip -V
pip 18.1 from /root/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pip (python 3.7)
  • pip install numpy julia