februari 05, 2019 —
Posted by Margaret Maynard-Reid, Google Developer Expert for ML
The TensorFlow 2.0 preview became available for testing in early January, and there has been a firehose of great info on the preview since then. I’m sharing my notes and useful links to help keep these all organized:
What is changing?How to set up to try the 2.0 preview?How to report bugs?How to join the community?Things are changing …
# Install TF 2.0 preview CPU version
$ pip install tf-nightly-2.0-preview
# Install tf 2.0 preview GPU version
$ pip install tf-nightly-gpu-2.0-preview
A GPU version of TF 2.0 for Colab became supported on 2/5/2019. To use that, include the “-gpu” prefix in your pip install commands above.
There are many API changes in TensorFlow 2.0 and the easiest way to automatically apply these changes is to run the v2 upgrade script. Note: at the moment the upgrade script only works on .py. In order to run the upgrade script on a notebook you will need to convert it to/from .py. One of my favorite issues 25448 tracks the feature that modifies the TF 2.0 upgrade script to convert .ipynb files.
See details on how to install TensorFlow with pip on tensorflow.org. TensorFlow signed the Python 3 Statement and 2.0 will support Python 3.5 and 3.7 (tracking Issue 25429).
At the time of writing this blog post, TensorFlow 2.0 preview only works with Python 2.7 or 3.6 (not 3.7). Using a virtual environment is likely the best way to test upgrades; you can use Virtualenv or Anaconda (Note: Anaconda wasn’t working initially, but started working around 2/7/2019).
If you try to install the preview in an environment with Python version 3.7, you are going to get an error “No matching distribution found for tf-nightly-2.0-preview”:
So make sure you have Python version 2.7 or 3.6. If you have multiple Python versions in your base environment, you can specify the Python version when creating the virtual environment.# Create a virtual environment With Virtualenv
$ virtualenv -p python3 [venv-name]
# Activate virtual environment
$ source [venv-name]/bin/activate
After you create a virtual environment with Python 2.7 or 3.6. and activate it, you are ready to install the TF 2.0 preview.
# Install tf 2.0 preview CPU version
$ pip install tf-nightly-2.0-preview
# Install tf 2.0 preview GPU version
$ pip install tf-nightly-gpu-2.0-preview
You can use the upgrade script to update your code to be 2.0 compliant. Note the upgrade script may not update all your code. Look at the report generated and see if you need to manually handle changes. Refer to the TensorFlow 2.0 Upgrade Guide for details.
# Run upgrade script (part of TensorFlow 1.13+)
$ tf_upgrade_v2 --infile foo.py --outfile foo-upgraded.py
Deactivate the virtual environment when done.
# Deactivate virtual environment when done
$ deactivate
Follow @tensorflow on Twitter to hear the latest news on TensorFlow 2.0!
februari 05, 2019
—
Posted by Margaret Maynard-Reid, Google Developer Expert for ML
The TensorFlow 2.0 preview became available for testing in early January, and there has been a firehose of great info on the preview since then. I’m sharing my notes and useful links to help keep these all organized:
What is changing?How to set up to try the 2.0 preview?How to report bugs?How to join the community?Things are changing …