setup.py后面必须加上
setup(
name='droid_backends',
ext_modules=[
CUDAExtension('droid_backends',
include_dirs=[osp.join(ROOT, 'thirdparty/eigen')],
sources=[
'src/droid.cpp',
'src/droid_kernels.cu',
'src/correlation_kernels.cu',
'src/altcorr_kernel.cu',
],
extra_compile_args={
'cxx': ['-O3'],
'nvcc': ['-O3',
'-gencode=arch=compute_60,code=sm_60',
'-gencode=arch=compute_61,code=sm_61',
'-gencode=arch=compute_70,code=sm_70',
'-gencode=arch=compute_75,code=sm_75',
'-gencode=arch=compute_80,code=sm_80',
'-gencode=arch=compute_86,code=sm_86',
"-gencode=arch=compute_90,code=sm_90", # RTX 50 系列(添加此行支持 RTX 5090)
"-gencode=arch=compute_90,code=compute_90", # 确保向前兼容
"-gencode=arch=compute_120,code=sm_120", # 添加 RTX 5090 的 sm_120 支持
"-gencode=arch=compute_120,code=compute_120",
]
}),
],
cmdclass={ 'build_ext' : BuildExtension }
)
表示对50系显卡的支持。
如果返回at::DeprecatedTypeProperties
源代码:
constexpr const char* at_dispatch_name = "sampler_forward_kernel";
at::ScalarType _st = ::detail::scalar_type(the_type); // 转换失败
后面要改得:
// 删除const auto& the_type = volume.type(); 这一行
constexpr const char* at_dispatch_name = "sampler_forward_kernel";
at::ScalarType _st = volume.scalar_type(); // 直接获取c10::ScalarType,无需转换
类似这种都这么改就行了
运行的时候发现了这个错误,搞了两天才高定:
File “/home/xxx/HI-SLAM2/hislam2/modules/corr.py”, line 47, in call
corr = CorrSampler.apply(self.corr_pyramid[i], coords/2**i, self.radius)
~~^
torch.AcceleratorError: CUDA error: no kernel image is available for execution on the device
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.
我通过
import droind_backends
print(droid_backends.__file__)
找到了这个文件的相应的位置,然后运行ls -l /home/xxx/anaconda3/envs/hislam2/lib/python3.11/site-packages/droid_backends-0.0.0-py3.11-linux-x86_64.egg/droid_backends.cpython-311-x86_64-linux-gnu.so
发现这个东西是好几天之前的,而不是自己刚刚编译的。我把他删除之后重新编译一遍,就好了。

被折叠的 条评论
为什么被折叠?



