C++ Implementation of PyTorch Tutorials for Deep Learning Researchers
OS (Compiler)\libtorch | 1.5 | nightly |
---|---|---|
macOS (clang 9.1) | ||
macOS (clang 10.0) | ||
macOS (clang 11.0) | ||
Linux (gcc 5) | ||
Linux (gcc 6) | ||
Linux (gcc 7) | ||
Linux (gcc 8) | ||
Windows (msvc 2017) |
This repository provides tutorial code in C++ for deep learning researchers to learn PyTorch.
Python Tutorial: https://github.com/yunjey/pytorch-tutorial
Note: Interactive Tutorials are currently running on LibTorch Nightly Version.
So there are some tutorials which can break when working with nightly version.
conda create --name pytorch-cpp
conda activate pytorch-cpp
conda install xeus-cling notebook -c conda-forge
git clone https://github.com/prabhuomkar/pytorch-cpp.git
cd pytorch-cpp
cmake -B build #<options>
Note for Windows users:
Libtorch only supports 64bit Windows and an x64 generator needs to be specified. For Visual Studio this can be done by appending-A x64
to the above command.
Some useful options:
Option | Default | Description |
---|---|---|
-D CUDA_V=(9.2|10.1|10.2|none) |
none |
Download libtorch for a CUDA version (none = download CPU version). |
-D DOWNLOAD_DATASETS=(OFF|ON) |
ON |
Download all datasets used in the tutorials. |
-D CMAKE_PREFIX_PATH=path/to/libtorch/share/cmake/Torch |
Skip the downloading of libtorch and use your own local version instead. |
cmake --build build
Note for Windows users:
The CMake script downloads the Release version of libtorch, so--config Release
has to be appended to the build command.General Note:
By default all tutorials will be built. If you only want to build one specific tutorial, specify thetarget
parameter for the build command. For example to only build the language model tutorial, append--target language-model
(target name = tutorial foldername with all underscores replaced with hyphens).
- (IMPORTANT!) First change into the tutorial's directory within
build/tutorials
. For example, assuming you are in thepytorch-cpp
directory and want to change to the pytorch basics tutorial folder:cd build/tutorials/basics/pytorch_basics # In general: cd build/tutorials/{basics|intermediate|advanced}/{tutorial_name}
- Run the executable. Note that the executable's name is the tutorial's foldername with all underscores replaced with hyphens (e.g. for tutorial folder:
pytorch_basics
-> executable name:pytorch-basics
(orpytorch-basics.exe
on Windows)). For example, to run the pytorch basics tutorial:
Linux/MacWindows./pytorch-basics # In general: ./{tutorial-name}
.\pytorch-basics.exe # In general: .\{tutorial-name}.exe
- Convolutional Neural Network
- Deep Residual Network
- Recurrent Neural Network
- Bidirectional Recurrent Neural Network
- Language Model (RNN-LM)
- Generative Adversarial Networks
- Variational Auto-Encoder
- Neural Style Transfer
- Image Captioning (CNN-RNN)
This repository is licensed under MIT as given in LICENSE.