@@ -34,8 +34,7 @@ Install the TensorFlow *pip* package dependencies (if using a virtual
34
34
environment, omit the ` --user ` argument):
35
35
36
36
<pre class =" prettyprint lang-bsh " >
37
- <code class =" devsite-terminal " >pip install -U --user pip numpy wheel packaging requests opt_einsum</code >
38
- <code class =" devsite-terminal " >pip install -U --user keras_preprocessing --no-deps</code >
37
+ <code class =" devsite-terminal " >pip install -U --user pip</code >
39
38
</pre >
40
39
41
40
Note: A ` pip ` version >19.0 is required to install the TensorFlow 2 ` .whl `
@@ -242,19 +241,6 @@ There are some preconfigured build configs available that can be added to the
242
241
243
242
## Build and install the pip package
244
243
245
- The pip package is build in two steps. A ` bazel build ` commands creates a
246
- "package-builder" program. You then run the package-builder to create the
247
- package.
248
-
249
- ### Build the package-builder
250
- Note: GPU support can be enabled with ` cuda=Y ` during the ` ./configure ` stage.
251
-
252
- Use ` bazel build ` to create the TensorFlow 2.x package-builder:
253
-
254
- <pre class =" devsite-terminal devsite-click-to-copy " >
255
- bazel build [--config=option] //tensorflow/tools/pip_package:build_pip_package
256
- </pre >
257
-
258
244
#### Bazel build options
259
245
260
246
Refer to the Bazel
@@ -270,33 +256,42 @@ that complies with the manylinux2014 package standard.
270
256
271
257
### Build the package
272
258
273
- The ` bazel build ` command creates an executable named ` build_pip_package ` —this
274
- is the program that builds the ` pip ` package. Run the executable as shown
275
- below to build a ` .whl ` package in the ` /tmp/tensorflow_pkg ` directory.
259
+ To build pip package, you need to specify ` --repo_env=WHEEL_NAME ` flag.
260
+ depending on the provided name, package will be created, e.g:
276
261
277
- To build from a release branch:
262
+ To build tensorflow CPU package:
263
+ <pre class =" devsite-terminal devsite-click-to-copy " >
264
+ bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_cpu
265
+ </pre >
278
266
267
+ To build tensorflow GPU package:
279
268
<pre class =" devsite-terminal devsite-click-to-copy " >
280
- ./ bazel-bin/ tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
269
+ bazel build // tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow --config=cuda
281
270
</pre >
282
271
283
- To build from master, use ` --nightly_flag ` to get the right dependencies:
272
+ To build tensorflow TPU package:
273
+ <pre class =" devsite-terminal devsite-click-to-copy " >
274
+ bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_tpu --config=tpu
275
+ </pre >
284
276
277
+ To build nightly package, set ` tf_nightly ` instead of ` tensorflow ` , e.g.
278
+ to build CPU nightly package:
285
279
<pre class =" devsite-terminal devsite-click-to-copy " >
286
- ./ bazel-bin/ tensorflow/tools/pip_package/build_pip_package --nightly_flag /tmp/tensorflow_pkg
280
+ bazel build // tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tf_nightly_cpu
287
281
</pre >
288
282
289
- Although it is possible to build both CUDA and non-CUDA configurations under the
290
- same source tree, it's recommended to run ` bazel clean ` when switching between
291
- these two configurations in the same source tree.
283
+ As a result, generated wheel will be located in
284
+ <pre class =" devsite-terminal devsite-click-to-copy " >
285
+ bazel-bin/tensorflow/tools/pip_package/wheel_house/
286
+ </pre >
292
287
293
288
### Install the package
294
289
295
290
The filename of the generated ` .whl ` file depends on the TensorFlow version and
296
291
your platform. Use ` pip install ` to install the package, for example:
297
292
298
293
<pre class =" devsite-terminal prettyprint lang-bsh " >
299
- pip install /tmp/tensorflow_pkg /tensorflow-<var >version</var >-<var >tags</var >.whl
294
+ pip install bazel-bin/tensorflow/tools/pip_package/wheel_house /tensorflow-<var >version</var >-<var >tags</var >.whl
300
295
</pre >
301
296
302
297
Success: TensorFlow is now installed.
@@ -346,26 +341,23 @@ virtual environment:
346
341
347
342
1 . Optional: Configure the build—this prompts the user to answer build
348
343
configuration questions.
349
- 2 . Build the tool used to create the * pip* package.
350
- 3 . Run the tool to create the * pip* package.
351
- 4 . Adjust the ownership permissions of the file for outside the container.
344
+ 2 . Build the * pip* package.
345
+ 3 . Adjust the ownership permissions of the file for outside the container.
352
346
353
347
<pre class =" devsite-disable-click-to-copy prettyprint lang-bsh " >
354
348
<code class =" devsite-terminal tfo-terminal-root " >./configure # if necessary</code >
355
349
356
- <code class =" devsite-terminal tfo-terminal-root " >bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package</code >
357
-
358
- <code class =" devsite-terminal tfo-terminal-root " >./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt # create package</code >
359
-
360
- <code class =" devsite-terminal tfo-terminal-root " >chown $HOST_PERMS /mnt/tensorflow-<var >version</var >-<var >tags</var >.whl</code >
350
+ <code class =" devsite-terminal tfo-terminal-root " >bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow_cpu --config=opt</code >
351
+ `
352
+ <code class =" devsite-terminal tfo-terminal-root " >chown $HOST_PERMS bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-<var >version</var >-<var >tags</var >.whl</code >
361
353
</pre >
362
354
363
355
Install and verify the package within the container:
364
356
365
357
<pre class =" prettyprint lang-bsh " >
366
358
<code class =" devsite-terminal tfo-terminal-root " >pip uninstall tensorflow # remove current version</code >
367
359
368
- <code class =" devsite-terminal tfo-terminal-root " >pip install /mnt /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
360
+ <code class =" devsite-terminal tfo-terminal-root " >pip install bazel-bin/tensorflow/tools/pip_package/wheel_house /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
369
361
<code class =" devsite-terminal tfo-terminal-root " >cd /tmp # don't import from source directory</code >
370
362
<code class =" devsite-terminal tfo-terminal-root " >python -c "import tensorflow as tf; print(tf.__version__)"</code >
371
363
</pre >
@@ -403,19 +395,17 @@ with GPU support:
403
395
<pre class =" devsite-disable-click-to-copy prettyprint lang-bsh " >
404
396
<code class =" devsite-terminal tfo-terminal-root " >./configure # if necessary</code >
405
397
406
- <code class =" devsite-terminal tfo-terminal-root " >bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package</code >
407
-
408
- <code class =" devsite-terminal tfo-terminal-root " >./bazel-bin/tensorflow/tools/pip_package/build_pip_package /mnt # create package</code >
398
+ <code class =" devsite-terminal tfo-terminal-root " >bazel build //tensorflow/tools/pip_package:wheel --repo_env=WHEEL_NAME=tensorflow --config=cuda --config=opt</code >
409
399
410
- <code class =" devsite-terminal tfo-terminal-root " >chown $HOST_PERMS /mnt /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
400
+ <code class =" devsite-terminal tfo-terminal-root " >chown $HOST_PERMS bazel-bin/tensorflow/tools/pip_package/wheel_house /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
411
401
</pre >
412
402
413
403
Install and verify the package within the container and check for a GPU:
414
404
415
405
<pre class =" prettyprint lang-bsh " >
416
406
<code class =" devsite-terminal tfo-terminal-root " >pip uninstall tensorflow # remove current version</code >
417
407
418
- <code class =" devsite-terminal tfo-terminal-root " >pip install /mnt /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
408
+ <code class =" devsite-terminal tfo-terminal-root " >pip install bazel-bin/tensorflow/tools/pip_package/wheel_house /tensorflow-<var >version</var >-<var >tags</var >.whl</code >
419
409
<code class =" devsite-terminal tfo-terminal-root " >cd /tmp # don't import from source directory</code >
420
410
<code class =" devsite-terminal tfo-terminal-root " >python -c "import tensorflow as tf; print(\"Num GPUs Available: \", len(tf.config.list_physical_devices('GPU')))"</code >
421
411
</pre >
0 commit comments