Switching to what is hopefully a better fix for the following CUDA error

error: calling a constexpr host function("log1p") from a device function("cuda_log1pexp") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.

The error only happens with some versions of CUDA.
pull/2150/head
Davis King 4 years ago
parent f8cfe63904
commit 7b564927d6

@ -633,14 +633,6 @@ if (NOT TARGET dlib)
endif()
endif()
if (CUDA_VERSION VERSION_LESS 10.3)
# To avoid this error from nvcc:
# error: calling a constexpr __host__ function("log1p") from a __device__ function("cuda_log1pexp")
# is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
# which is a bug in nvcc in this version of cuda.
list(APPEND FLAGS_FOR_NVCC "--expt-relaxed-constexpr")
endif()
set(CUDA_HOST_COMPILATION_CPP ON)
# Note that we add __STRICT_ANSI__ to avoid freaking out nvcc with gcc specific
# magic in the standard C++ header files (since nvcc uses gcc headers on

@ -1759,9 +1759,9 @@ namespace dlib
if (x <= -18)
return std::exp(x);
else if (-18 < x && x <= 9)
return std::log1p(std::exp(x));
return std::log1pf(std::exp(x));
else if (9 < x && x <= 16)
return x + std::exp(-x);
return x + expf(-x);
else
return x;
}

Loading…
Cancel
Save