Loading deploy_anaconda.sh +61 −19 Original line number Diff line number Diff line Loading @@ -36,10 +36,14 @@ # Point me to where you want anaconda installed. # I recommend "/ccs/proj/<PROJID>/opt/anaconda/titan-gnu" which labels the host # and programming environment, is readable on the compute nodes, and is not # purged. ANACONDA_PATH="${ANACONDA_PATH-/ccs/proj/csc103/opt/anaconda/titan-gnu}" ANACONDA_PATH="${ANACONDA_PATH-}" VENV_NAME="myenv" if [ -z "${ANACONDA_PATH}" ]; then echo "=> Select where you would like to install Anaconda:" read ANACONDA_PATH fi # Set the environment modules # =========================== Loading @@ -59,23 +63,59 @@ module load cray-hdf5-parallel cudatoolkit # Deploy Anaconda # =============== # Install anaconda as needed if [ ! -d "${ANACONDA_PATH}" ]; then # Use a particular anaconda installer version. ANACONDA_INSTALLER="Anaconda2-4.2.0-Linux-x86_64.sh" if [ ! -f "./${ANACONDA_INSTALLER}" ]; then wget "https://repo.continuum.io/archive/${ANACONDA_INSTALLER}" chmod a+x "${ANACONDA_INSTALLER}" ANACONDA_INSTALLER_NAME="Anaconda2-4.2.0-Linux-x86_64.sh" ANACONDA_INSTALLER_HASH="a0d1fbe47014b71c6764d76fb403f217" echo "=> Installing ${ANACONDA_INSTALLER_NAME%.sh}" mkdir -p "/tmp/$USER" INSTALLER="/tmp/$USER/$ANACONDA_INSTALLER_NAME" # Get the installer, if needed. if [ ! -f "${INSTALLER}" ]; then echo "-> Obtaining installer" wget "https://repo.continuum.io/archive/${ANACONDA_INSTALLER_NAME}" \ -O "${INSTALLER}" fi ./${ANACONDA_INSTALLER} -p "${ANACONDA_PATH}" rm "./${ANACONDA_INSTALLER}" # Check that the installer is OK. echo "-> Verifying installer" _dl_hash="$(md5sum ${INSTALLER} 2>&1 | grep -m 1 -oe "^[^ ]*")" if [ "$_dl_hash" != "$ANACONDA_INSTALLER_HASH" ]; then echo "!> ERROR: '${INSTALLER}' failed checksum and was removed." echo "Please check installer md5sum and re-run this script" return 1 fi # Do the installation. echo "-> Performing non-interactive Anaconda install" chmod a+x "${INSTALLER}" ${INSTALLER} -b -p "${ANACONDA_PATH}" # The anaconda 'activate' script makes some crummy assumptions about zsh # version. This patch fixes it to work with all versions. patch --unified --strip=1 --backup --directory="${ANACONDA_PATH}" <<'EOF' --- a/bin/activate 2016-12-14 08:42:22.253429000 -0500 +++ b/bin/activate 2016-12-14 08:42:27.640355000 -0500 @@ -5,7 +5,7 @@ _SCRIPT_LOCATION=${BASH_SOURCE[0]} _SHELL="bash" elif [[ -n $ZSH_VERSION ]]; then - _SCRIPT_LOCATION=${funcstack[1]} + _SCRIPT_LOCATION="${(%):-%N}" _SHELL="zsh" else echo "Only bash and zsh are supported" EOF fi # Add Anaconda to the PATH # ======================= # ======================== # We want to use ONLY the anaconda distro we installed to $ANACONDA_PATH. We # cannot block Python from finding modules in your $HOME/.local space, but be Loading @@ -84,6 +124,7 @@ fi # on all OLCF resources. Try to avoid using packages installed there unless they # are simple, v2.6-compatible packages written purely in python. echo "=> Adding Anaconda to the PATH" export PATH="${ANACONDA_PATH}/bin:$PATH" # Wipe the PYTHONPATH so it is not contaminated with packages installed for use Loading @@ -98,23 +139,20 @@ export PYTHONPATH='' # installing our own interpretor but it is good practice and prevents some # clashes with OLCF provided python packages/interpreters. # On M.P.Belhorn's preferred shell (zsh), the anaconda 'activate' script doesn't # work without being in the anaconda binary directory (it assumes we are using # an up-to-date zsh). This is to recall the CWD from which we started. _LAST_CWD="$PWD" cd "$ANACONDA_PATH/bin" # If this is the first time this script has been called, # then create the venv... if [ ! -d "${ANACONDA_PATH}/envs/${VENV_NAME}" ]; then echo "=> Setting up a virtualenv" # Configure compiler wrapper to target the batch nodes so compiled code will # run on both batch and compute nodes. Switch back to craype-interlagos when # building code that will only be run on the compute nodes for optimal # performance. echo "-> Configuring the build environment" module unload craype-interlagos module load craype-istanbul # Use the latest and greatest! echo "-> Updating Conda packages" conda update conda # This may need some work. "accelerate" uses CUDA, but conda is notoriously Loading @@ -126,31 +164,35 @@ if [ ! -d "${ANACONDA_PATH}/envs/${VENV_NAME}" ]; then conda install accelerate # Create the venv echo "-> Creating Anaconda virtualenv, '${VENV_NAME}'" conda create -n "${VENV_NAME}" python=2.7 numpy accelerate # Activate it echo "-> Activating VENV." source activate "${VENV_NAME}" # Manually install core packages without relying on pre-compiled binaries from # conda that would use, for instance, openmpi instead of Cray MPICH. echo "-> Building customized python packages" pip install --upgrade pip echo "-> Building mpi4py" CC=cc pip install -v --no-binary :all: mpi4py # H5py needs some configure options to use MPI. Worst case scenario, some # packages will need to be built without pip. echo "-> Building h5py" HDF5_DIR="${CRAY_HDF5_DIR}/${PE_ENV}/${GNU_VERSION%.*}" CC=cc HDF5_MPI="ON" HDF5_DIR="${HDF5_DIR}" pip install -v --no-binary :all: h5py # Reconfigure the compiler wrapper for the compute nodes. Remember, all # environment module changes must happen *without* an active python venv. echo "-> Restoring the build environment" source deactivate "${VENV_NAME}" module unload craype-istanbul module load craype-interlagos fi # Activate the venv. echo "=> Activating Anaconda virtualenv" source activate "${VENV_NAME}" # End where we began. cd "${_LAST_CWD}" Loading
deploy_anaconda.sh +61 −19 Original line number Diff line number Diff line Loading @@ -36,10 +36,14 @@ # Point me to where you want anaconda installed. # I recommend "/ccs/proj/<PROJID>/opt/anaconda/titan-gnu" which labels the host # and programming environment, is readable on the compute nodes, and is not # purged. ANACONDA_PATH="${ANACONDA_PATH-/ccs/proj/csc103/opt/anaconda/titan-gnu}" ANACONDA_PATH="${ANACONDA_PATH-}" VENV_NAME="myenv" if [ -z "${ANACONDA_PATH}" ]; then echo "=> Select where you would like to install Anaconda:" read ANACONDA_PATH fi # Set the environment modules # =========================== Loading @@ -59,23 +63,59 @@ module load cray-hdf5-parallel cudatoolkit # Deploy Anaconda # =============== # Install anaconda as needed if [ ! -d "${ANACONDA_PATH}" ]; then # Use a particular anaconda installer version. ANACONDA_INSTALLER="Anaconda2-4.2.0-Linux-x86_64.sh" if [ ! -f "./${ANACONDA_INSTALLER}" ]; then wget "https://repo.continuum.io/archive/${ANACONDA_INSTALLER}" chmod a+x "${ANACONDA_INSTALLER}" ANACONDA_INSTALLER_NAME="Anaconda2-4.2.0-Linux-x86_64.sh" ANACONDA_INSTALLER_HASH="a0d1fbe47014b71c6764d76fb403f217" echo "=> Installing ${ANACONDA_INSTALLER_NAME%.sh}" mkdir -p "/tmp/$USER" INSTALLER="/tmp/$USER/$ANACONDA_INSTALLER_NAME" # Get the installer, if needed. if [ ! -f "${INSTALLER}" ]; then echo "-> Obtaining installer" wget "https://repo.continuum.io/archive/${ANACONDA_INSTALLER_NAME}" \ -O "${INSTALLER}" fi ./${ANACONDA_INSTALLER} -p "${ANACONDA_PATH}" rm "./${ANACONDA_INSTALLER}" # Check that the installer is OK. echo "-> Verifying installer" _dl_hash="$(md5sum ${INSTALLER} 2>&1 | grep -m 1 -oe "^[^ ]*")" if [ "$_dl_hash" != "$ANACONDA_INSTALLER_HASH" ]; then echo "!> ERROR: '${INSTALLER}' failed checksum and was removed." echo "Please check installer md5sum and re-run this script" return 1 fi # Do the installation. echo "-> Performing non-interactive Anaconda install" chmod a+x "${INSTALLER}" ${INSTALLER} -b -p "${ANACONDA_PATH}" # The anaconda 'activate' script makes some crummy assumptions about zsh # version. This patch fixes it to work with all versions. patch --unified --strip=1 --backup --directory="${ANACONDA_PATH}" <<'EOF' --- a/bin/activate 2016-12-14 08:42:22.253429000 -0500 +++ b/bin/activate 2016-12-14 08:42:27.640355000 -0500 @@ -5,7 +5,7 @@ _SCRIPT_LOCATION=${BASH_SOURCE[0]} _SHELL="bash" elif [[ -n $ZSH_VERSION ]]; then - _SCRIPT_LOCATION=${funcstack[1]} + _SCRIPT_LOCATION="${(%):-%N}" _SHELL="zsh" else echo "Only bash and zsh are supported" EOF fi # Add Anaconda to the PATH # ======================= # ======================== # We want to use ONLY the anaconda distro we installed to $ANACONDA_PATH. We # cannot block Python from finding modules in your $HOME/.local space, but be Loading @@ -84,6 +124,7 @@ fi # on all OLCF resources. Try to avoid using packages installed there unless they # are simple, v2.6-compatible packages written purely in python. echo "=> Adding Anaconda to the PATH" export PATH="${ANACONDA_PATH}/bin:$PATH" # Wipe the PYTHONPATH so it is not contaminated with packages installed for use Loading @@ -98,23 +139,20 @@ export PYTHONPATH='' # installing our own interpretor but it is good practice and prevents some # clashes with OLCF provided python packages/interpreters. # On M.P.Belhorn's preferred shell (zsh), the anaconda 'activate' script doesn't # work without being in the anaconda binary directory (it assumes we are using # an up-to-date zsh). This is to recall the CWD from which we started. _LAST_CWD="$PWD" cd "$ANACONDA_PATH/bin" # If this is the first time this script has been called, # then create the venv... if [ ! -d "${ANACONDA_PATH}/envs/${VENV_NAME}" ]; then echo "=> Setting up a virtualenv" # Configure compiler wrapper to target the batch nodes so compiled code will # run on both batch and compute nodes. Switch back to craype-interlagos when # building code that will only be run on the compute nodes for optimal # performance. echo "-> Configuring the build environment" module unload craype-interlagos module load craype-istanbul # Use the latest and greatest! echo "-> Updating Conda packages" conda update conda # This may need some work. "accelerate" uses CUDA, but conda is notoriously Loading @@ -126,31 +164,35 @@ if [ ! -d "${ANACONDA_PATH}/envs/${VENV_NAME}" ]; then conda install accelerate # Create the venv echo "-> Creating Anaconda virtualenv, '${VENV_NAME}'" conda create -n "${VENV_NAME}" python=2.7 numpy accelerate # Activate it echo "-> Activating VENV." source activate "${VENV_NAME}" # Manually install core packages without relying on pre-compiled binaries from # conda that would use, for instance, openmpi instead of Cray MPICH. echo "-> Building customized python packages" pip install --upgrade pip echo "-> Building mpi4py" CC=cc pip install -v --no-binary :all: mpi4py # H5py needs some configure options to use MPI. Worst case scenario, some # packages will need to be built without pip. echo "-> Building h5py" HDF5_DIR="${CRAY_HDF5_DIR}/${PE_ENV}/${GNU_VERSION%.*}" CC=cc HDF5_MPI="ON" HDF5_DIR="${HDF5_DIR}" pip install -v --no-binary :all: h5py # Reconfigure the compiler wrapper for the compute nodes. Remember, all # environment module changes must happen *without* an active python venv. echo "-> Restoring the build environment" source deactivate "${VENV_NAME}" module unload craype-istanbul module load craype-interlagos fi # Activate the venv. echo "=> Activating Anaconda virtualenv" source activate "${VENV_NAME}" # End where we began. cd "${_LAST_CWD}"