GithubHelp home page GithubHelp logo

azure / huggingface-on-azure-databricks Goto Github PK

View Code? Open in Web Editor NEW
11.0 7.0 11.0 53 KB

Sample notebooks for optimized training and inference of Hugging Face models on Azure Databricks

License: MIT License

Jupyter Notebook 99.93% Shell 0.07%

huggingface-on-azure-databricks's Introduction

Training and Inference of Hugging Face models on Azure Databricks

This repository contains the code for the blog post series Optimized Training and Inference of Hugging Face Models on Azure Databricks.

If you want to reproduce the Databricks Notebooks, you should first follow the steps below to set up your environment:

  1. Create a Azure Databricks Workspace: you can create one by following these instructions and you can select the Standard pricing tier.

  2. Create a Cluster: you can follow these instructions to create your cluster. Your cluster configuration should be based on nodes of the type Standard_NC4as_T4_v3. Please make sure you have enough CPU cores of that type, otherwise work with your Azure subscription administrator to request a quota increase. Use the information below when creating your cluster:

  • Databricks runtime version should be at least 11.2 ML (GPU, Scala 2.12, Spark 3.3.0)
  • worker type should be Standard_NC4as_T4_v3 and number of workers should be at least 2 (the notebooks here were run with 8 worker nodes)
  • Driver type should be the same as worker type
  • Disable autoscaling
  1. Install Python libraries in your cluster: you can follow these instructions to install the libraries. Please install the following PyPI libraries in your cluster:
  • transformers==4.20.1
  • sentencepiece
  • datasets
  • deepspeed
  • mpi4py
  • ninja
  1. Install a cluster-scoped init script in your cluster. This is needed for installing the ninja Linux library. The script to be installed is the ninja_install.sh. You can follow these instructions to learn how to install it.

The notebooks should be run in the following order:

  1. data_preparation.ipynb: it downloads and prepares the datasets needed for model training and inference.
  2. model_training_hvd.ipynb: it performs distributed fine tuning using PyTorch and Horovod on the pre-trained Hugging Face model.
  3. model_training_hvd_deepspeed.ipynb: it performs distributed fine tuning using PyTorch and Horovod, optimized with DeepSpeed, on the pre-trained Hugging Face model.
  4. model_inference_hvd.ipynb: it performs distributed inference using PyTorch and Horovod on the fine-tuned model.
  5. model_inference_hvd_deepspeed.ipynb: it performs distributed inference using PyTorch and Horovod, optimized with DeepSpeed, on the fine-tuned model.
  6. model_inference_pudf.ipynb: it performs distributed inference using Transformer's Pipeline and Pandas UDF on the fine-tuned model.
  7. model_inference_pudf_deepspeed.ipynb it performs distributed inference using Transformer's Pipeline and Pandas UDF, optimized with DeepSpeed, on the fine-tuned model.

huggingface-on-azure-databricks's People

Contributors

microsoft-github-policy-service[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

huggingface-on-azure-databricks's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.