diff --git a/docs/install.md b/docs/install.md index 80a9df471..a3ee62a6c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -10,14 +10,14 @@ There are a few ways to set up your environment to use TensorFlow Quantum (TFQ): Python's pip package manager. * Or build TensorFlow Quantum from source. -TensorFlow Quantum is supported on Python 3.6 and 3.7 and depends directly on [Cirq](https://github.com/quantumlib/Cirq). +TensorFlow Quantum is supported on Python 3.6, 3.7, and 3.8 and depends directly on [Cirq](https://github.com/quantumlib/Cirq). ## Pip package ### Requirements * pip 19.0 or later (requires `manylinux2010` support) -* [TensorFlow == 2.1](https://www.tensorflow.org/install/pip) +* [TensorFlow == 2.3.1](https://www.tensorflow.org/install/pip) See the [TensorFlow install guide](https://www.tensorflow.org/install/pip) to set up your Python development environment and an (optional) virtual environment. @@ -27,7 +27,7 @@ Upgrade `pip` and install TensorFlow
@@ -57,33 +57,34 @@ The following steps are tested for Ubuntu-like systems. ### 1. Set up a Python 3 development environment +First we need the Python 3.8 development tools.pip3 install --upgrade pip
-pip3 install tensorflow==2.1.0
+pip3 install tensorflow==2.3.1
### 2. Create a virtual environment +Go to your workspace directory and make a virtual environment for TFQ development.sudo apt update
-sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3
-sudo apt install python3 python3-dev python3-venv python3-pip
-python3 -m pip install --upgrade pip
+sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3.8
+sudo apt install python3.8 python3.8-dev python3.8-venv python3-pip
+python3.8 -m pip install --upgrade pip
-### 3. Install Bazel -See the TensorFlow +As noted in the TensorFlow [build from source](https://www.tensorflow.org/install/source#install_bazel) -guide to install the Bazel -build system. +guide, the Bazel +build system will be required. -To ensure compatibility with TensorFlow, `bazel` version 0.26.1 or lower is -required. To remove any existing version of Bazel: +To ensure compatibility with TensorFlow 2.3.1, we use `bazel` version 3.1.0. To remove any existing version of Bazel:python3 -m venv tfq_env
-source tfq_env/bin/activate
+python3.8 -m venv quantum_env
+source quantum_env/bin/activate
@@ -91,20 +92,37 @@ required. To remove any existing version of Bazel:-Then install Bazel version 0.26.0: +Download and install `bazel` version 3.1.0:
-+ + +To prevent automatic updating of `bazel` to an incompatible version, run the following: + + +wget https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel_0.26.0-linux-x86_64.deb
-sudo dpkg -i bazel_0.26.0-linux-x86_64.deb
+wget https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel_3.1.0-linux-x86_64.deb +
+sudo dpkg -i bazel_3.1.0-linux-x86_64.deb
+
+ sudo apt-mark hold bazel
+
+
+
+Finally, confirm installation of the correct `bazel` version:
+
+
+
+ bazel --version
### 4. Build TensorFlow from source
-Read the TensorFlow [build from source](https://www.tensorflow.org/install/source)
-guide for details. TensorFlow Quantum is compatible with TensorFlow version 2.1.
+Here we adapt instructions from the TensorFlow [build from source](https://www.tensorflow.org/install/source)
+guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version 2.3.
Download the
TensorFlow source code:
@@ -113,22 +131,21 @@ Download the
-Install the TensorFlow dependencies: +Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies:git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
-git checkout v2.1.0
+git checkout v2.3.1
--Configure the TensorFlow build. The default Python location and Python library -paths should point inside the virtual environment. The default options are -recommended: +Configure the TensorFlow build. When asked for the Python interpreter and library locations, be sure to specify locations inside your virtual environment folder. The remaining options can be left at default values.python3 -m pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'
-python3 -m pip install -U keras_applications --no-deps
-python3 -m pip install -U keras_preprocessing --no-deps
+pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'
+pip install -U keras_applications --no-deps
+pip install -U keras_preprocessing --no-deps
+pip install numpy==1.18.0
@@ -136,14 +153,6 @@ recommended:-Verify that your Bazel version is correct: - - -
- bazel version
-
-
-
Build the TensorFlow package:
@@ -154,35 +163,28 @@ Build the TensorFlow package:
Note: It may take over an hour to build the package.
-After the build is complete, install the package:
+After the build is complete, install the package and leave the TensorFlow directory:
### 5. Download TensorFlow Quantum -Download the TensorFlow Quantum source code and install the requirements: +We use the standard [fork and pull request workflow](https://guides.github.com/activities/forking/) for contributions. After forking from the [TensorFlow Quantum](https://github.com/tensorflow/quantum) GitHub page, download the source of your fork and install the requirements:./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip install /tmp/tensorflow_pkg/name_of_generated_wheel.whl
+cd ..
--Verify your Bazel version (since it can auto-update): - - -cd ..
-git clone https://github.com/tensorflow/quantum.git
+git clone https://github.com/username/quantum.git
cd quantum
-python3 -m pip install -r requirements.txt
+pip install -r requirements.txt
- bazel version
-
-
### 6. Build the TensorFlow Quantum pip package
@@ -197,4 +199,12 @@ Build the TensorFlow Quantum pip package and install:
+To confirm that TensorFlow Quantum has successfully been installed, you can run the tests:
+
+
+ ./scripts/test_all.sh
+
+
+
+
Success: TensorFlow Quantum is now installed.
diff --git a/docs/tutorials/barren_plateaus.ipynb b/docs/tutorials/barren_plateaus.ipynb
index 3039089eb..a9eefa81e 100644
--- a/docs/tutorials/barren_plateaus.ipynb
+++ b/docs/tutorials/barren_plateaus.ipynb
@@ -97,7 +97,7 @@
},
"outputs": [],
"source": [
- "!pip install tensorflow==2.1.0"
+ "!pip install tensorflow==2.3.1"
]
},
{
diff --git a/docs/tutorials/gradients.ipynb b/docs/tutorials/gradients.ipynb
index 8922a86f7..e1f4c4c77 100644
--- a/docs/tutorials/gradients.ipynb
+++ b/docs/tutorials/gradients.ipynb
@@ -99,7 +99,7 @@
},
"outputs": [],
"source": [
- "!pip install tensorflow==2.1.0"
+ "!pip install tensorflow==2.3.1"
]
},
{
diff --git a/docs/tutorials/hello_many_worlds.ipynb b/docs/tutorials/hello_many_worlds.ipynb
index 145d1531c..96b414b87 100644
--- a/docs/tutorials/hello_many_worlds.ipynb
+++ b/docs/tutorials/hello_many_worlds.ipynb
@@ -97,7 +97,7 @@
},
"outputs": [],
"source": [
- "!pip install tensorflow==2.1.0"
+ "!pip install tensorflow==2.3.1"
]
},
{
diff --git a/docs/tutorials/mnist.ipynb b/docs/tutorials/mnist.ipynb
index 85bd4c0d5..0415a399d 100644
--- a/docs/tutorials/mnist.ipynb
+++ b/docs/tutorials/mnist.ipynb
@@ -97,7 +97,7 @@
},
"outputs": [],
"source": [
- "!pip install tensorflow==2.1.0"
+ "!pip install tensorflow==2.3.1"
]
},
{
diff --git a/docs/tutorials/qcnn.ipynb b/docs/tutorials/qcnn.ipynb
index cd7115bcb..c3174b7de 100644
--- a/docs/tutorials/qcnn.ipynb
+++ b/docs/tutorials/qcnn.ipynb
@@ -99,7 +99,7 @@
},
"outputs": [],
"source": [
- "!pip install tensorflow==2.1.0"
+ "!pip install tensorflow==2.3.1"
]
},
{
diff --git a/scripts/build_pip_package_test.sh b/scripts/build_pip_package_test.sh
index 285245b62..1adc7a7e9 100755
--- a/scripts/build_pip_package_test.sh
+++ b/scripts/build_pip_package_test.sh
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
+
pip install -r requirements.txt
# cd tensorflow_quantum