Skip to content

Commit 0964de1

Browse files
authored
Merge pull request #12505 from velconia/fix_pserver_shutdown
Fix pserver can NOT start with DebugString problem
2 parents 3185d38 + f9ef0ee commit 0964de1

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ include(external/snappy) # download snappy
200200
include(external/snappystream)
201201
include(external/threadpool)
202202

203+
if(WITH_GPU)
204+
include(cuda)
205+
include(tensorrt)
206+
include(external/anakin)
207+
else()
208+
set(WITH_ANAKIN OFF CACHE STRING "Anakin is valid only when GPU is set." FORCE)
209+
endif()
210+
203211
include(cudnn) # set cudnn libraries, must before configure
204212
include(cupti)
205213
include(configure) # add paddle env configuration
@@ -228,14 +236,6 @@ set(EXTERNAL_LIBS
228236
${PYTHON_LIBRARIES}
229237
)
230238

231-
if(WITH_GPU)
232-
include(cuda)
233-
include(tensorrt)
234-
include(external/anakin)
235-
else()
236-
set(WITH_ANAKIN OFF CACHE STRING "Anakin is valid only when GPU is set." FORCE)
237-
endif()
238-
239239
if(WITH_AMD_GPU)
240240
find_package(HIP)
241241
include(hip)

cmake/cudnn.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
2121
${CUDNN_ROOT}/lib64
2222
${CUDNN_ROOT}/lib
2323
${CUDNN_ROOT}/lib/${TARGET_ARCH}-linux-gnu
24+
${CUDNN_ROOT}/local/cuda-${CUDA_VERSION}/targets/${TARGET_ARCH}-linux/lib/
2425
$ENV{CUDNN_ROOT}
2526
$ENV{CUDNN_ROOT}/lib64
2627
$ENV{CUDNN_ROOT}/lib

paddle/fluid/framework/operator.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License. */
1818

1919
#include "paddle/fluid/framework/data_transform.h"
2020
#include "paddle/fluid/framework/executor.h"
21+
#include "paddle/fluid/framework/lod_tensor.h"
2122
#include "paddle/fluid/framework/operator.h"
2223
#include "paddle/fluid/framework/shape_inference.h"
2324
#include "paddle/fluid/framework/var_type.h"
@@ -57,7 +58,11 @@ static DDim GetDims(const Scope& scope, const std::string& name,
5758
}
5859

5960
if (var->IsType<LoDTensor>()) {
60-
return var->Get<LoDTensor>().dims();
61+
const LoDTensor& tensor = var->Get<LoDTensor>();
62+
if (UNLIKELY(!tensor.IsInitialized())) {
63+
return DDim({-1});
64+
}
65+
return tensor.dims();
6166
} else if (var->IsType<SelectedRows>()) {
6267
if (get_actual_dim) {
6368
return var->Get<SelectedRows>().value().dims();
@@ -74,8 +79,13 @@ static std::string GetDtype(const Scope& scope, const std::string& name) {
7479
if (var == nullptr) {
7580
return "";
7681
}
82+
7783
if (var->IsType<LoDTensor>()) {
78-
return DataTypeToString(ToDataType(var->Get<LoDTensor>().type()));
84+
const LoDTensor& tensor = var->Get<LoDTensor>();
85+
if (UNLIKELY(!tensor.IsInitialized())) {
86+
return "";
87+
}
88+
return DataTypeToString(ToDataType(tensor.type()));
7989
} else if (var->IsType<SelectedRows>()) {
8090
return DataTypeToString(
8191
ToDataType(var->Get<SelectedRows>().value().type()));
@@ -106,7 +116,11 @@ static LoD GetLoD(const Scope& scope, const std::string& name) {
106116
}
107117

108118
if (var->IsType<LoDTensor>()) {
109-
return var->Get<LoDTensor>().lod();
119+
const LoDTensor& tensor = var->Get<LoDTensor>();
120+
if (UNLIKELY(!tensor.IsInitialized())) {
121+
return default_lod;
122+
}
123+
return tensor.lod();
110124
} else {
111125
return default_lod;
112126
}

paddle/fluid/framework/tensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Tensor {
8282
template <typename T>
8383
const T* data() const;
8484

85-
bool IsInitialized() const;
85+
inline bool IsInitialized() const;
8686

8787
/**
8888
* @brief Return a pointer to mutable memory block.

0 commit comments

Comments
 (0)