小编tot*_*tok的帖子

在虚拟机上使用 OpenCV 重建 C++ 程序

我需要从 ubuntu 20.04 切换到 Windows 7 工作站。

我正在为Raspberry PI编写一个需要pthread的程序,因此我需要一个linux测试环境。

我安装了 ubuntu 20.04 VM 并重新安装了程序中使用的所有库:

  • OpenCV 4.2
  • 利托奇
  • Cpp数

这是我的 CMakeLists.txt :

cmake_minimum_required(VERSION 3.15)
project(POC_V4)

set(CMAKE_CXX_STANDARD 14)

# Specifying we are using pthread for UNIX systems.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -pthread -Wall")

find_package(OpenCV REQUIRED)
find_package(Torch REQUIRED)

if(NOT Torch_FOUND)
    message(FATAL_ERROR "Pytorch Not Found!")
endif(NOT Torch_FOUND)

message(STATUS "Pytorch status :")
message(STATUS "    libraries: ${TORCH_LIBRARIES}")

message(STATUS "OpenCV library status :")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

add_executable(POC_V4 <all_my_sources_and_headers>) …
Run Code Online (Sandbox Code Playgroud)

c++ linux opencv compilation cmake

2
推荐指数
1
解决办法
442
查看次数

Raspberry 上的 Libtorch 无法加载 pt 文件,但可以在 ubuntu 上运行

我正在尝试在 Raspberry PI 上使用 libtorch 构建 C++ 程序。该程序在 Ubuntu 上运行,但在 Raspberry 上构建时出现以下错误:

\n
error: use of deleted function \xc3\xa2\xe2\x82\xac\xcb\x9cvoid torch::jit::script::Module::operator=(const torch::jit::script::Module&)\xc3\xa2\xe2\x82\xac\xe2\x84\xa2\nIn file included from /usr/include/torch/csrc/jit/ir.h:18,\n                 from /usr/include/torch/csrc/jit/tracer.h:9,\n                 from /usr/include/torch/csrc/autograd/generated/variable_factories.h:8,\n                 from /usr/include/torch/csrc/api/include/torch/types.h:7,\n                 from /usr/include/torch/script.h:3,\n                 from /tmp/tmp.k6618dczxt/src/../include/suvoNet.h:26,\n                 from /tmp/tmp.k6618dczxt/src/../include/classifier.h:17,\n                 from /tmp/tmp.k6618dczxt/src/classifier.cpp:11:\n/usr/include/torch/csrc/jit/script/module.h:319:3: note: declared here\n   TH_DISALLOW_COPY_AND_ASSIGN(Module);\n
Run Code Online (Sandbox Code Playgroud)\n

这是崩溃的代码:

\n
MyClass::MyClass() {\n    try {\n        // Deserialize the ScriptModule from a file using torch::jit::load().\n        network = torch::jit::load(MODEL_FILE);\n    }\n    catch (const c10::Error& e) {\n        std::cerr << "Error loading the model\\n";\n        exit(-1);\n    }\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

network声明为私有 …

c++ build raspberry-pi torch libtorch

2
推荐指数
1
解决办法
2106
查看次数

标签 统计

c++ ×2

build ×1

cmake ×1

compilation ×1

libtorch ×1

linux ×1

opencv ×1

raspberry-pi ×1

torch ×1