Skip to content

Instantly share code, notes, and snippets.

@hungyiwu
Last active February 25, 2021 20:49
Show Gist options
  • Save hungyiwu/72f47365a4b3e9d0626467a9fd0aab9d to your computer and use it in GitHub Desktop.
Save hungyiwu/72f47365a4b3e9d0626467a9fd0aab9d to your computer and use it in GitHub Desktop.
Install SimpleElastix with Python3 on the O2 server at Harvard Medical School
#!/bin/bash
#SBATCH --job-name=installSE
#SBATCH -c 4 # Number of cores
#SBATCH -t 0-03 # Runtime in D-HH:MM, minimum of 10 minutes
#SBATCH -p short # Partition to submit to, whichever is faster
#SBATCH --mem-per-cpu=4G # Memory (see also --mem)
#SBATCH -o joboutput.out # job output
#SBATCH -e joberrors.err # job error log
# load modules
module load gcc/6.2.0 python/3.7.4 cmake/3.14.1
# paths
export VENVPATH="/home/$(whoami)/se_venv"
export CODEPATH="/home/$(whoami)/SimpleElastix"
# create virtual environment
virtualenv $VENVPATH
source "$VENVPATH/bin/activate"
# download code for installation
git clone https://github.com/SuperElastix/SimpleElastix $CODEPATH
# configure installation
# check this link for background information
# https://github.com/rcasero/pysto/wiki/Build-and-install-SimpleElastix-for-python-3.x
mkdir "$CODEPATH/build"
cd "$CODEPATH/build"
cmake -DPYTHON_EXECUTABLE:FILEPATH="$VENVPATH/bin/python3" \
-DPYTHON_LIBRARY:FILEPATH="$VENVPATH/lib/python3.7" \
-DPYTHON_INCLUDE_DIR:PATH="$VENVPATH/include/python3.7m" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
"$CODEPATH/SuperBuild"
# install the main component
make -j4
# install the Python-related components
cd "$CODEPATH/build/SimpleITK-build/Wrapping/Python"
python "Packaging/setup.py" install
@hungyiwu
Copy link
Author

hungyiwu commented Jul 8, 2020

The O2 server hasn't supported Docker engine yet and the Python path issue took me quite some time, so here's the script that may save you some time

@Ru-bixcube
Copy link

Thank you soo much!

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