Table of Contents
These are instructions for installing projectq and using its fast C++ backend on ARCHER or ARCUS-B, accessible by SLURM / PBS jobs.
module load gcc/5.3.0
# if you're on ARCHER:
module load anaconda-compute/python3
module unload xalt
# if you're on ARCUS-B:
module load binutils python/anaconda3/4.3.0Notice on ARCHER we loaded anaconda-compute rater than anaconda, so that our running jobs can access python.
Notice on ARCUS-B we loaded some additional compiler instructions through binutils.
To see what compiler and anaconda versions are available, call
module avail gcc
module avail anacondaYou can clear your loaded modules with module purge, and view available modules with module avail, and view modules currently loaded with module list.
on ARCHER, calling
module purgewill limit which modules you can subsequently load, requiring you restart your SSH session
The above modules will need to be loaded each time you SSH into either ARCHER or ARCUS-B.
Here we create and activate an environment (and if on ARCHER, get some C++ symbols we'll need later).
On ARCUS-B
conda create --name projqenv python=3.5 anaconda
source activate projqenvThis environment will need to be activated (source activate projqenv) each time after SSH'ing in to ARCUS-B.
Enter conda info --env to see a list of your conda environments, source deactivate to leave an environment and delete the environment with
conda remove --name projqenv --allOn ARCHER
Care must be taken to put your conda environment in the work (accessible by the compute nodes) and not the default home directory.
Replace PROJNAME and USERNAME below with your project code and username (which you SSH in with) respectively.
cd /work/PROJNAME/PROJNAME/USERNAME/
rm -rf .condarc .conda .local .cache
mkdir -p .conda .local .cache
export CONDARC=$PWD/.condarc
export PYTHONUSERBASE=$PWD/.local
conda config --add envs_dirs $PWD/.conda/envs
conda create --copy --name projqenv python=3.5 anaconda
source activate projqenv
conda install --copy libgccThis environment will need to be activated (source activate projqenv) each time after SSH'ing in to ARCHER.
Anaconda has a habit of giving you an old pip version, or a handle to the global pip (rather than your projqenv environment's pip).
Check that
which pipfeatures
~/.conda/envs/projqenv/bin/pip
and if not, call
conda install pip
Also ensure pip is up-to-date:
pip install --upgrade pip
pip uninstall pybind11
pip uninstall projectq
rm -r ~/.cache/pipThis clears any built wheels, so we can force pip to (re)build projectq correctly
Even the latest version of pip can goof up installing projectq's dependencies in the correct order. Give it a hand by installing pybind11 yourself first, though not the notoriously bugged 2.0.0 version!
# on ARCUS-B
python -m pip install pybind11!=2.2.0
# on ARCHER
pip install --cache-dir $PWD/.cache pybind11!=2.2.0On ARCHER, we were careful to install pybind in our cache in the /work directory.
Let's now (force pip to) build projectq.
# ARCUS-B:
env LANG=en_GB.UTF-8 CC=gcc CXX=g++ python -m pip install --user --force-reinstall --ignore-installed projectq
# ARCHER:
env LANG=en_GB.UTF-8 CC=gcc CXX=g++ pip install --cache-dir $PWD/.cache --user --force-reinstall --ignore-installed projectq
Here, we've
- warned pip that projectq's README file contains non-ASCII characters (through
LANG) - pointed pip to our C and C++ compilers (
gccandg++) - forced projectq to build, regardless of any previous builds (e.g. ones which failed to build the C++ backend)
- on ARCHER, forced projq to install on the /work directory
All done (hopefully)! Open python, and call
from projectq import MainEngine
MainEngine()If the following notice doesn't appear:
(Note: This is the (slow) Python simulator.)
then installation of projectq (with the C++ backend) was successful, at least on the front-end.
On ARCHER, further check that
import projectq
projectq.__file__
import pybind11
pybind11.__file__are located inside the /work dir, and not /home, so as to be accessible by the compute nodes.
-
Assembler Error: no such instruction ...:
you're missing some assembler instructions. On ARCUS-B, load these withmodule load binutils -
(some generic compilation error):
your C/C++ compilers mightn't support C11! Get a compatible one using (for example)module load gcc/5.3.0; view available compilers usingmodule avail gcc -
PermissionError: [Errno 13] Permission denied: '.../site-packages/projectq':
you mightn't be using your conda environment's pip, but the global one instead. Check this whichwhich pip(the direc should feature your environment name), and correct it withconda install pipthenpip install --upgrade pip -
FileNotFoundError: [Errno 2] No such file or directory: '.../.conda/envs/.pkgs/qt-5.6.2-4/info/index.json':
You might be using an incompatible compiler version. Try a newer/older compiler using (for example)module load gcc/5.3.0; view available compilers usingmodule avail gcc -
ImportError: No module named 'pybind11' --- Failed building wheel for projectq:
pip didn't build projectq's dependencies in the correct order; this can still happen with the latest pip! Install pybind11 yourself first before retrying (python -m pip install pybind11!=2.2.0) -
Successful installation, but
MainEngine()gives (Note: This is the (slow) Python simulator.):
Check building projectq was successful by checking.../site-packages/projectq/backends/_sim/_cppsim...soexists. If not, force rebuilding as above. If so, you might need extra C symbols which you can get withconda install libgcc. To better diagnose, editsite-packages/projectq/backends/_sim/_simulator.py. You can findsite packageswithpython -m site --user-site. In_simulator.py, addfrom ._cppsim import Simulator as SimulatorBackendabove thetry/except. Then openpythonand callfrom projectq import MainEngineand you may see a more descriptive error message. -
Successful installation,
MainEngine()gives no warning, but ARCHER PBS jobs give errorNo module named projectq. Checkprojectqandpybind11are in the /work dir, by inpython:import projectq; projectq.__file__. If so, ensure youCONDARCandPYTHONUSERBASEin your submission script and pass-bto aprun (see below).
Now that you've set projectq up, the next time you SSH into ARCHER or ARCUS-B, in order to access projectq on the submit machine, you'll need to call...
on ARCHER:
module load gcc/5.3.0 anaconda-compute/python3
module unload xalt
source activate projqenvon ARCUS-B:
module load gcc/5.3.0 python/anaconda3/4.3.0
source activate projqenvYou can put the above code into a script...
nano myscript.sh
< paste above code >
chmod +x myscript.sh
which you can then call via source myscript.sh after SSH'ing in, or inside your SLURM or PBS submission scripts.
Recall you can enter conda info --env to see a list of your conda environments, and source deactivate to leave an environment.
In your SLURM submit script, simply include
module load gcc/5.3.0 python/anaconda3/4.3.0
source activate projqenv
export OMP_NUM_THREADS=16
export OMP_PROC_BIND=spread
python my_projq_script.pyYour PBS submit script should include (replacing PROJECTNAME and USERNAME)
mydir=/work/PROJECTNAME/PROJECTNAME/USERNAME
module load anaconda-compute/python3
module load gcc/5.3.0
module unload xalt
export CONDARC=${mydir}/.condarc
export PYTHONUSERBASE=${mydir}/.local
source activate projqenv
export OMP_NUM_THREADS=24
export OMP_PROC_BIND=spread
cd "$PBS_O_WORKDIR"
aprun -b -n 1 -d 24 python my_projq_script.pyTake note of the -b argument to aprun.
We recommend creating a script /work/PROJECTNAME/PROJECTNAME/USERNAME/prepq.sh with contents
mydir=/work/PROJECTNAME/PROJECTNAME/USERNAME
module load anaconda-compute/python3
module load gcc/5.3.0
module unload xalt
export CONDARC=${mydir}/.condarc
export PYTHONUSERBASE=${mydir}/.local
source activate projqenv
export OMP_NUM_THREADS=24
export OMP_PROC_BIND=spreadand giving it permission to run (chmod +x prepq.sh) and replacing the above code in your PBS submission script with
cd "$PBS_O_WORKDIR"
source .../path/to/prepq.sh
aprun -b -n 1 -d 24 python my_projq_script.py
An enormous thankyou to the ARCHER CSE team, Andrew Gittings of ARCUS and Thomas Haener of ProjectQ for their considerable help and patience!