FTorch - A library for coupling (Py)Torch machine learning models to Fortran codes.
Written in modern Fortran (2008) with source code available on GitHub it has been used in multiple scientific projects.
The associated JOSS paper can read here.

Find us on…

GitHub

FTorch


logo

Description

It is desirable to run machine learning (ML) models directly in Fortran. However, ML models are often trained in some other language using popular frameworks (say, Python and PyTorch).

FTorch is a library enabling users to directly couple their PyTorch models to Fortran code enabling the development of hybrid models that combine high-performance scientific computing with modern ML techniques. It supports running on both CPU and GPU, and is tested on UNIX and Windows operating systems

This site contains user and API documentation for FTorch as well as community information. There are also installation instructions for the library and numerous examples of performing coupling.

Using and Citing FTorch

FTorch is published in JOSS. To cite it in your work please refer to:

Atkinson et al., (2025). FTorch: a library for coupling PyTorch models to Fortran.
Journal of Open Source Software, 10(107), 7602, https://doi.org/10.21105/joss.07602


For examples of the many projects and publications that rely on FTorch please see our user case studies page. If you use FTorch and want to be included please get in touch.

The presentations page has a full list of recent talks about FTorch with links to slides and recordings.

News

For the latest updates and developments please see the news page and join our user mailing list.

Training

We offer training on FTorch in the form of tutorials and workshops. The companion repository https://github.com/Cambridge-ICCS/FTorch-workshop provides a set of exercises and solutions to help users get started with FTorch. Upcoming in-person sessions will be listed on the news page.

Contact

For feature requests, bug reports, or assistance in using FTorch please get in touch via GitHub by either raising an issue or opening an discussion.

For general enquiries please contact ICCS via iccs@maths.cam.ac.uk.

License

The FTorch source code, related files and documentation are distributed under an MIT License which can be viewed here.

Developer picture

Developer Info

ICCS Cambridge

Research Software Engineering team supporting software development and standards across the climate sciences domain.