Skip to content

It is tiny-dnn based on libtorch. Only headers without dependencies other than libtorch, deep learning framework

License

Notifications You must be signed in to change notification settings

Sanaxen/cpp_torch

Repository files navigation

header only, deep learning framework with no dependencies other than libtorch

Enabled to build with libtorch1.6 -> libtorch1.7.1 -> libtorch1.9.0 -> libtorch1.12.1 -> ** libtorch2.5.0 **

CUDA 11.8 is required for calculation using GPU.

also needs cuDNN

I am currently trying to upgrade libtorch to version 2.x. The current libtorch version of cpp_torch is 1.12.1, but I was hesitant to work on it because I thought upgrading to 2.0 would be a major change.

Notes.
Most of the code in cpp_torch did not require modification, but some functions are no longer available.
mnist datasets can no longer be downloaded, so examples of downloading and running datasets are not available.
torch_jit and some functions in torchvision are also Some functions of torch_jit and torchvision have also been moved to python, so it is no longer possible to do everything in C++ as in the examples provided.
The OpenCV version has also been changed.

The following are no longer required in libtorch-2.5.

LinkOption(libtorch1.9.0):
-INCLUDE:?warp_size@cuda@at@@YAHXZ

LinkOption(libtorch1.12.1):
-INCLUDE:?warp_size@cuda@at@@YAHXZ -INCLUDE:?_torch_cuda_cu_linker_symbol_op_cuda@native@at@@YA?AVTensor@2@AEBV32@@Z


Enabled to build with libtorch1.5


Directory structure

This project aims to be a wrapper for libtorch to make tiny-dnn compatible with GPU. tiny-dnn really great, but unfortunately it can not be calculated on a GPU. At first glance, this header-only framework aims to be used as written in tiny-dnn.

Include path settings

Libtorch_path/include
Libtorch_path/include/torch/csrc/api/include
cpp_torch_path
cpp_torch_path/include

Library path setting

Libtorch_path/lib
cpp_torch_path

Minimum include file

#include "cpp_torch.h"

progress
tiny_dnn

tiny_dnn::progress_display disp(train_images.size());

cpp_torch

cpp_torch::progress_display disp(train_images.size());

cpp_torch::progress_display disp(train_images.size());

data set download
What you can do is still limited.

config.h

options description default
USE_WINDOWS ON
USE_COLOR_CONSOLE ON
USE_ZLIB ON
USE_IMAGE_UTIL ON
USE_OPENCV_UTIL OpenCV >= 2.3 OFF ex. C:\dev\opencv-3.4.0

example

MNIS
CIFAR10
DCGAN

Latest topic

Do you have a favorite cute person?

This app was created with C # for GUI and C ++ only for core processing. Python is not required.

This application is in cpp_torch/example/app/dcgan_Application

Requirements

visual studio 2015,2017,2019

libtorch Please adapt the version of cuda to your environment

tiny-dnn

BSD 3-Clause License Copyright (c) 2013, Taiga Nomi

tiny_dnn was good, but unfortunately development has clearly stopped. Therefore, we created cpp_torch that can be used instead.

If you are building in C++,
Even if Python or pytorch (libtorch) is changed Should work.  

Will the Python app function correctly next month?  
Is there a guarantee that customers will not update python, etc.?