|
| 1 | +.. _cpp-frontend-tutorial: |
| 2 | + |
1 | 3 | Using the PyTorch C++ Frontend
|
2 | 4 | ==============================
|
3 | 5 |
|
| 6 | +**Author:** `Peter Goldsborough <https://github.com/goldsborough>`_ |
| 7 | + |
| 8 | +.. grid:: 2 |
| 9 | + |
| 10 | + .. grid-item-card:: :octicon:`mortar-board;1em;` What you will learn |
| 11 | + :class-card: card-prerequisites |
| 12 | + |
| 13 | + * How to build a C++ application that utilizes the PyTorch C++ frontend |
| 14 | + * How to define and train neural networks from C++ using PyTorch abstractions |
| 15 | + |
| 16 | + .. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites |
| 17 | + :class-card: card-prerequisites |
| 18 | + |
| 19 | + * PyTorch 1.5 or later |
| 20 | + * Basic understanding of C++ programming |
| 21 | + * Basic Ubuntu Linux environment with CMake >= 3.5; similar commands will work in a MacOS / Windows environment |
| 22 | + * (Optional) A CUDA-based GPU for the GPU training sections |
| 23 | + |
4 | 24 | The PyTorch C++ frontend is a pure C++ interface to the PyTorch machine learning
|
5 | 25 | framework. While the primary interface to PyTorch naturally is Python, this
|
6 | 26 | Python API sits atop a substantial C++ codebase providing foundational data
|
7 | 27 | structures and functionality such as tensors and automatic differentiation. The
|
8 |
| -C++ frontend exposes a pure C++11 API that extends this underlying C++ codebase |
| 28 | +C++ frontend exposes a pure C++17 API that extends this underlying C++ codebase |
9 | 29 | with tools required for machine learning training and inference. This includes a
|
10 | 30 | built-in collection of common components for neural network modeling; an API to
|
11 | 31 | extend this collection with custom modules; a library of popular optimization
|
@@ -137,14 +157,14 @@ on we'll use this ``CMakeLists.txt`` file:
|
137 | 157 |
|
138 | 158 | .. code-block:: cmake
|
139 | 159 |
|
140 |
| - cmake_minimum_required(VERSION 3.0 FATAL_ERROR) |
| 160 | + cmake_minimum_required(VERSION 3.5 FATAL_ERROR) |
141 | 161 | project(dcgan)
|
142 | 162 |
|
143 | 163 | find_package(Torch REQUIRED)
|
144 | 164 |
|
145 | 165 | add_executable(dcgan dcgan.cpp)
|
146 | 166 | target_link_libraries(dcgan "${TORCH_LIBRARIES}")
|
147 |
| - set_property(TARGET dcgan PROPERTY CXX_STANDARD 14) |
| 167 | + set_property(TARGET dcgan PROPERTY CXX_STANDARD 17) |
148 | 168 |
|
149 | 169 | .. note::
|
150 | 170 |
|
@@ -859,7 +879,7 @@ stacks them into a single tensor along the first dimension:
|
859 | 879 |
|
860 | 880 | Note that the MNIST dataset should be located in the ``./mnist`` directory
|
861 | 881 | relative to wherever you execute the training binary from. You can use `this
|
862 |
| -script <https://gist.github.com/goldsborough/6dd52a5e01ed73a642c1e772084bcd03>`_ |
| 882 | +script <https://gist.github.com/jbschlosser/94347505df6188f8764793ee29fd1bdd>`_ |
863 | 883 | to download the MNIST dataset.
|
864 | 884 |
|
865 | 885 | Next, we create a data loader and pass it this dataset. To make a new data
|
|
0 commit comments