@@ -10,14 +10,14 @@ There are a few ways to set up your environment to use TensorFlow Quantum (TFQ):
10
10
Python's pip package manager.
11
11
* Or build TensorFlow Quantum from source.
12
12
13
- TensorFlow Quantum is supported on Python 3.6 and 3.7 and depends directly on [ Cirq] ( https://github.com/quantumlib/Cirq ) .
13
+ TensorFlow Quantum is supported on Python 3.6, 3.7, and 3.8 and depends directly on [ Cirq] ( https://github.com/quantumlib/Cirq ) .
14
14
15
15
## Pip package
16
16
17
17
### Requirements
18
18
19
19
* pip 19.0 or later (requires ` manylinux2010 ` support)
20
- * [ TensorFlow == 2.1] ( https://www.tensorflow.org/install/pip )
20
+ * [ TensorFlow == 2.3. 1] ( https://www.tensorflow.org/install/pip )
21
21
22
22
See the [ TensorFlow install guide] ( https://www.tensorflow.org/install/pip ) to
23
23
set up your Python development environment and an (optional) virtual environment.
@@ -27,7 +27,7 @@ Upgrade `pip` and install TensorFlow
27
27
<!-- common_typos_disable -->
28
28
<pre class =" devsite-click-to-copy " >
29
29
<code class =" devsite-terminal " >pip3 install --upgrade pip</code >
30
- <code class =" devsite-terminal " >pip3 install tensorflow==2.1.0 </code >
30
+ <code class =" devsite-terminal " >pip3 install tensorflow==2.3.1 </code >
31
31
</pre >
32
32
<!-- common_typos_enable -->
33
33
@@ -57,54 +57,72 @@ The following steps are tested for Ubuntu-like systems.
57
57
58
58
### 1. Set up a Python 3 development environment
59
59
60
+ First we need the Python 3.8 development tools.
60
61
<!-- common_typos_disable -->
61
62
<pre class =" devsite-click-to-copy " >
62
63
<code class =" devsite-terminal " >sudo apt update</code >
63
- <code class =" devsite-terminal " >sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3</code >
64
- <code class =" devsite-terminal " >sudo apt install python3 python3-dev python3-venv python3-pip</code >
65
- <code class =" devsite-terminal " >python3 -m pip install --upgrade pip</code >
64
+ <code class =" devsite-terminal " >sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python3.8 </code >
65
+ <code class =" devsite-terminal " >sudo apt install python3.8 python3.8 -dev python3.8 -venv python3-pip</code >
66
+ <code class =" devsite-terminal " >python3.8 -m pip install --upgrade pip</code >
66
67
</pre >
67
68
<!-- common_typos_enable -->
68
69
69
70
### 2. Create a virtual environment
70
71
72
+ Go to your workspace directory and make a virtual environment for TFQ development.
71
73
<!-- common_typos_disable -->
72
74
<pre class =" devsite-click-to-copy " >
73
- <code class =" devsite-terminal " >python3 -m venv tfq_env </code >
74
- <code class =" devsite-terminal " >source tfq_env /bin/activate</code >
75
+ <code class =" devsite-terminal " >python3.8 -m venv quantum_env </code >
76
+ <code class =" devsite-terminal " >source quantum_env /bin/activate</code >
75
77
</pre >
76
78
<!-- common_typos_enable -->
77
79
78
80
### 3. Install Bazel
79
81
80
- See the TensorFlow
82
+ As noted in the TensorFlow
81
83
[ build from source] ( https://www.tensorflow.org/install/source#install_bazel )
82
- guide to install the <a href =" https://bazel.build/ " class =" external " >Bazel</a >
83
- build system.
84
+ guide, the <a href =" https://bazel.build/ " class =" external " >Bazel</a >
85
+ build system will be required .
84
86
85
- To ensure compatibility with TensorFlow, ` bazel ` version 0.26.1 or lower is
86
- required. To remove any existing version of Bazel:
87
+ To ensure compatibility with TensorFlow 2.3.1, we use ` bazel ` version 3.1.0. To remove any existing version of Bazel:
87
88
88
89
<!-- common_typos_disable -->
89
90
<pre class =" devsite-click-to-copy " >
90
91
<code class =" devsite-terminal " >sudo apt-get remove bazel</code >
91
92
</pre >
92
93
<!-- common_typos_enable -->
93
94
94
- Then install Bazel version 0.26 .0:
95
+ Download and install ` bazel ` version 3.1 .0:
95
96
96
97
<!-- common_typos_disable -->
97
98
<pre class =" devsite-click-to-copy " >
98
- <code class =" devsite-terminal " >wget https://github.com/bazelbuild/bazel/releases/download/0.26.0/bazel_0.26.0-linux-x86_64.deb</code >
99
- <code class =" devsite-terminal " >sudo dpkg -i bazel_0.26.0-linux-x86_64.deb</code >
99
+ <code class =" devsite-terminal " >wget https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel_3.1.0-linux-x86_64.deb
100
+ </code >
101
+ <code class =" devsite-terminal " >sudo dpkg -i bazel_3.1.0-linux-x86_64.deb</code >
102
+ </pre >
103
+ <!-- common_typos_enable -->
104
+
105
+ To prevent automatic updating of ` bazel ` to an incompatible version, run the following:
106
+
107
+ <!-- common_typos_disable -->
108
+ <pre class =" devsite-click-to-copy " >
109
+ <code class =" devsite-terminal " >sudo apt-mark hold bazel</code >
110
+ </pre >
111
+ <!-- common_typos_enable -->
112
+
113
+ Finally, confirm installation of the correct ` bazel ` version:
114
+
115
+ <!-- common_typos_disable -->
116
+ <pre class =" devsite-click-to-copy " >
117
+ <code class =" devsite-terminal " >bazel --version</code >
100
118
</pre >
101
119
<!-- common_typos_enable -->
102
120
103
121
104
122
### 4. Build TensorFlow from source
105
123
106
- Read the TensorFlow [ build from source] ( https://www.tensorflow.org/install/source )
107
- guide for details. TensorFlow Quantum is compatible with TensorFlow version  ; 2.1 .
124
+ Here we adapt instructions from the TensorFlow [ build from source] ( https://www.tensorflow.org/install/source )
125
+ guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version  ; 2.3 .
108
126
109
127
Download the
110
128
<a href =" https://github.com/tensorflow/tensorflow " class =" external " >TensorFlow source code</a >:
@@ -113,37 +131,28 @@ Download the
113
131
<pre class =" devsite-click-to-copy " >
114
132
<code class =" devsite-terminal " >git clone https://github.com/tensorflow/tensorflow.git</code >
115
133
<code class =" devsite-terminal " >cd tensorflow</code >
116
- <code class =" devsite-terminal " >git checkout v2.1.0 </code >
134
+ <code class =" devsite-terminal " >git checkout v2.3.1 </code >
117
135
</pre >
118
136
119
- Install the TensorFlow dependencies:
137
+ Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies:
120
138
121
139
<!-- common_typos_disable -->
122
140
<pre class =" devsite-click-to-copy " >
123
- <code class =" devsite-terminal " >python3 -m pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'</code >
124
- <code class =" devsite-terminal " >python3 -m pip install -U keras_applications --no-deps</code >
125
- <code class =" devsite-terminal " >python3 -m pip install -U keras_preprocessing --no-deps</code >
141
+ <code class =" devsite-terminal " >pip install -U pip six numpy wheel setuptools mock 'future>=0.17.1'</code >
142
+ <code class =" devsite-terminal " >pip install -U keras_applications --no-deps</code >
143
+ <code class =" devsite-terminal " >pip install -U keras_preprocessing --no-deps</code >
144
+ <code class =" devsite-terminal " >pip install numpy==1.18.0</code >
126
145
</pre >
127
146
<!-- common_typos_enable -->
128
147
129
- Configure the TensorFlow build. The default Python location and Python library
130
- paths should point inside the virtual environment. The default options are
131
- recommended:
148
+ 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.
132
149
133
150
<!-- common_typos_disable -->
134
151
<pre class =" devsite-click-to-copy " >
135
152
<code class =" devsite-terminal " >./configure</code >
136
153
</pre >
137
154
<!-- common_typos_enable -->
138
155
139
- Verify that your Bazel version is correct:
140
-
141
- <!-- common_typos_disable -->
142
- <pre class =" devsite-click-to-copy " >
143
- <code class =" devsite-terminal " >bazel version</code >
144
- </pre >
145
- <!-- common_typos_enable -->
146
-
147
156
Build the TensorFlow package:
148
157
149
158
<!-- common_typos_disable -->
@@ -154,35 +163,28 @@ Build the TensorFlow package:
154
163
155
164
Note: It may take over an hour to build the package.
156
165
157
- After the build is complete, install the package:
166
+ After the build is complete, install the package and leave the TensorFlow directory :
158
167
159
168
<!-- common_typos_disable -->
160
169
<pre class =" devsite-click-to-copy " >
161
170
<code class =" devsite-terminal " >./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg</code >
162
171
<code class =" devsite-terminal " >pip install /tmp/tensorflow_pkg/<var >name_of_generated_wheel</var >.whl</code >
172
+ <code class =" devsite-terminal " >cd ..</code >
163
173
</pre >
164
174
<!-- common_typos_enable -->
165
175
166
176
### 5. Download TensorFlow Quantum
167
177
168
- Download the TensorFlow Quantum source code and install the requirements:
178
+ 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:
169
179
170
180
<!-- common_typos_disable -->
171
181
<pre class =" devsite-click-to-copy " >
172
- <code class =" devsite-terminal " >cd ..</code >
173
- <code class =" devsite-terminal " >git clone https://github.com/tensorflow/quantum.git</code >
182
+ <code class =" devsite-terminal " >git clone https://github.com/<var >username</var >/quantum.git</code >
174
183
<code class =" devsite-terminal " >cd quantum</code >
175
- <code class =" devsite-terminal " >python3 -m pip install -r requirements.txt</code >
184
+ <code class =" devsite-terminal " >pip install -r requirements.txt</code >
176
185
</pre >
177
186
<!-- common_typos_enable -->
178
187
179
- Verify your Bazel version (since it can auto-update):
180
-
181
- <!-- common_typos_disable -->
182
- <pre class =" devsite-click-to-copy " >
183
- <code class =" devsite-terminal " >bazel version</code >
184
- </pre >
185
- <!-- common_typos_enable -->
186
188
187
189
### 6. Build the TensorFlow Quantum pip package
188
190
@@ -197,4 +199,12 @@ Build the TensorFlow Quantum pip package and install:
197
199
</pre >
198
200
<!-- common_typos_enable -->
199
201
202
+ To confirm that TensorFlow Quantum has successfully been installed, you can run the tests:
203
+ <!-- common_typos_disable -->
204
+ <pre class =" devsite-click-to-copy " >
205
+ <code class =" devsite-terminal " >./scripts/test_all.sh</code >
206
+ </pre >
207
+ <!-- common_typos_enable -->
208
+
209
+
200
210
Success: TensorFlow Quantum is now installed.
0 commit comments