Skip to content

Commit 44ee251

Browse files
authored
fix UNIX cmake problem (#31113)
1 parent a60d93f commit 44ee251

7 files changed

Lines changed: 18 additions & 25 deletions

File tree

cmake/generic.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,16 +794,14 @@ function(py_test TARGET_NAME)
794794
if(WITH_COVERAGE AND NOT (WITH_INCREMENTAL_COVERAGE AND "$ENV{PADDLE_GIT_DIFF_PY_FILE}" STREQUAL ""))
795795
add_test(NAME ${TARGET_NAME}
796796
COMMAND ${CMAKE_COMMAND} -E env FLAGS_init_allocated_mem=true FLAGS_cudnn_deterministic=true
797-
FLAGS_cpu_deterministic=true
798-
PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_ENVS}
797+
FLAGS_cpu_deterministic=true ${py_test_ENVS}
799798
COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data
800799
${PYTHON_EXECUTABLE} -m coverage run --branch -p ${py_test_SRCS} ${py_test_ARGS}
801800
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
802801
else()
803802
add_test(NAME ${TARGET_NAME}
804803
COMMAND ${CMAKE_COMMAND} -E env FLAGS_init_allocated_mem=true FLAGS_cudnn_deterministic=true
805-
FLAGS_cpu_deterministic=true
806-
PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_ENVS}
804+
FLAGS_cpu_deterministic=true ${py_test_ENVS}
807805
${PYTHON_EXECUTABLE} -u ${py_test_SRCS} ${py_test_ARGS}
808806
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
809807
endif()

paddle/scripts/paddle_build.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ rem ------pre install python requirement----------
114114
where python
115115
where pip
116116
pip install wheel --user
117-
pip install --force-reinstall -r %work_dir%\python\requirements.txt --user
118-
pip install --force-reinstall -r %work_dir%\python\unittest_py\requirements.txt --user
117+
pip install -r %work_dir%\python\unittest_py\requirements.txt --user
118+
pip install -r %work_dir%\python\requirements.txt --user
119119
if %ERRORLEVEL% NEQ 0 (
120120
echo pip install requirements.txt failed!
121121
exit /b 7

python/paddle/fluid/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ add_subdirectory(unittests)
1010
add_subdirectory(book)
1111

1212
# TODO: support New Custom OP on Mac
13-
if(Linux)
13+
if(LINUX)
1414
add_subdirectory(custom_op)
1515
endif()
1616

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ py_test(test_sysconfig SRCS test_sysconfig.py)
1313
py_test(test_dispatch SRCS test_dispatch.py)
1414
set_tests_properties(test_dispatch PROPERTIES TIMEOUT 180)
1515

16-
if(NOT Linux)
16+
if(NOT LINUX)
1717
return()
1818
endif()
1919

python/paddle/fluid/tests/custom_op/test_dispatch.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,18 @@
2020
from utils import paddle_includes, extra_compile_args
2121
from paddle.utils.cpp_extension.extension_utils import run_cmd
2222

23-
# Because the shared lib already exists in the cache dir,
24-
# it will not be compiled again unless the cache dir is cleared.
23+
# Because Windows don't use docker, the shared lib already exists in the
24+
# cache dir, it will not be compiled again unless the shared lib is removed.
2525
if os.name == 'nt':
26-
cmd = 'rmdir {} /s/q'.format(get_build_directory())
27-
else:
28-
cmd = 'rm -rf {}'.format(get_build_directory())
29-
30-
run_cmd(cmd, True)
26+
cmd = 'del {}\\dispatch_op.pyd'.format(get_build_directory())
27+
run_cmd(cmd, True)
3128

3229
dispatch_op = load(
3330
name='dispatch_op',
3431
sources=['dispatch_test_op.cc'],
3532
extra_include_paths=paddle_includes, # add for Coverage CI
36-
extra_cflags=extra_compile_args) # add for Coverage CI
33+
extra_cflags=extra_compile_args, # add for Coverage CI
34+
verbose=True)
3735

3836

3937
class TestJitDispatch(unittest.TestCase):

python/paddle/fluid/tests/custom_op/test_simple_custom_op_jit.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,19 @@
2222
from utils import paddle_includes, extra_compile_args
2323
from test_simple_custom_op_setup import relu2_dynamic, relu2_static
2424

25-
# Because the shared lib already exists in the cache dir,
26-
# it will not be compiled again unless the cache dir is cleared.
25+
# Because Windows don't use docker, the shared lib already exists in the
26+
# cache dir, it will not be compiled again unless the shared lib is removed.
2727
if os.name == 'nt':
28-
cmd = 'rmdir {} /s/q'.format(get_build_directory())
29-
else:
30-
cmd = 'rm -rf {}'.format(get_build_directory())
31-
32-
run_cmd(cmd, True)
28+
cmd = 'del {}\\simple_jit_relu2.pyd'.format(get_build_directory())
29+
run_cmd(cmd, True)
3330

3431
# Compile and load custom op Just-In-Time.
3532
custom_module = load(
3633
name='simple_jit_relu2',
3734
sources=['relu_op_simple.cc', 'relu_op_simple.cu', 'relu_op3_simple.cc'],
3835
extra_include_paths=paddle_includes, # add for Coverage CI
39-
extra_cflags=extra_compile_args) # add for Coverage CI
36+
extra_cflags=extra_compile_args, # add for Coverage CI
37+
verbose=True)
4038

4139

4240
class TestJITLoad(unittest.TestCase):

python/paddle/utils/cpp_extension/extension_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ def find_cuda_home():
323323
if six.PY3:
324324
nvcc_path = nvcc_path.decode()
325325
nvcc_path = nvcc_path.rstrip('\r\n')
326-
log_v(nvcc_path)
327326
# for example: /usr/local/cuda/bin/nvcc
328327
cuda_home = os.path.dirname(os.path.dirname(nvcc_path))
329328
except:

0 commit comments

Comments
 (0)