Building SIRF and CIL with conda - SyneRBI/SIRF GitHub Wiki

These are instructions to build SIRF, CIL and all prerequisites using conda for dependencies. It is recommended to do this if you use conda for your normal python development. The instructions are for a Linux system although minor variations should work on other systems (see also below).

First, install miniconda.

Then follow these steps (see below for modifications if you encounter problems):

mkdir ~/devel
cd ~/devel
git clone https://github.com/SyneRBI/SIRF-SuperBuild
mkdir buildConda
cd buildConda

conda create --name cilsirfbuild python=3 cxx-compiler cmake ninja swig \
  scipy python-wget cython six pillow nose h5py numpy matplotlib pytest pytest-cov \
  boost pugixml libitk-devel libitk nlohmann_json libparallelproj fftw docopt deprecation niftyreg \
  tqdm pywavelets numba zenodo_get -c conda-forge

conda activate cilsirfbuild

cmake -G Ninja -S ../SIRF-SuperBuild/ -B . -DCMAKE_INSTALL_PREFIX:PATH=~/devel/install -DCMAKE_PREFIX_PATH:PATH=$CONDA_PREFIX -DUSE_SYSTEM_ACE=OFF -DUSE_SYSTEM_Boost=ON -DUSE_SYSTEM_ITK=ON -DUSE_SYSTEM_parallelproj=ON -DUSE_SYSTEM_FFTW3=ON -DUSE_SYSTEM_SWIG=ON -DUSE_SYSTEM_HDF5=ON -DUSE_SYSTEM_JSON=ON -DUSE_SYSTEM_NIFTYREG=ON -DUSE_ITK=ON -DBUILD_Gadgetron=OFF -DBUILD_CIL=ON 

cmake --build . --config Release

Usual CMake build instructions apply. For instance, if you prefer to use a build tool such as make over Ninja, you will have to install it, and use that for the -G option of cmake above.

This will download, build, & install all CIL & SIRF dependencies in ~/devel/install, however without Gadgetron toolbox support (see below).

To run SIRF+CIL you need to create a shell script like the following and source it:

# activate conda environment
conda activate cilsirfbuild
# source the SIRF environment file
source ~/devel/install/bin/env_sirf.sh
# add CONDA_PREFIX/lib to LD_LIBRARY_PATH (probably not necessary)
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH

Note that ideally we'd have a requirements.yml to specify all of the above. Work in progress...

Building Gadgetron etc.

The above lines don't have all dependencies for Gadgetron, and you will therefore likely see failures. You could try to use conda to install Gadgetron as well. Please check the Gadgetron conda instructions, and add above dependencies to the suggested requirements.yml. We haven't tried this ourselves yet.

Building on non-Linux systems

Windows

You will need some obvious changes from the above to accomodate for the shell syntax of course. Surprisingly, you also have to substitute $CONDA_PREFIX with $Env:CONDA_PREFIX/Library (when using Powershell).

It is highly recommended to use -DCMAKE_INSTALL_PREFIX:PATH=$Env:CONDA_PREFIX/Library -DPYTHON_DEST_DIR:PATH=$Env:CONDA_PREFIX/lib/site-packages to avoid problems with Python permissions, see https://github.com/SyneRBI/SIRF-SuperBuild/issues/729#issuecomment-1173548769

Problems and potential solutions:

On older Linux, e.g. Ubuntu 20.04, you might have some linking problems. You can try the following work-arounds:

  • add sysroot_linux-64 to the list of conda packages. This could resolve linking problems with the system GLIBC being older than what was used to build certain conda packages. An example error is undefined reference to memcpy@GLIBC_2.14 (arguably, this should have been solved by conda or the relevant packages, but adding the dependency yourself could work around this problem).
  • add the envs lib folder directly to the path of the run-time loader of shared libraries. This could resolve linking problems finding the correct openmp library for instance:
    export LD_LIBRARY_PATH="$CONDA_PREFIX/lib/:$LD_LIBRARY_PATH"
    
  • If you still have problems building the ISMRMRD examples, you could just switch them off:
    cmake -DISMRMRD_EXTRA_CMAKE_ARGS:STRING="-DBUILD_EXAMPLES:BOOL=OFF" -B .
    cmake --build . --config Release
    
  • If you have problems with a conda package that we can build ourselves, you can do that as opposed to the above, e.g. when experiencing problems with parallelproj:
    # first remove the package that we installed
    conda remove --force libparallelproj
    # now reconfigure telling the SuperBuild to build it
    cmake -DUSE_SYSTEM_parallelproj:BOOL=OFF -B .
    cmake --build . --config Release