Skip to content

Commit db9284e

Browse files
authored
Merge pull request #14617 from wopeizl/windows/online
Windows/online
2 parents 867c312 + 6a85dd3 commit db9284e

File tree

8 files changed

+26
-12
lines changed

8 files changed

+26
-12
lines changed

paddle/fluid/framework/parallel_executor.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License. */
2020

2121
#include "paddle/fluid/framework/ir/graph.h"
2222

23-
#ifdef PADDLE_WITH_CUDA
23+
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
2424
#include "paddle/fluid/platform/nccl_helper.h"
2525
#endif
2626

@@ -54,7 +54,7 @@ class ParallelExecutorPrivate {
5454
Scope *global_scope_; // not owned
5555
std::unique_ptr<details::SSAGraphExecutor> executor_;
5656

57-
#ifdef PADDLE_WITH_CUDA
57+
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
5858
std::unique_ptr<platform::NCCLContextMap> nccl_ctxs_;
5959
#endif
6060
bool own_local_scope_;
@@ -104,7 +104,7 @@ ParallelExecutor::ParallelExecutor(
104104

105105
if (member_->use_cuda_) {
106106
// Bcast Parameters to all GPUs
107-
#ifdef PADDLE_WITH_CUDA
107+
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
108108
auto *nccl_id_var = scope->FindVar(NCCL_ID_VARNAME);
109109
ncclUniqueId *nccl_id = nullptr;
110110
if (nccl_id_var != nullptr) {
@@ -124,7 +124,7 @@ ParallelExecutor::ParallelExecutor(
124124

125125
// Step 2. Convert main_program to SSA form and dependency graph. Also, insert
126126
// ncclOp
127-
#ifdef PADDLE_WITH_CUDA
127+
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
128128
std::unique_ptr<ir::Graph> graph = build_strategy.Apply(
129129
main_program, member_->places_, loss_var_name, params,
130130
member_->local_scopes_, member_->use_cuda_, member_->nccl_ctxs_.get());
@@ -213,7 +213,7 @@ void ParallelExecutor::BCastParamsToDevices(
213213
}
214214
auto &dims = main_tensor.dims();
215215
if (paddle::platform::is_gpu_place(main_tensor.place())) {
216-
#ifdef PADDLE_WITH_CUDA
216+
#if defined(PADDLE_WITH_CUDA) && !defined(_WIN32)
217217
std::vector<void *> buffers;
218218
size_t numel = main_tensor.numel();
219219
ncclDataType_t data_type = platform::ToNCCLDataType(main_tensor.type());

paddle/fluid/inference/analysis/analyzer_tester.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ void TestWord2vecPrediction(const std::string& model_path) {
7676
0.000932706};
7777
const size_t num_elements = outputs.front().data.length() / sizeof(float);
7878
// The outputs' buffers are in CPU memory.
79-
for (size_t i = 0; i < std::min((size_t)5UL, num_elements); i++) {
79+
for (size_t i = 0; i < std::min(static_cast<size_t>(5UL), num_elements);
80+
i++) {
8081
LOG(INFO) << "data: "
8182
<< static_cast<float*>(outputs.front().data.data())[i];
8283
PADDLE_ENFORCE(static_cast<float*>(outputs.front().data.data())[i],

paddle/fluid/memory/detail/system_allocator.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ void CPUAllocator::Free(void* p, size_t size, size_t index) {
8686
munlock(p, size);
8787
#endif
8888
}
89+
#ifdef _WIN32
90+
_aligned_free(p);
91+
#else
8992
free(p);
93+
#endif
9094
}
9195

9296
bool CPUAllocator::UseGpu() const { return false; }

paddle/fluid/operators/dropout_op_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15+
#ifndef _WIN32
1516
#include <unistd.h>
17+
#endif
1618

1719
#include <string>
1820
#include <thread> // NOLINT

paddle/fluid/operators/math/sequence_pooling.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ limitations under the License. */
1616
#include "paddle/fluid/operators/math/math_function.h"
1717
#include "paddle/fluid/operators/math/sequence_pooling.h"
1818
#include "paddle/fluid/platform/cuda_primitives.h"
19+
#include "paddle/fluid/platform/macros.h"
1920

2021
namespace paddle {
2122
namespace operators {
2223
namespace math {
2324

24-
#define FLT_MAX __FLT_MAX__
25-
2625
template <typename T>
2726
struct MaxPoolFunctor {
2827
HOSTDEVICE void operator()(const T* input, const size_t start,

paddle/fluid/platform/gpu_info.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ limitations under the License. */
2020
#include "paddle/fluid/platform/enforce.h"
2121

2222
#ifndef _WIN32
23-
const float fraction_of_gpu_memory_to_use = 0.92f;
23+
constexpr static float fraction_of_gpu_memory_to_use = 0.92f;
2424
#else
2525
// fraction_of_gpu_memory_to_use cannot be too high on windows,
2626
// since the win32 graphic sub-system can occupy some GPU memory
2727
// which may lead to insufficient memory left for paddle
28-
const float fraction_of_gpu_memory_to_use = 0.5f;
28+
constexpr static float fraction_of_gpu_memory_to_use = 0.5f;
2929
#endif
3030

3131
DEFINE_double(fraction_of_gpu_memory_to_use, fraction_of_gpu_memory_to_use,

paddle/fluid/pybind/protobuf.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ limitations under the License. */
2929
namespace pybind11 {
3030
namespace detail {
3131

32+
#if !defined(PYBIND11_HIDDEN)
33+
#ifdef _WIN32
34+
#define PYBIND11_HIDDEN __declspec(dllexport)
35+
#else
36+
#define PYBIND11_HIDDEN __attribute__((visibility("hidden")))
37+
#endif
38+
#endif
39+
3240
// Can be replaced by a generic lambda in C++14
33-
struct __attribute__((visibility("hidden"))) paddle_variant_caster_visitor
41+
struct PYBIND11_HIDDEN paddle_variant_caster_visitor
3442
: public boost::static_visitor<handle> {
3543
return_value_policy policy;
3644
handle parent;

python/paddle/fluid/tests/unittests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function(py_test_modules TARGET_NAME)
6363
set(multiValueArgs MODULES DEPS ENVS)
6464
cmake_parse_arguments(py_test_modules "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
6565
add_test(NAME ${TARGET_NAME}
66-
COMMAND env PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_modules_ENVS}
66+
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_modules_ENVS}
6767
${PYTHON_EXECUTABLE} ${PADDLE_SOURCE_DIR}/tools/test_runner.py ${py_test_modules_MODULES}
6868
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
6969
if (py_test_modules_SERIAL)

0 commit comments

Comments
 (0)