Skip to content

Commit bd1f6a7

Browse files
committed
Fix swig on linux and clean cmake
1 parent 8c3a9e6 commit bd1f6a7

File tree

6 files changed

+30
-38
lines changed

6 files changed

+30
-38
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,21 @@ include_directories("${PROJ_ROOT}/paddle/cuda/include")
7272
include_directories("${CMAKE_CURRENT_BINARY_DIR}/proto")
7373

7474
set(EXTERNAL_LIBS
75-
# have not include gtest here.
7675
${GFLAGS_LIBRARIES}
7776
${GLOG_LIBRARIES}
7877
${CBLAS_LIBRARIES}
7978
${PROTOBUF_LIBRARY}
8079
${ZLIB_LIBRARIES}
80+
${PYTHON_LIBRARIES}
8181
)
8282

83+
if(WITH_GPU)
84+
list(APPEND EXTERNAL_LIB ${CUDA_LIBRARIES} ${CUDA_rt_LIBRARY})
85+
if(NOT WITH_DSO)
86+
list(APPEND EXTERNAL_LIB ${CUDNN_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} ${CUDA_curand_LIBRARY})
87+
endif(NOT WITH_DSO)
88+
endif(WITH_GPU)
89+
8390
add_subdirectory(proto)
8491
add_subdirectory(paddle)
8592
add_subdirectory(python)

cmake/external/python.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,3 @@ ENDIF(PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
216216

217217
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
218218
INCLUDE_DIRECTORIES(${PYTHON_NUMPY_INCLUDE_DIR})
219-
220-
MESSAGE("[Paddle] Python Executable: ${PYTHON_EXECUTABLE}")
221-
MESSAGE("[Paddle] Python Include: ${PYTHON_INCLUDE_DIRS}")
222-
MESSAGE("[Paddle] Python Libraries: ${PYTHON_LIBRARIES}")

cmake/util.cmake

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,12 @@ function(link_paddle_exe TARGET_NAME)
9595
paddle_parameter
9696
paddle_proto
9797
paddle_cuda
98-
${METRIC_LIBS}
9998
${EXTERNAL_LIBS}
10099
${CMAKE_THREAD_LIBS_INIT}
101100
${CMAKE_DL_LIBS}
102101
${RDMA_LD_FLAGS}
103102
${RDMA_LIBS})
104103

105-
if(WITH_PYTHON)
106-
target_link_libraries(${TARGET_NAME}
107-
${PYTHON_LIBRARIES} util)
108-
endif()
109-
110-
if(WITH_GPU)
111-
if(NOT WITH_DSO OR WITH_METRIC)
112-
target_link_libraries(${TARGET_NAME}
113-
${CUDNN_LIBRARY}
114-
${CUDA_curand_LIBRARY})
115-
CUDA_ADD_CUBLAS_TO_TARGET(${TARGET_NAME})
116-
endif()
117-
118-
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME )
119-
if(HAVE_CLOCK_GETTIME)
120-
target_link_libraries(${TARGET_NAME} rt)
121-
endif()
122-
endif()
123-
124104
add_dependencies(${TARGET_NAME} ${external_project_dependencies})
125105
endfunction()
126106

paddle/api/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,33 @@ SET(SWIG_MODULE_swig_paddle_EXTRA_DEPS
4545

4646
IF(APPLE)
4747
SET(CMAKE_LINK_FLAGS "-undefined dynamic_lookup -Wl,-all_load")
48+
ELSE(APPLE)
49+
SET(ARCHIVE_START "-Wl,--whole-archive")
50+
SET(ARCHIVE_END "-Wl,--no-whole-archive")
4851
ENDIF(APPLE)
4952

5053
SWIG_ADD_MODULE(swig_paddle python Paddle.i)
5154
SWIG_LINK_LIBRARIES(swig_paddle
5255
${CMAKE_LINK_FLAGS}
5356
${CMAKE_DL_LIBS}
5457
${EXTERNAL_LIBS}
55-
${PYTHON_LIBRARIES}
5658
${CMAKE_THREAD_LIBS_INIT}
5759
${RDMA_LD_FLAGS}
5860
${RDMA_LIBS}
5961
paddle_parameter
60-
paddle_function
6162
paddle_math
6263
paddle_utils
63-
paddle_gserver
6464
paddle_pserver
6565
paddle_api
6666
paddle_cuda
6767
paddle_trainer_lib
6868
paddle_network
6969
paddle_proto
70+
ARCHIVE_START
71+
paddle_gserver
72+
paddle_function
73+
${METRIC_LIBS}
74+
ARCHIVE_END
7075
)
7176

7277
add_custom_command(OUTPUT ${PROJ_ROOT}/paddle/dist/.timestamp

paddle/api/test/run_tests.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ popd > /dev/null
2020

2121
cd $SCRIPTPATH
2222

23-
$1 -m pip install ../../dist/*.whl
23+
rm -rf .test_env
24+
virtualenv .test_env
25+
source .test_env/bin/activate
26+
27+
python -m pip install ../../dist/*.whl
2428

2529
test_list="testArguments.py testGradientMachine.py testMatrix.py testVector.py testTrain.py testTrainer.py"
2630

@@ -29,7 +33,7 @@ export PYTHONPATH=$PWD/../../../python/
2933
for fn in $test_list
3034
do
3135
echo "test $fn"
32-
$1 $fn
36+
python $fn
3337
if [ $? -ne 0 ]; then
3438
exit 1
3539
fi

paddle/setup.py.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
from setuptools import setup, Extension
1717

1818
setup(name="py_paddle",
19-
version="@PADDLE_VERSION@",
20-
packages=['py_paddle'],
21-
include_package_data=True,
22-
package_data={'py_paddle':['*.py','_swig_paddle.so']},
23-
install_requires = [
24-
'numpy>=1.8.0', # The numpy is required.
25-
'protobuf>=2.4.1' # The paddle protobuf version
26-
],
19+
version="@PADDLE_VERSION@",
20+
packages=['py_paddle'],
21+
include_package_data=True,
22+
package_data={'py_paddle':['*.py','_swig_paddle.so']},
23+
install_requires = [
24+
'numpy>=1.8.0', # The numpy is required.
25+
'protobuf>=2.4.1' # The paddle protobuf version
26+
],
2727
)

0 commit comments

Comments
 (0)