Installing ASTRA toolbox for python on linux

Last modified by Heikki Suhonen on 2024/10/04 09:07

On this page are some specific tips for installing ASTRA toolbox. Official install instructions for ASTRA toolbox are at https://www.astra-toolbox.com/docs/install.html#linux-from-source

Download astra distribution for example version 2.1.0 from https://github.com/astra-toolbox/astra-toolbox/archive/refs/tags/v2.1.0.zip

Move the archive to a suitable place and unzip it

unzip astra-toolbox-2.1.0.zip

Then create a virtual environment that will contain ASTRA in your home folder. Because astra 2.1.0 does not work with python 3.10, you have to use the version 3.9.

Update astra version 2.2.0 works with python 3.10, so you can use that with more up to date python version.

mkdir venv_astra
python3 -m venv --system-site-packages venv_astra
source venv_astra/bin/activate

Then you will have to install some packages in the virtual environment in order to be able to compile astra (unless they are already installed in the system global packages)

pip install numpy
pip install cython
pip install six
pip install scipy

Then configure and build the ASTRA toolbox for python, using the astra distribution you earlier downloaded. Note here that we are using CUDA version 11 as the version 12 of CUDA seems to prodiuce errors during compilation of ASTRA 2.1.0.

cd astra-toolbox-2.1.0/build/linux/
./autogen.sh
./configure --with-cuda=/usr/local/cuda-11 --with-python --with-install-type=module
make

The last step (make) will take a significant amount of time (possibly several coffee cups worth). If there were errors, they may be resolved by installing the correct python packages that may be missing.

When there were no errors in the compilation, it is finally time to install the toolbox by typing.

make install

Then whenever using the astra toolbox, one has to just type

source venv_astra/bin/activate

To test the ASTRA installation, start python (while having the venv_astra active), and type the following commands.

import astra
astra.test()