Skip to content

Commit 3688f3c

Browse files
Update docs for building from source
PiperOrigin-RevId: 613981262
1 parent 57a0d99 commit 3688f3c

File tree

1 file changed

+30
-40
lines changed

1 file changed

+30
-40
lines changed

site/en/install/source.md

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ Install the TensorFlow *pip* package dependencies (if using a virtual
3434
environment, omit the `--user` argument):
3535

3636
<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>
3938
</pre>
4039

4140
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
242241

243242
## Build and install the pip package
244243

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-
258244
#### Bazel build options
259245

260246
Refer to the Bazel
@@ -270,33 +256,42 @@ that complies with the manylinux2014 package standard.
270256

271257
### Build the package
272258

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:
276261

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>
278266

267+
To build tensorflow GPU package:
279268
<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
281270
</pre>
282271

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>
284276

277+
To build nightly package, set `tf_nightly` instead of `tensorflow`, e.g.
278+
to build CPU nightly package:
285279
<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
287281
</pre>
288282

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>
292287

293288
### Install the package
294289

295290
The filename of the generated `.whl` file depends on the TensorFlow version and
296291
your platform. Use `pip install` to install the package, for example:
297292

298293
<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
300295
</pre>
301296

302297
Success: TensorFlow is now installed.
@@ -346,26 +341,23 @@ virtual environment:
346341

347342
1. Optional: Configure the build—this prompts the user to answer build
348343
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.
352346

353347
<pre class="devsite-disable-click-to-copy prettyprint lang-bsh">
354348
<code class="devsite-terminal tfo-terminal-root">./configure # if necessary</code>
355349

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>
361353
</pre>
362354

363355
Install and verify the package within the container:
364356

365357
<pre class="prettyprint lang-bsh">
366358
<code class="devsite-terminal tfo-terminal-root">pip uninstall tensorflow # remove current version</code>
367359

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>
369361
<code class="devsite-terminal tfo-terminal-root">cd /tmp # don't import from source directory</code>
370362
<code class="devsite-terminal tfo-terminal-root">python -c "import tensorflow as tf; print(tf.__version__)"</code>
371363
</pre>
@@ -403,19 +395,17 @@ with GPU support:
403395
<pre class="devsite-disable-click-to-copy prettyprint lang-bsh">
404396
<code class="devsite-terminal tfo-terminal-root">./configure # if necessary</code>
405397

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>
409399

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>
411401
</pre>
412402

413403
Install and verify the package within the container and check for a GPU:
414404

415405
<pre class="prettyprint lang-bsh">
416406
<code class="devsite-terminal tfo-terminal-root">pip uninstall tensorflow # remove current version</code>
417407

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>
419409
<code class="devsite-terminal tfo-terminal-root">cd /tmp # don't import from source directory</code>
420410
<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>
421411
</pre>

0 commit comments

Comments
 (0)