clearhanhui / learnlibtorch Goto Github PK
View Code? Open in Web Editor NEWLibTorch 中文教程。
License: MIT License
LibTorch 中文教程。
License: MIT License
感谢大佬的libtorch开源学习项目。
在运行chap1示例项目时,cmake ..
正常,make
时出现以下错误(部分):
/home/dev/dev/lib/libtorch/include/torch/csrc/api/include/torch/all.h:4:2: error: #error C++17 or later compatible compiler is required to use PyTorch.
#error C++17 or later compatible compiler is required to use PyTorch.
^~~~~
In file included from /home/dev/dev/lib/libtorch/include/c10/util/string_view.h:4:0,
from /home/dev/dev/lib/libtorch/include/c10/util/StringUtil.h:6,
from /home/dev/dev/lib/libtorch/include/c10/util/Exception.h:5,
from /home/dev/dev/lib/libtorch/include/c10/core/Device.h:5,
from /home/dev/dev/lib/libtorch/include/ATen/core/TensorBody.h:11,
from /home/dev/dev/lib/libtorch/include/ATen/core/Tensor.h:3,
from /home/dev/dev/lib/libtorch/include/ATen/Tensor.h:3,
from /home/dev/dev/lib/libtorch/include/torch/csrc/autograd/function_hook.h:3,
from /home/dev/dev/lib/libtorch/include/torch/csrc/autograd/cpp_hook.h:2,
from /home/dev/dev/lib/libtorch/include/torch/csrc/autograd/variable.h:6,
from /home/dev/dev/lib/libtorch/include/torch/csrc/autograd/autograd.h:3,
from /home/dev/dev/lib/libtorch/include/torch/csrc/api/include/torch/autograd.h:3,
from /home/dev/dev/lib/libtorch/include/torch/csrc/api/include/torch/all.h:7,
from /home/dev/dev/lib/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
from /home/dev/dev/LearnLibTorch/chap1/HelloWorld.cpp:9:
/home/dev/dev/lib/libtorch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
#error You need C++17 to compile PyTorch
看报错好像是编译引用pytorch需要c++17的支持,后面在CMakeList.txt
中加了c++17支持,如下:
cmake_minimum_required(VERSION 3.21)
project(HelloWorld)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
find_package(Torch REQUIRED)
add_executable(HelloWorld HelloWorld.cpp)
target_link_libraries(HelloWorld ${TORCH_LIBRARIES})
然后编译运行正常了。
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.