Closed zzybj closed 3 years ago
你好,我只写了CUDA的版本。按照你的问题,我有三个建议,优先级依次递减:
- 尝试用低版本torch进行编译。我给torch的版本限定了1.5是因为我只在这个版本下测试过,低版本的torch可能也能编译。
- 尝试安装torch 1.5。无法安装torch 1.5常见的原因有Nvidia驱动版本不符,python环境冲突等等,经过排查一般是可以安装的。
- 如果实在搞不定可以自己用C++进行重构。因为CUDA版本和C++的核心逻辑是一致的, 只是CUDA版本可以自动并行化而已,在C下可以使用循环代替CUDA的并行运算。添加Pytorch C++拓展的具体操作可以参考这个教程。但是这是最不推荐的,因为不能使用GPU加速,数据在CPU和GPU之间来回传递也会产生Overhead。如果需要计算的Bounding Box多的话会非常慢。
祝好
非常感谢您的回答,但是我用的是实验室的服务器,不敢自己改配置......,您感觉这个排序只用pytorch能实现吗? 我发现pytorch好像只有一个sort函数,无法实现自定义排序,而且最终还需要代码在模型运行时能够正常执行,不知道您有没有什么好的思路能分享一下,万分感谢
你好,我只写了CUDA的版本。按照你的问题,我有三个建议,优先级依次递减:
- 尝试用低版本torch进行编译。我给torch的版本限定了1.5是因为我只在这个版本下测试过,低版本的torch可能也能编译。
- 尝试安装torch 1.5。无法安装torch 1.5常见的原因有Nvidia驱动版本不符,python环境冲突等等,经过排查一般是可以安装的。
- 如果实在搞不定可以自己用C++进行重构。因为CUDA版本和C++的核心逻辑是一致的, 只是CUDA版本可以自动并行化而已,在C下可以使用循环代替CUDA的并行运算。添加Pytorch C++拓展的具体操作可以参考这个教程。但是这是最不推荐的,因为不能使用GPU加速,数据在CPU和GPU之间来回传递也会产生Overhead。如果需要计算的Bounding Box多的话会非常慢。
祝好
大佬 您好 能帮忙看看这个错误吗 这是用torch1.5 ,install之后报的错误 running install running bdist_egg running egg_info writing sort_vertices.egg-info/PKG-INFO writing dependency_links to sort_vertices.egg-info/dependency_links.txt writing top-level names to sort_vertices.egg-info/top_level.txt reading manifest file 'sort_vertices.egg-info/SOURCES.txt' writing manifest file 'sort_vertices.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_ext building 'sort_vertices' extension gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/user1/anaconda3/lib/python3.6/site-packages/torch/include -I/home/user1/anaconda3/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/home/user1/anaconda3/lib/python3.6/site-packages/torch/include/TH -I/home/user1/anaconda3/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda-10.1/include -I/home/user1/anaconda3/include/python3.6m -c sort_vert.cpp -o build/temp.linux-x86_64-3.6/sort_vert.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=sort_vertices -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from sort_vert.cpp:1:0: utils.h:27:64: warning: backslash-newline at end of file
^
sort_vert.cpp: In function ‘at::Tensor sort_vertices(at::Tensor, at::Tensor, at::Tensor)’: utils.h:12:73: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_contiguous(), #x " must ne a contiguous tensor"); \ ^ sort_vert.cpp:7:5: note: in expansion of macro ‘CHECK_CONTIGUOUS’ CHECK_CONTIGUOUS(vertices); ^ utils.h:12:73: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_contiguous(), #x " must ne a contiguous tensor"); \ ^ sort_vert.cpp:8:5: note: in expansion of macro ‘CHECK_CONTIGUOUS’ CHECK_CONTIGUOUS(mask); ^ utils.h:12:73: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_contiguous(), #x " must ne a contiguous tensor"); \ ^ sort_vert.cpp:9:5: note: in expansion of macro ‘CHECK_CONTIGUOUS’ CHECK_CONTIGUOUS(num_valid); ^ utils.h:7:61: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_cuda(), #x " must be a CUDA tensor"); \ ^ sort_vert.cpp:10:5: note: in expansion of macro ‘CHECK_CUDA’ CHECK_CUDA(vertices); ^ utils.h:7:61: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_cuda(), #x " must be a CUDA tensor"); \ ^ sort_vert.cpp:11:5: note: in expansion of macro ‘CHECK_CUDA’ CHECK_CUDA(mask); ^ utils.h:7:61: error: ‘TORCH_CHECK’ was not declared in this scope TORCH_CHECK(x.is_cuda(), #x " must be a CUDA tensor"); \ ^ sort_vert.cpp:12:5: note: in expansion of macro ‘CHECK_CUDA’ CHECK_CUDA(num_valid); ^ utils.h:24:49: error: ‘TORCH_CHECK’ was not declared in this scope
^
sort_vert.cpp:13:5: note: in expansion of macro ‘CHECK_IS_FLOAT’ CHECK_IS_FLOAT(vertices); ^ utils.h:30:48: error: ‘TORCH_CHECK’ was not declared in this scope
^
sort_vert.cpp:14:5: note: in expansion of macro ‘CHECK_IS_BOOL’ CHECK_IS_BOOL(mask); ^ utils.h:18:47: error: ‘TORCH_CHECK’ was not declared in this scope
^
sort_vert.cpp:15:5: note: in expansion of macro ‘CHECK_IS_INT’
CHECK_IS_INT(num_valid);
^
sort_vert.cpp:23:54: error: expected primary-expression before ‘float’
sort_vertices_wrapper(b, n, m, vertices.data_ptr
关键的报错是这一句:
/bin/sh: /usr/local/cuda-8.0/bin/nvcc: No such file or directory
nvcc是nvidia的CUDA编译器,类似于c语言的gcc。这里的报错表示找不到nvcc。最可能的原因是没有安装cuda-toolkit。
安装方法参考官网的教程。注意必须使用10.2版本。
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
https://github.com/cmpute/d3d/blob/master/d3d/box/__init__.py 我写的版本,目前支持torch1.4+,理论上再往下支持也可以,只不过要改CMake
你好,我只写了CUDA的版本。按照你的问题,我有三个建议,优先级依次递减:
祝好