-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-545] Fix broken cython build #10951
Changes from all commits
9d47eed
b3a9784
feecd35
fcc41a0
771a9b6
df1a291
0000950
86d1c90
f8a7b8c
646ea91
64057b3
5aaa8ad
1f4d53a
d252bea
cbae43d
be0744a
40ba9de
b5b0a54
c798d38
206e706
939e9ce
6df4e28
741d088
b32b8a6
9a526ec
17286a4
0d4a2aa
238f40c
7284615
57c3410
48039a2
96ed71f
991dd8c
d779ec9
5922f88
2fbe3fe
ed1e126
430f38d
e3ad1ca
58c2754
d0ef6fe
8140a4d
5093d83
868b170
bf798c9
4bca56c
e602d88
7dd3fa6
d80fc68
bc838c8
8cb0e62
94f5427
f6cee03
c505bf0
17f6c70
8ccc5f2
c6d1e49
786b2fd
e02cc4f
fc6f843
aa64c42
c90570c
a2bb2e1
d89de2f
2297f34
2cc7e85
2b8628c
efd5bd2
927ca1a
d02b89b
df89ef3
17a702c
8375dfe
d5f6fe6
c1480f5
fdf344f
7036d9b
e81dba9
92ea420
fcf5986
064f56f
b30ba00
aea2d41
9965e4c
371a8c6
9adca4d
09efb2b
61387bc
10d817c
adce15e
d7bdf63
83f5a1e
550ae4a
2253b76
95f42bd
f42fd0a
4ed7657
e81093a
9c836bc
4be2da6
0dce3f9
ec37d87
d5de9c4
11e30ca
d8c435c
bc526f2
25a3dfd
e300834
8dbc12f
10bc51e
a6005c7
db80ee7
a5ad3c0
1443088
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ def pack_lib(name, libs, include_gcov_data = false) { | |
sh returnStatus: true, script: """ | ||
set +e | ||
echo "Packing ${libs} into ${name}" | ||
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum | ||
for i in \$(echo ${libs} | sed -e 's/,/ /g'); do md5sum \$i; done | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to handle glob patterns in |
||
return 0 | ||
""" | ||
stash includes: libs, name: name | ||
|
@@ -86,7 +86,7 @@ def unpack_and_init(name, libs, include_gcov_data = false) { | |
sh returnStatus: true, script: """ | ||
set +e | ||
echo "Unpacked ${libs} from ${name}" | ||
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum | ||
for i in \$(echo ${libs} | sed -e 's/,/ /g'); do md5sum \$i; done | ||
return 0 | ||
""" | ||
if (include_gcov_data) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,26 @@ scala_prepare() { | |
export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" | ||
} | ||
|
||
check_cython() { | ||
set -ex | ||
local python_ver=$1 | ||
local is_cython_used=$(python${python_ver} <<EOF | ||
import sys | ||
import mxnet as mx | ||
cython_ndarraybase = 'mxnet._cy' + str(sys.version_info.major) + '.ndarray' | ||
print(mx.nd._internal.NDArrayBase.__module__ == cython_ndarraybase) | ||
EOF | ||
) | ||
|
||
if [ "${is_cython_used}" != "True" ]; then | ||
echo "ERROR: cython is not used." | ||
return 1 | ||
else | ||
echo "NOTE: cython is used." | ||
return 0 | ||
fi | ||
} | ||
|
||
build_ccache_wrappers() { | ||
set -ex | ||
|
||
|
@@ -370,6 +390,8 @@ build_ubuntu_cpu_openblas() { | |
USE_LIBJPEG_TURBO=1 \ | ||
USE_SIGNAL_HANDLER=1 \ | ||
-j$(nproc) | ||
make cython PYTHON=python2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ccache doesn't work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
make cython PYTHON=python3 | ||
} | ||
|
||
build_ubuntu_cpu_mkl() { | ||
|
@@ -682,6 +704,9 @@ build_ubuntu_gpu_cuda100_cudnn7() { | |
CUDA_ARCH="$CI_CUDA_COMPUTE_CAPABILITIES" \ | ||
USE_SIGNAL_HANDLER=1 \ | ||
-j$(nproc) | ||
|
||
make cython PYTHON=python2 | ||
make cython PYTHON=python3 | ||
} | ||
|
||
build_ubuntu_amalgamation() { | ||
|
@@ -749,6 +774,7 @@ build_ubuntu_gpu_cmake() { | |
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCUDA_ARCH_NAME=Manual \ | ||
-DCUDA_ARCH_BIN=$CI_CMAKE_CUDA_ARCH_BIN \ | ||
-DBUILD_CYTHON_MODULES=1 \ | ||
-G Ninja \ | ||
/work/mxnet | ||
|
||
|
@@ -816,12 +842,25 @@ sanity_check() { | |
nosetests-3.4 tests/tutorials/test_sanity_tutorials.py | ||
} | ||
|
||
unittest_ubuntu_python2_cpu_cython() { | ||
set -ex | ||
export PYTHONPATH=./python/ | ||
export MXNET_MKLDNN_DEBUG=1 | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=1 | ||
export MXNET_ENFORCE_CYTHON=1 | ||
check_cython 2 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_train.xml --verbose tests/python/train | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
} | ||
|
||
unittest_ubuntu_python2_cpu() { | ||
set -ex | ||
export PYTHONPATH=./python/ | ||
export MXNET_MKLDNN_DEBUG=0 | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_train.xml --verbose tests/python/train | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
|
@@ -832,6 +871,7 @@ unittest_ubuntu_python3_cpu() { | |
export PYTHONPATH=./python/ | ||
export MXNET_MKLDNN_DEBUG=0 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
} | ||
|
@@ -841,6 +881,7 @@ unittest_ubuntu_python3_cpu_mkldnn() { | |
export PYTHONPATH=./python/ | ||
export MXNET_MKLDNN_DEBUG=0 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_mkl.xml --verbose tests/python/mkl | ||
} | ||
|
@@ -860,6 +901,19 @@ unittest_ubuntu_python3_gpu() { | |
export MXNET_MKLDNN_DEBUG=0 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export CUDNN_VERSION=${CUDNN_VERSION:-7.0.3} | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
unittest_ubuntu_python3_gpu_cython() { | ||
set -ex | ||
export PYTHONPATH=./python/ | ||
export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export CUDNN_VERSION=${CUDNN_VERSION:-7.0.3} | ||
export MXNET_ENABLE_CYTHON=1 | ||
export MXNET_ENFORCE_CYTHON=1 | ||
check_cython 3 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
|
@@ -868,6 +922,7 @@ unittest_ubuntu_python3_gpu_nocudnn() { | |
export PYTHONPATH=./python/ | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export CUDNN_OFF_TEST_ONLY=true | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
|
@@ -877,6 +932,7 @@ unittest_ubuntu_tensorrt_gpu() { | |
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export LD_LIBRARY_PATH=/work/mxnet/lib:$LD_LIBRARY_PATH | ||
export CUDNN_VERSION=${CUDNN_VERSION:-7.0.3} | ||
export MXNET_ENABLE_CYTHON=0 | ||
python tests/python/tensorrt/lenet5_train.py | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_trt_gpu.xml --verbose --nocapture tests/python/tensorrt/ | ||
} | ||
|
@@ -889,6 +945,7 @@ unittest_ubuntu_python2_quantization_gpu() { | |
export MXNET_MKLDNN_DEBUG=0 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export CUDNN_VERSION=${CUDNN_VERSION:-7.0.3} | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_quantization_gpu.xml --verbose tests/python/quantization_gpu | ||
} | ||
|
||
|
@@ -900,6 +957,7 @@ unittest_ubuntu_python3_quantization_gpu() { | |
export MXNET_MKLDNN_DEBUG=0 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export CUDNN_VERSION=${CUDNN_VERSION:-7.0.3} | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS $NOSE_TIMER_ARGUMENTS --with-xunit --xunit-file nosetests_quantization_gpu.xml --verbose tests/python/quantization_gpu | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
function(add_cython_modules python_version) | ||
unset(PYTHON_EXECUTABLE CACHE) | ||
set(PYTHONINTERP_FOUND FALSE) | ||
find_package(PythonInterp ${python_version} EXACT) | ||
if(PYTHONINTERP_FOUND) | ||
find_program(CYTHON_EXECUTABLE NAMES cython) | ||
if(CYTHON_EXECUTABLE) | ||
add_custom_command(COMMAND ${CMAKE_COMMAND} POST_BUILD | ||
-E env MXNET_LIBRARY_PATH=${CMAKE_BINARY_DIR}/libmxnet.so | ||
${PYTHON_EXECUTABLE} setup.py build_ext --inplace --with-cython | ||
TARGET mxnet | ||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/python") | ||
message("-- Cython modules for python${python_version} will be built") | ||
set(PYTHON${python_version}_FOUND 1 PARENT_SCOPE) | ||
else() | ||
message(FATAL_ERROR "-- Cython not found") | ||
endif() | ||
else() | ||
set(PYTHON${python_version}_FOUND 0 PARENT_SCOPE) | ||
endif() | ||
endfunction() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,22 @@ When USE_PROFILER is enabled in Makefile or CMake, the following environments ca | |
- If set to '0', profiler records the events of the symbolic operators. | ||
- If set to '1', profiler records the events of all operators. | ||
|
||
## Interface between Python and the C API | ||
|
||
* MXNET_ENABLE_CYTHON | ||
- Values: 0(false), 1(true) ```(default=1)``` | ||
- If set to 0, MXNet uses the ctypes to interface with the C API. | ||
- If set to 1, MXNet tries to use the cython modules for the ndarray and symbol. If it fails, the ctypes is used or an error occurs depending on MXNET_ENFORCE_CYTHON. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool! |
||
|
||
* MXNET_ENFORCE_CYTHON | ||
- Values: 0(false) or 1(true) ```(default=0)``` | ||
- This has an effect only if MXNET_ENABLE_CYTHON is 1. | ||
- If set to 0, MXNet fallbacks to the ctypes if importing the cython modules fails. | ||
- If set to 1, MXNet raises an error if importing the cython modules fails. | ||
|
||
If cython modules are used, `mx.nd._internal.NDArrayBase` must be `mxnet._cy3.ndarray.NDArrayBase` for python 3 or `mxnet._cy2.ndarray.NDArrayBase` for python 2. | ||
If ctypes is used, it must be `mxnet._ctypes.ndarray.NDArrayBase`. | ||
|
||
## Other Environment Variables | ||
|
||
* MXNET_GPU_WORKER_NSTREAMS | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a default value for PYTHON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the default is just
python
. It is defined inmake/config.mk
.