diff --git a/src/metric/elementwise_metric.cu b/src/metric/elementwise_metric.cu index b1c764047..01aec16e1 100644 --- a/src/metric/elementwise_metric.cu +++ b/src/metric/elementwise_metric.cu @@ -217,7 +217,7 @@ struct EvalError { } } const char *Name() const { - static std::string name; + static thread_local std::string name; if (has_param_) { std::ostringstream os; os << "error"; @@ -315,7 +315,7 @@ struct EvalTweedieNLogLik { << "tweedie variance power must be in interval [1, 2)"; } const char *Name() const { - static std::string name; + static thread_local std::string name; std::ostringstream os; os << "tweedie-nloglik@" << rho_; name = os.str();