Code Monkey home page Code Monkey logo

cppdocs's Introduction

pytorch/cppdocs

This repository is automatically generated to contain the website source for the PyTorch C++ API documentation at https://pytorch.org/cppdocs.

Please do not send pull requests against this repository to edit tutorial or documentation sources as it is automatically generated. Instead, edit the sources in https://github.com/pytorch/pytorch/tree/master/docs/cpp/source to change tutorials and notes, or the source code in the PyTorch documentation to update source-level docs. Otherwise, changes to this repository will be overwritten by the next automatic sync.

cppdocs's People

Contributors

goldsborough avatar joelmarcey avatar pytorchbot avatar soumith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppdocs's Issues

linker error in building a minimal C++ application

Hi there,
I tried to build a minimal C++ based on the latest nightly build of libtorch but got the following errors. Can someone help?
/lib/../lib64/crt1.o: In function _start': (.text+0x20): undefined reference to main'
.../libtorch_nightly/lib/libtorch.so: undefined reference to lgammaf@GLIBC_2.23' .../libtorch_nightly/lib/libtorch.so: undefined reference to lgamma@GLIBC_2.23'
collect2: error: ld returned 1 exit status
gmake[3]: *** [stylegan] Error 1
gmake[2]: *** [CMakeFiles/mymodel.dir/all] Error 2
gmake[1]: *** [CMakeFiles/mymodel.dir/rule] Error 2
gmake: *** [mymodel] Error 2

Direct Installation command

I was reading the docs, and I feel like here are some things that can be added, and since I'm working, I reaaaallly need it!

Here goes the list:

  • Ability to configure src/ as the source folder for source files
  • Ability to config include/ for user created Header files
  • Docs to install and unzip the Pytorch, instead of manually wgetting it, and unzipping

If these can be added, or I can be guide, that would be awesome!!

Regards,
Have a great day!

how to install or use libtorch for pythoners knowing a little about c++

hey, thanks for this great framework and the c++ API design philosophy is really user-friendly for old pytorch user using python.

could you please provide some more concrete examples about
(1) how to install and use libtorch not only with cmake ( add g++ example?);
(2) what is the best practice to use pybind to invoke c++ tensor functions or models in python.
considering some pythoners do have the desire to use libtorch and conduct mix programming but with knowing a little about the c++.

@goldsborough @soumith @apaszke

have a nice day.

Feedback

Hey, I just did a simple integration of libtorch as an addon for nodejs. The API worked very nice and I really enjoyed the design, it's very well done ! I'm adding in this issue some feedbacks (don't know if here is the best place, but here you go):

  • The torch::jit::load isn't exposed by just adding the torch/torch.h header, you have to include the torch/script.h as well, don't know if it is intentional but it took me some time to find the right header, maybe a documentation improvement could help;
  • There are some local paths hardcoded into the ATen cmake files, such as in share/cmake/ATen/ATenConfig.cmake: /Users/administrator/nightlies/2018_10_01/wheel_build_dirs/libtorch_2.7/pytorch/torch/lib/tmp_install/include;
  • Documentation is still missing some parts, especially regarding loading TorchScript, etc. Given that a lot of people will start to use the libtorch, I would be nice to have a expanded documentation on ATen/Torch API with some examples (I can contribute as well);
  • Problem when seeing the docs for the torch::jit::load (https://pytorch.org/cppdocs/api/function_namespacetorch_1_1jit_1ace2c44fb8af5905ae17834e81086b8a3.html#exhale-function-namespacetorch-1-1jit-1ace2c44fb8af5905ae17834e81086b8a3)
  • Many broken broken in the initial page of the docs (torch::nn, torch::optim, torch::data, torch::serialize, torch::jit and torch::python)

This is what I remember, if I see anything else I'll add it here as well.

Minimal Example: 'torch/torch.h' file not found

Hi, apologies if this is not an issue. I walked through the "Minimal Example" for Installing c++ Distributions of PyTorch, and I get through it with no issues. However, when I create the example-app.cpp file, clang throws an error 'torch/torch.h' file not found [clang: pp_file_not_found] (while in neovim) and this causes other issues in the file since it's not reading the next line #include <iostream>. Do I need to place libtorch somewhere within the project or somewhere else for it to be recognized by clang?

Compile with tensorRT error?

Hi, I want to deploy a detection model with TensoRT to accelerate the backbone and use libtorch to do detection(maily reshape and decode boxes) and nms, but how to compiler them together?
When I try to compiler them, many redefined class error appears. Please help me out. Thanks.
A minimal makefile example is appreciated. Thanks.

How to set up pytorch for c++ (with g++) via commandline not cmake

I have a Lapop with a nvidia graphicscard and I'm trying to use pytorch for cuda with g++. But i couldn't find any good information about dependecies e.g and my compiler always trohws errors, I'm currently using this command I found on the internet: "g++ -std=c++14 main.cpp -I ${TORCH_DIR}/include/torch/csrc/api/include/ -I ${TORCH_DIR}/include/ -L ${TORCH_DIR}/lib/ -L /usr/local/cuda/lib64 -L /usr/local/cuda/nvvm/lib64 -ltorch -lc10 -lc10_cuda -lnvrtc -lcudart_static -ldl -lrt -pthread -o out", but it just says: "torch/torch.h: file not found"

[Pytorch C++ Usage Support]

Hi.
I'm trying to convert my python model to C++.
But while doing so, when i call one class from another class, how do i register the class module.

class A(nn.Module):
def init(self, num_features):
super(A, self).init()
self.bn = BatchNorm2d(num_features)

def forward(self, x):
    bn = self.bn(x)
    return bn

def __call__(self, x):
    return self.forward(x)

class B(nn::Module):
def init(self, num_features)
super(BNCN_Gate, self).init()
self.bn = CustomBatchNorm(in_channels, renorm, arg_ex)
conv_gate = nn::sequential()
......`

How should write such using Pytorch C++ API.
Right now i'm able to do this:

`struct A : torch::nn::Module {
A(int64_t num_features) :
bn(torch::nn::BatchNorm(num_features)) {
}
torch::Tensor forward(torch::Tensor x) {
x = bn->forward(x);
return x;
}
torch::nn::BatchNorm bn;
};

struct BNCC_Gate : torch::nn::Module {
BNCC_Gate()
{
bn(CustomBatchNorm(3, NULL, NULL));
this->register_module("bn", bn);
conv_gate = torch::nn::Sequential();
......
}
};
But this is giving me error as: undefined bn.
How should i create a object of the class A and regsiter it to get the complete network structure in class B?

@goldsborough
@soumith @asmeurer @asuhan @xuhdev
Any help would be great.
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.