Exporting a FastAI model

Learn how to export a FastAI model

Last updated 18th August, 2020.


FastAI is a popular machine learning library supported by OVHcloud ML Serving. This tutorial will cover how to export a FastAI trained model.


  • A python environment with FastAI installed

Save a simple model

Let's take a simple example of a FastAI model to illustrate:

import os
from fastai.text import *

# Load dataset
path = untar_data(URLs.IMDB_SAMPLE)
df = pd.read_csv(path / 'texts.csv')
data_lm = TextLMDataBunch.from_csv(path, 'texts.csv')

# Initialize classifier
data_clas = TextClasDataBunch.from_csv(path, 'texts.csv', vocab=data_lm.train_ds.vocab, bs=32)
learn = language_model_learner(data_lm, AWD_LSTM, drop_mult=0.5)

# Train ...

# Export trainer

Your model is now serialized on your local file system in the my_export.pkl file.

Going further

Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.

These guides might also interest you...

OVHcloud Community

Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Discuss with the OVHcloud community

In accordance with the 2006/112/CE Directive, modified on 01/01/2015, prices exclude VAT. VAT may vary according to the customer's country of residence.