在 Jetson Nano 上安装 C++ 版 torchvision

问题描述 投票:0回答:1

我想在我的 Jetson Nano (Jetpack 4.5) 上使用 torchvision c++。

我只需要 torchvision 中的 torchvision::ops::nms 函数。如果您可以提供该函数的源代码或使用 torch (c++) 实现该函数的替代实现,请分享,并且不再需要安装。

我尝试了很多方法安装,但还没有成功。

例如,我尝试了https://www.neuralception.com/settingupopencv/这种方法,但在运行时出现此错误

make
并且无法解决。

[  2%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/io/image/cpu/common_jpeg.cpp.o
[  5%] Building CXX object CMakeFiles/torchvision.dir/torchvision/csrc/io/image/cpu/decode_image.cpp.o
In file included from /usr/include/c++/7/bits/stl_algobase.h:59:0,
                 from /usr/include/c++/7/memory:62,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/aarch64-linux-gnu/c++/7/bits/c++config.h:250:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/aarch64-linux-gnu/c++/7/bits/c++config.h:438:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:59:0,
                 from /usr/include/c++/7/memory:62,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/aarch64-linux-gnu/c++/7/bits/c++config.h:563:3: error: operator '&&' has no right operand
   && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201505L \
   ^~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/memory:62,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:107:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/string:52:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/unique_ptr.h:37,
                 from /usr/include/c++/7/memory:80,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/basic_string.h:56:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/string:53:0,
                 from /usr/include/c++/7/stdexcept:39,
                 from /usr/include/c++/7/array:39,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/unique_ptr.h:37,
                 from /usr/include/c++/7/memory:80,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/basic_string.tcc:50:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/array:39:0,
                 from /usr/include/c++/7/tuple:39,
                 from /usr/include/c++/7/bits/unique_ptr.h:37,
                 from /usr/include/c++/7/memory:80,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/stdexcept:46:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/stdexcept:127:28: error: operator '||' has no left operand
 #if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS
                            ^~
/usr/include/c++/7/stdexcept:211:28: error: operator '||' has no left operand
 #if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS
                            ^~
In file included from /usr/include/c++/7/bits/ios_base.h:41:0,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /home/jets/Desktop/project/torch/include/c10/macros/Macros.h:228,
                 from /home/jets/Desktop/project/torch/include/c10/core/DeviceType.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/core/Device.h:3,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:6,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/locale_classes.h:354:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/bits/ios_base.h:46:0,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /home/jets/Desktop/project/torch/include/c10/macros/Macros.h:228,
                 from /home/jets/Desktop/project/torch/include/c10/core/DeviceType.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/core/Device.h:3,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:6,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/system_error:91:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/ios:42:0,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /home/jets/Desktop/project/torch/include/c10/macros/Macros.h:228,
                 from /home/jets/Desktop/project/torch/include/c10/core/DeviceType.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/core/Device.h:3,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:6,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/ios_base.h:230:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/bits/ios_base.h:254:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /home/jets/Desktop/project/torch/include/c10/macros/Macros.h:228:0,
                 from /home/jets/Desktop/project/torch/include/c10/core/DeviceType.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/core/Device.h:3,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:6,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/sstream:297:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/sstream:826:0,
                 from /home/jets/Desktop/project/torch/include/c10/macros/Macros.h:228,
                 from /home/jets/Desktop/project/torch/include/c10/core/DeviceType.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/core/Device.h:3,
                 from /home/jets/Desktop/project/torch/include/c10/core/Allocator.h:6,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/sstream.tcc:92:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/locale:41:0,
                 from /usr/include/c++/7/iomanip:43,
                 from /home/jets/Desktop/project/torch/include/c10/util/logging_is_not_google_glog.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/util/Logging.h:28,
                 from /home/jets/Desktop/project/torch/include/c10/core/TensorImpl.h:19,
                 from /home/jets/Desktop/project/torch/include/ATen/core/TensorBody.h:14,
                 from /home/jets/Desktop/project/torch/include/ATen/Tensor.h:3,
                 from /home/jets/Desktop/project/torch/include/ATen/Context.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:9,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/locale_facets_nonio.h:719:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/bits/locale_facets_nonio.h:1567:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
/usr/include/c++/7/bits/locale_facets_nonio.h:1590:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
/usr/include/c++/7/bits/locale_facets_nonio.h:1712:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
/usr/include/c++/7/bits/locale_facets_nonio.h:1747:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
In file included from /usr/include/c++/7/bits/locale_facets_nonio.h:2013:0,
                 from /usr/include/c++/7/locale:41,
                 from /usr/include/c++/7/iomanip:43,
                 from /home/jets/Desktop/project/torch/include/c10/util/logging_is_not_google_glog.h:8,
                 from /home/jets/Desktop/project/torch/include/c10/util/Logging.h:28,
                 from /home/jets/Desktop/project/torch/include/c10/core/TensorImpl.h:19,
                 from /home/jets/Desktop/project/torch/include/ATen/core/TensorBody.h:14,
                 from /home/jets/Desktop/project/torch/include/ATen/Tensor.h:3,
                 from /home/jets/Desktop/project/torch/include/ATen/Context.h:4,
                 from /home/jets/Desktop/project/torch/include/ATen/ATen.h:9,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/locale_facets_nonio.tcc:352:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
/usr/include/c++/7/bits/locale_facets_nonio.tcc:564:33: error: operator '&&' has no right operand
       && _GLIBCXX_USE_CXX11_ABI == 0
                                 ^~
In file included from /usr/include/c++/7/list:63:0,
                 from /home/jets/Desktop/project/torch/include/ATen/core/dispatch/OperatorEntry.h:17,
                 from /home/jets/Desktop/project/torch/include/ATen/core/dispatch/Dispatcher.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/runtime/operator.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/ir/ir.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/function_impl.h:4,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/method.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/object.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/frontend/tracer.h:9,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/autograd/generated/variable_factories.h:12,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:7,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/stl_list.h:326:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/bits/stl_list.h:349:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/bits/stl_list.h:1886:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
/usr/include/c++/7/bits/stl_list.h:1955:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
In file included from /usr/include/c++/7/list:64:0,
                 from /home/jets/Desktop/project/torch/include/ATen/core/dispatch/OperatorEntry.h:17,
                 from /home/jets/Desktop/project/torch/include/ATen/core/dispatch/Dispatcher.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/runtime/operator.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/ir/ir.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/function_impl.h:4,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/method.h:7,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/api/object.h:6,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/jit/frontend/tracer.h:9,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/autograd/generated/variable_factories.h:12,
                 from /home/jets/Desktop/project/torch/include/torch/csrc/api/include/torch/types.h:7,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.h:3,
                 from /home/jets/Desktop/project/vision/torchvision/csrc/io/image/cpu/decode_image.cpp:1:
/usr/include/c++/7/bits/list.tcc:178:27: error: #if with no expression
 #if _GLIBCXX_USE_CXX11_ABI
                           ^
CMakeFiles/torchvision.dir/build.make:89: recipe for target 'CMakeFiles/torchvision.dir/torchvision/csrc/io/image/cpu/decode_image.cpp.o' failed
make[2]: *** [CMakeFiles/torchvision.dir/torchvision/csrc/io/image/cpu/decode_image.cpp.o] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/torchvision.dir/all' failed
make[1]: *** [CMakeFiles/torchvision.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

更改了编译器,尝试了多种其他方法,但仍然无法解决此问题。

尝试为python安装torchvision并在cmake中链接库(适用于libtorch安装),但torchvision目录中没有“include”或“libs”目录。

尝试使用 this 指令安装,但是当我运行

sudo -H pip3 install torchvision-0.11.0a0+fa347eb-cp36-cp36m-linux_aarch64.whl 
时,它显示“没有名为 Cython 的模块”,但我安装了 cython,然后它尝试从源代码构建 numpy 并再次失败(我安装了 numpy ).

这还不是全部,尝试了数百万种其他方法但仍然卡住了(甚至用中文谷歌搜索)。

如果您知道有什么可以帮忙的,请说出来。

c++ torchvision nvidia-jetson-nano
1个回答
0
投票

安装时不要使用 sudo

sudo -H pip3 install torchvision-0.11.0a0+fa347eb-cp36-cp36m-linux_aarch64.whl
sudo 将系统指向不同的 python 包,也称为系统范围包。要解决问题,请使用 sudo 安装所有依赖项或从上面的命令中删除 sudo

© www.soinside.com 2019 - 2024. All rights reserved.