Commit 7b564927 authored by Davis King's avatar Davis King
Browse files

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.
parent f8cfe639
...@@ -633,14 +633,6 @@ if (NOT TARGET dlib) ...@@ -633,14 +633,6 @@ if (NOT TARGET dlib)
endif() endif()
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) set(CUDA_HOST_COMPILATION_CPP ON)
# Note that we add __STRICT_ANSI__ to avoid freaking out nvcc with gcc specific # 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 # magic in the standard C++ header files (since nvcc uses gcc headers on
......
...@@ -1759,9 +1759,9 @@ namespace dlib ...@@ -1759,9 +1759,9 @@ namespace dlib
if (x <= -18) if (x <= -18)
return std::exp(x); return std::exp(x);
else if (-18 < x && x <= 9) else if (-18 < x && x <= 9)
return std::log1p(std::exp(x)); return std::log1pf(std::exp(x));
else if (9 < x && x <= 16) else if (9 < x && x <= 16)
return x + std::exp(-x); return x + expf(-x);
else else
return x; return x;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment