diff --git a/c10/core/impl/alloc_cpu.cpp b/c10/core/impl/alloc_cpu.cpp index f976e7b745e..b252f28a751 100644 --- a/c10/core/impl/alloc_cpu.cpp +++ b/c10/core/impl/alloc_cpu.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -121,7 +122,7 @@ void* alloc_cpu(size_t nbytes) { " bytes. Error code ", err, " (", - strerror(err), + c10::utils::str_error(err), ")"); if (is_thp_alloc(nbytes)) { #ifdef __linux__ @@ -129,7 +130,9 @@ void* alloc_cpu(size_t nbytes) { // general posix compliant systems can check POSIX_MADV_SEQUENTIAL advise. int ret = madvise(data, nbytes, MADV_HUGEPAGE); if (ret != 0) { - TORCH_WARN_ONCE("thp madvise for HUGEPAGE failed with ", strerror(errno)); + TORCH_WARN_ONCE( + "thp madvise for HUGEPAGE failed with ", + c10::utils::str_error(errno)); } #endif }