tuotuoxp / cpp-torch Goto Github PK
View Code? Open in Web Editor NEWcpp-torch is a C++ library, implemented as a wrapper around Torch libraries.
License: Apache License 2.0
cpp-torch is a C++ library, implemented as a wrapper around Torch libraries.
License: Apache License 2.0
The CMakeLists.txt for cpp-torch rely on a find_package(Torch REQUIRED)
even if the torch Lib never actually gets built (we only builf TH TH_NN ...)
If you try to compile from a machine that include a full torch install, it's going to pick it up from there, but if you try to compile from a new setup, it's going to complain about
Could not find a package configuration file provided by "Torch" with any of
the following names:
TorchConfig.cmake
torch-config.cmake
Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set
"Torch_DIR" to a directory containing one of the above files. If "Torch"
provides a separate development package or SDK, be sure it has been
installed.
Hi, first of all thank you so much for the api, its so simple to load the torch model into c api now and see the real quick results, But how about loading a custom model which is in torch(.t7) format.
how to add custom layers into your code?
Basically I have a model, and I tried loading it using your API, but got stuck and error was:
ERROR:
std::shared_ptrcpptorch::object object_loader::read_object(std::istream&): Assertion `0' failed.
Aborted (core dumped)
Hello,
I trained my model in python using PyTorch and now I want to make inference in cpptorch. I am not quite sure how to load my model. I tried saving my model using torch.save_state_dic() and then loading the file using code you provided but i got this error:
/home/aytop/Downloads/cpp-torch/src/loader.cpp:203: std::shared_ptrcpptorch::object object_loader::read_object(std::istream&): Assertion `0' failed.
Aborted (core dumped)
Any advice?
Actually we have image input in most time. Save image to .t7 format then load it is kinda unnecessary. Does cpp-torch supports image input currently?
When I want to read a tensor as a cuda tensor I get the following error:
.../main.cpp:11: undefined reference to `cpptorch::read_cuda_tensor(cpptorch::object const*)'
.../main.cpp:12: undefined reference to `std::ostream& operator<< <float, (GPUFlag)1>(std::ostream&, cpptorch::Tensor<float, (GPUFlag)1> const&)'
.../main.cpp:11: undefined reference to `cpptorch::Tensor<float, (GPUFlag)1>::~Tensor()'
.../main.cpp:11: undefined reference to `cpptorch::Tensor<float, (GPUFlag)1>::~Tensor()'
collect2: error: ld returned 1 exit status
make[3]: *** [TestApplication] Error 1
make[2]: *** [CMakeFiles/TestApplication.dir/all] Error 2
make[1]: *** [CMakeFiles/TestApplication.dir/rule] Error 2
make: *** [TestApplication] Error 2
my makefile looks as follows:
cmake_minimum_required(VERSION 3.8)
project(TestApplication)
set(CMAKE_CXX_STANDARD 11)
if(NOT CPPTORCH_FOUND)
find_package(cpptorch REQUIRED)
endif()
set(SOURCE_FILES main.cpp)
add_executable(TestApplication ${SOURCE_FILES})
target_include_directories(TestApplication PRIVATE ${CPPTORCH_INCLUDE_DIR})
target_link_libraries(TestApplication ${CPPTORCH_LIBRARIES})
do I need to link the cuda stuff somehow??
I'm failing to load a trained model, and i believe its because the project does not currently support loading nn.ConcatTable - is there any chance someone could quickly/easily add support for this?
Here is the error im getting when loading the trained mode:
cpp-torch/src/reader.h.inl:133: std::shared_ptr<cpptorch::nn::Layer<T, F> > object_reader<T, F>::build_layer(const cpptorch::object*) [with T = float; GPUFlag F = (GPUFlag)0u]: Assertion `0' failed.
Also, I dont see the ConcatTable .h or code file, and in the reader.h.inl it looks like its missing.
Hi, I wanted to try out your cpp wrapper around torch. While installing I get the following error when I try to 'make' :
[ 22%] Building CXX object CMakeFiles/cpptorch.dir/src/th_wrapper.cpp.o
/cpptorch/cpp-torch/src/th_wrapper.cpp:549:45: error: too few arguments to function ‘void THLongTensor_max(THLongTensor*, THLongTensor*, THLongTensor*, int, int)’
THLongTensor_max(values, l, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:555:46: error: too few arguments to function ‘void THFloatTensor_max(THFloatTensor*, THLongTensor*, THFloatTensor*, int, int)’
THFloatTensor_max(values, l, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:561:47: error: too few arguments to function ‘void THDoubleTensor_max(THDoubleTensor*, THLongTensor*, THDoubleTensor*, int, int)’
THDoubleTensor_max(values, l, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:567:49: error: too few arguments to function ‘void THLongTensor_sum(THLongTensor*, THLongTensor*, int, int)’
return THLongTensor_sum(values, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:567:49: error: return-statement with a value, in function returning 'void' [-fpermissive]
return THLongTensor_sum(values, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:572:50: error: too few arguments to function ‘void THFloatTensor_sum(THFloatTensor*, THFloatTensor*, int, int)’
return THFloatTensor_sum(values, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:572:50: error: return-statement with a value, in function returning 'void' [-fpermissive]
return THFloatTensor_sum(values, t, dimension);
^
/cpptorch/cpp-torch/src/th_wrapper.cpp:577:51: error: too few arguments to function ‘void THDoubleTensor_sum(THDoubleTensor*, THDoubleTensor*, int, int)’
return THDoubleTensor_sum(values, t, dimension);
^
cpptorch/cpp-torch/src/th_wrapper.cpp:577:51: error: return-statement with a value, in function returning 'void' [-fpermissive]
return THDoubleTensor_sum(values, t, dimension);
^
CMakeFiles/cpptorch.dir/build.make:86: recipe for target 'CMakeFiles/cpptorch.dir/src/th_wrapper.cpp.o' failed
make[2]: *** [CMakeFiles/cpptorch.dir/src/th_wrapper.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cpptorch.dir/all' failed
make[1]: *** [CMakeFiles/cpptorch.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
hi,
I made the example of openface and I got that only the forward() for each pic takes ~150 ms.
does anyone know why?
thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.