Skip to content

Commit f14676a

Browse files
authored
doc: clarify support for requirements.txt in Tensorflow docs (#1512)
1 parent 5d66d76 commit f14676a

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

doc/using_tf.rst

+30-3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,34 @@ In your training script the channels will be stored in environment variables ``S
133133
``output_path``.
134134

135135

136+
Use third-party libraries
137+
-------------------------
138+
139+
If there are other packages you want to use with your script, you can use a ``requirements.txt`` to install other dependencies at runtime.
140+
141+
For training, support for installing packages using ``requirements.txt`` varies by TensorFlow version as follows:
142+
143+
- For TensorFlow 1.11 or newer using Script Mode without Horovod, TensorFlow 1.15.2 with Python 3.7 or newer, and TensorFlow 2.2 or newer:
144+
- Include a ``requirements.txt`` file in the same directory as your training script.
145+
- You must specify this directory using the ``source_dir`` argument when creating a TensorFlow estimator.
146+
- For older versions of TensorFlow using Script Mode with Horovod:
147+
- Write a shell script for your entry point that first calls ``pip install -r requirements.txt``, then runs your training script.
148+
- For an example of using shell scripts, see `this example notebook <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/tensorflow_script_mode_using_shell_commands/tensorflow_script_mode_using_shell_commands.ipynb>`__.
149+
- For older versions of TensorFlow using Legacy Mode:
150+
- Specify the path to your ``requirements.txt`` file using the ``requirements_file`` argument.
151+
152+
For serving, support for installing packages using ``requirements.txt`` varies by TensorFlow version as follows:
153+
154+
- For TensorFlow 1.11 or newer:
155+
- Include a ``requirements.txt`` file in the ``code`` directory.
156+
- For older versions of TensorFlow:
157+
- Specify the path to your ``requirements.txt`` file using the ``SAGEMAKER_REQUIREMENTS`` environment variable.
158+
159+
A ``requirements.txt`` file is a text file that contains a list of items that are installed by using ``pip install``.
160+
You can also specify the version of an item to install.
161+
For information about the format of a ``requirements.txt`` file, see `Requirements Files <https://pip.pypa.io/en/stable/user_guide/#requirements-files>`__ in the pip documentation.
162+
163+
136164
Create an Estimator
137165
===================
138166

@@ -215,7 +243,7 @@ Calling ``fit`` starts a SageMaker training job. The training job will execute t
215243
- starts asynchronous training
216244

217245
If the ``wait=False`` flag is passed to ``fit``, then it returns immediately. The training job continues running
218-
asynchronously. Later, a Tensorflow estimator can be obtained by attaching to the existing training job.
246+
asynchronously. Later, a TensorFlow estimator can be obtained by attaching to the existing training job.
219247
If the training job is not finished, it starts showing the standard output of training and wait until it completes.
220248
After attaching, the estimator can be deployed as usual.
221249

@@ -882,8 +910,7 @@ in the following code:
882910
You can also bring in external dependencies to help with your data
883911
processing. There are 2 ways to do this:
884912

885-
1. If you included ``requirements.txt`` in your ``source_dir`` or in
886-
your dependencies, the container installs the Python dependencies at runtime using ``pip install -r``:
913+
1. If your model archive contains ``code/requirements.txt``, the container will install the Python dependencies at runtime using ``pip install -r``.
887914

888915
.. code::
889916

0 commit comments

Comments
 (0)