Skip to content

Instantly share code, notes, and snippets.

@obarisk
Created October 20, 2020 07:23
Show Gist options
  • Save obarisk/e2a685e0c6397bdd451c525d0811bac4 to your computer and use it in GitHub Desktop.
Save obarisk/e2a685e0c6397bdd451c525d0811bac4 to your computer and use it in GitHub Desktop.
lambda ml inference
# configs
PYTHON_VER="3.8"
PYLIBPATH="/mnt/python"
PKGS=(numpy scipy tensorflow xgboost)
sudo yum -y update
sudo yum install -y amazon-efs-utils
# Set up env vars
PYTHON_VER_YUM="${PYTHON_VER/\./}"
# SITE_PACKAGES_DIR="/usr/local/lib64/python${PYTHON_VER}/site-packages"
if [ "${PYTHON_VER_YUM}" -ge 38 ]; then
sudo yum install -y amazon-linux-extras
sudo amazon-linux-extras enable python3.8
sudo yum clean metadata
fi
sudo yum -y install \
atlas-devel \
atlas-sse3-devel \
blas-devel \
findutils \
gcc \
gcc-c++ \
lapack-devel \
python${PYTHON_VER_YUM}-devel \
zip
sudo "$(command -v "pip${PYTHON_VER}")" install --upgrade pip setuptools
PIP="$(command -v "pip${PYTHON_VER}")"
PYTHON="$(command -v "python${PYTHON_VER}")"
for p in "${PKGS[@]}"
do
${PIP} install -U --prefix=${PYLIBPATH} "${p}" # --no-binary :all:
done
${PYTHON} -V
${PYTHON} -c "
import sys
import os
sys.path.insert(0, '/mnt/python/lib/python3.8/site-packages')
sys.path.insert(0, '/mnt/python/lib64/python3.8/site-packages')
import tensorflow as tf
print(tf.__version__)
import numpy as np
print(np.__version__)
print(np.__config__.show())
import scipy as sp
print(sp.version.version)
print(sp.__version__)
import xgboost as xg
print(xg.__version__)
"
# share libraries
mkdir -p /mnt/python/library
cp /usr/lib64/libgomp.so /mnt/python/library
cp /usr/lib64/libdl.so.2 /mnt/python/library
cp /usr/lib64/atlas/* /mnt/python/library
cp /usr/lib64/libquadmath.so.0 /mnt/python/library
cp /usr/lib64/libgfortran.so /mnt/python/library
cp /usr/lib64/libgfortran.so.4 /mnt/python/library
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment