Install TensorFlow Ranking

There are several ways to set up your environment to use the TensorFlow Ranking library.

  • The easiest way to learn and use TensorFlow Ranking is run any of the tutorials Google Colab. Select the link at the top of the Quickstart tutorial).
  • To use the Ranking library on a local machine, install the tensorflow_ranking pip package.
  • If you have a unique machine configuration, you can build the package from source, using the Build from source instructions.

Install TensorFlow Ranking using pip

Install using pip.

pip install --upgrade tensorflow_ranking

Build from source

You can also install from source, which requires the Bazel build system.

  1. Install Bazel, Git and Pip.

    sudo apt-get update
    sudo apt-get install bazel git python3-pip python3-venv
  2. Clone the TensorFlow Ranking repository.

    git clone https://github.com/tensorflow/ranking.git

  3. Build TensorFlow Ranking wheel file and store them in a /tmp/ranking_pip folder.

    cd ranking  # folder cloned in Step 2.
    bazel build //tensorflow_ranking/tools/pip_package:build_pip_package
    bazel-bin/tensorflow_ranking/tools/pip_package/build_pip_package \
        /tmp/ranking_pip
  4. Activate a venv environment.

    python3 -m venv --system-site-packages venv
    source venv/bin/activate
  5. Install the wheel package in your venv environment.

    pip install /tmp/ranking_pip/tensorflow_ranking*.whl
    
  6. Optionally, run all TensorFlow Ranking tests.

    bazel test //tensorflow_ranking/...
    

For more information about installing Python, pip, TensorFlow, and working with Python virtual environments, see Install TensorFlow with pip.