4 errors detected in the compilation of “render_utils_kernel.cu“

发布时间:2023年12月22日

部署环境:

平台:Windows 10

Python:3.10.13

Torch:1.12.1

Cuda:11.7

通过nvcc编译render_utils_kernel.cu的时候会返回以下错误信息

render_utils_kernel.cu(441): error: calling a __host__ function("std::conditional< ::std::is_same_v|| ::std::is_same_v, long double, ? ?::std::conditional< ::std::is_same_v&& ::std::is_same_v, float, double> ::type> ::type ?::pow<double, float, (int)0> (T1, T2)") from a __global__ function("raw2alpha_cuda_kernel<double> ") is not allowed

render_utils_kernel.cu(441): error: identifier "pow<double, float, (int)0> " is undefined in device code

render_utils_kernel.cu(515): error: calling a __host__ function("std::conditional< ::std::is_same_v|| ::std::is_same_v, long double, ? ?::std::conditional< ::std::is_same_v&& ::std::is_same_v, float, double> ::type> ::type ?::pow<double, float, (int)0> (T1, T2)") from a __global__ function("raw2alpha_backward_cuda_kernel<double> ") is not allowed

render_utils_kernel.cu(515): error: identifier "pow<double, float, (int)0> " is undefined in device code

4 errors detected in the compilation of "render_utils_kernel.cu".

?根据错误提示,修改render_utils_kernel.cu的441行和515行

# 原始代码
alpha[i_pt] = 1 - pow((1 + e), (-interval));


# 修改为
alpha[i_pt] = 1 - pow((double)(1 + e), (double)(-interval));

?

# 原始代码
grad[i_pt] = min(exp_d[i_pt], 1e10) * pow((1+exp_d[i_pt]), (-interval-1)) * interval * grad_back[i_pt];

# 修改为

grad[i_pt] = min(exp_d[i_pt], 1e10) * pow((double)(1+exp_d[i_pt]), (double)(-interval-1)) * interval * grad_back[i_pt];

修改完这两行代码后,编译就可以顺利通过了

文章来源:https://blog.csdn.net/infinite_jason/article/details/135155120
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。