Skip to content

Quantum Information Software (Qiskit) rebuild environment

20lives edited this page Aug 29, 2017 · 1 revision

Quantum Information Software (Qiskit) rebuild environment

Using premade environment

This tutorial will explain how to create the Qiskit environment with rebuild, to only use the Qiskit sdk you can skip it and use the premade environment on dockerhub with only few simple steps (you will still need to make simple configurations outside the environment and learn running an example):

rbld search
rbld deploy qiskit:r0.3 # replace with search result version
rbld run qiskit:r0.3 -- "jupytern notebook" 

Setting up the environment

To set up the sdk we need Anaconda installer, we can find it here: https://www.continuum.io/downloads#linux

now we will create a rebuild environment based on ubuntu

rbld create --base ubuntu:16.04 qiskit

let's check that the process succeeded by listing the rebuild environments:


 rbld list

we now should find "qiskit:initial" it in the results

let's move into interactive mode, to configure the environment:

rbld modify qiskit:initial

this will get us into the interactive shell of the environment, we should now see something like this:

myuser@qiskit-initial-M ~]$

we will now install git and python

sudo apt-get update
sudo apt-get install -y git python python-pip

now we will install Anaconda into the root dir:

sudo bash Anaconda3-4.4.0-Linux-x86_64.sh -p /anaconda3 # you might need to replace filename with your version.

we want to add anaconda to the PATH environment variable, we will use the rebuild.rc file for that:

echo export PATH=/anaconda3/bin:$PATH | sudo tee -a /rebuild/rebuild.rc > /dev/null

now we will clone the IBM Qiskit into the root directory

sudo git clone https://github.com/IBM/qiskit-sdk-py.git /Qiskit

we change the write permissions of the Qiskit directory

sudo chmod 777 -R /Qiskit

we will use PIP to install IBM Quantum Experience:

sudo pip install IBMQuantumExperience

we need to fix jupyter notebook webserver ip in jupyter configuration file

echo "c.NotebookApp.ip  = '$(hostname -i)' " | sudo tee /anaconda3/etc/jupyter/jupyter_notebook_config.py

we are done with the environment setup, CTRL+D to exit the interactive shell. let's commit the changes we made and delete the initial environment:

rbld commit qiskit:initial --tag r0.3
rbld rm qiskit:initial

Configurations outside the environment

now that we have the environment ready we need to have a config file outside of it, the file file can be found here: https://github.com/QISKit/qiskit-sdk-py/blob/master/Qconfig.py.default save and reame it to: Qconfig.py.

to use the Qiskit we need to register the Quantum experience service and generate a token this can be done here: https://quantumexperience.ng.bluemix.net/qx

the token should be placed inside the Qconfig.py file:

#APItoken = "PUT_YOUR_API_TOKEN_HERE" 

(don't forget to remove the commnet) now we can run it: open the jupyter notebook with:

bld run qiskit:r0.3 -- "jupyter notebook"

Running an example

First make sure you configured the Qconfig.py file as mentioned above. clone the tutorial repo form here: https://github.com/QISKit/qiskit-tutorial. run the jupyter notebook

rbld run qiskit:r0.3 -- "jupyter notebook"

this should start a jupyter notebook webserver and print the address in the shell, or open the default browser if you have one configured. now navigate to one of the examples and open it. to get it work properly we need to change the path to the qiskit, at one of the first lines look for:

sys.path.append("../../")
# importing the QISKit

and replace it to "/Qiskit" instead of "../../" we are all set, just click "kernel -> Restart & run all" and wait for the results.