This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-545] Fix broken cython build #10951
Merged
Merged
Changes from 55 commits
Commits
Show all changes
114 commits
Select commit
Hold shift + click to select a range
9d47eed
Fix broken build with cython 0.28
asitstands b3a9784
Fix setup.py to be compatible with cython 0.28
asitstands feecd35
Fix broken cython ndarray module
asitstands fcc41a0
Revised comments
asitstands 771a9b6
Replace hard coded library path with one obtained by find_lib_path
asitstands df1a291
Add documentation for MXNET_ENABLE_CYTHON and MXNET_ENFORCE_CYTHON
asitstands 0000950
Add cython build to CI
asitstands 86d1c90
Fix for cython CI
asitstands f8a7b8c
Adjust python environment for cython CI
asitstands 646ea91
Add make variables to set python executable
asitstands 64057b3
Fix typo
asitstands 5aaa8ad
Fix nnvm include path
asitstands 1f4d53a
Does not use ccache for cython
asitstands d252bea
Fix issues with the wildcards in the library list in Jenkinsfile
asitstands cbae43d
Fix issues with the wildcards in the library list in Jenkinsfile (con…
asitstands be0744a
Fix issues with the wildcards in the library list in Jenkinsfile (con…
asitstands 40ba9de
Intentionally introduce a bug to check that the tests actually runwit…
asitstands b5b0a54
Remove the intentionally introduced bug
asitstands c798d38
Update installation doc
asitstands 206e706
Retrigger CI
asitstands 939e9ce
Merge branch 'master' into fix_cython
asitstands 6df4e28
Run cython CI in ubuntu environment instead of CentOS environment
asitstands 741d088
Commit a missed file
asitstands b32b8a6
Fix a bug in check_cython
asitstands 9a526ec
Refine environments for cython CI
asitstands 17286a4
Restore unrelated changes
asitstands 0d4a2aa
Merge branch 'master' into fix_cython
asitstands 238f40c
Fix a problem occurring when the cython modules for python 2 and 3 ar…
asitstands 7284615
Trigger CI
asitstands 57c3410
Pin the cython version in the CI
asitstands 48039a2
Resolve the confliction with master. Merge branch 'master' into fix_c…
asitstands 96ed71f
Catch up #11320
asitstands 991dd8c
Remove optional arguments unused after #11320
asitstands d779ec9
Trigger CI
asitstands 5922f88
Trigger CI
asitstands 2fbe3fe
Resolve conflict with master
asitstands ed1e126
Trigger CI
asitstands 430f38d
Remove unnecessary stype argument from the NDArrayBase constructor
asitstands e3ad1ca
Revise confusing initialization of `_ndarray_cls`
asitstands 58c2754
Cython CI with CMake
asitstands d0ef6fe
Add cython build for python3 in CI
asitstands 8140a4d
Fix misplaced cython build in CI
asitstands 5093d83
Adjust CI environments for cython
asitstands 868b170
Merge branch 'master' into fix_cython
asitstands bf798c9
Fix invalid path for cython generated .so files in cmake build
asitstands 4bca56c
Revert invalid fix
asitstands e602d88
Revise docs
asitstands 7dd3fa6
Revise check_cython
asitstands d80fc68
Merge branch 'master' into fix_cython
asitstands bc838c8
Temporaily use make instead of cmake for debugging
asitstands 8cb0e62
Temporal changes for debugging
asitstands 94f5427
Temporal changes for debugging
asitstands f6cee03
Temporaily use ctypes instead of cython modules for debugging
asitstands c505bf0
Temporaily disable ccache for debugging
asitstands 17f6c70
Temporaily use make (DEV = 0) instead of cmake for debugging
asitstands 8ccc5f2
Temporaily disable cudnn for debugging
asitstands c6d1e49
Merge branch 'master' into fix_cython
asitstands 786b2fd
Restore temporal changes
asitstands e02cc4f
Temporarily disable coverage report
asitstands fc6f843
Merge branch 'master' into fix_cython
asitstands aa64c42
Adapt to Jenkinsfile_utils
asitstands c90570c
Adapt to Jenkinsfile_utils (cont.)
asitstands a2bb2e1
Restore unrelated changes
asitstands d89de2f
Restore temporal changes
asitstands 2297f34
Merge branch 'master' into fix_cython
asitstands 2cc7e85
Merge master
asitstands 2b8628c
Resolve conflict
asitstands efd5bd2
Merge branch 'master' into fix_cython
asitstands 927ca1a
Resolving conflict
asitstands d02b89b
Test with the cmake build is removed
asitstands df89ef3
Resolving conflicts
asitstands 17a702c
Add MXNET_ENABLE_CYTHON=0 to tensorrt test
asitstands 8375dfe
Resolving conflicts
asitstands d5f6fe6
Fix typo
asitstands c1480f5
Resolve conflicts
asitstands fdf344f
Trigger CI
asitstands 7036d9b
Merge branch 'master' into fix_cython
asitstands e81dba9
Trigger CI
asitstands 92ea420
Merge branch 'master' into fix_cython
asitstands fcf5986
Adapt to Jenkinsfile refactoring
asitstands 064f56f
Adapt to Jenkinsfile refactoring (cont.)
asitstands b30ba00
Trigger CI
asitstands aea2d41
Merge branch 'master' into fix_cython
asitstands 9965e4c
Trigger CI
asitstands 371a8c6
Stash missing cython modules
asitstands 9adca4d
Trigger CI
asitstands 09efb2b
Merge branch 'master' into fix_cython
asitstands 61387bc
Merge branch 'master' into fix_cython
asitstands 10d817c
CMake build of cython modules without unit tests
asitstands adce15e
Fix typo
asitstands d7bdf63
Trigger CI
asitstands 83f5a1e
Merge branch 'master' into fix_cython
asitstands 550ae4a
Fix a mistake introduced in merging process
asitstands 2253b76
trigger test
szha 95f42bd
Update Jenkinsfile_utils.groovy
szha f42fd0a
Trigger CI
asitstands 4ed7657
Merge branch 'fix_cython' of /~https://github.com/asitstands/incubator-…
asitstands e81093a
Trigger CI
asitstands 9c836bc
Trigger CI
asitstands 4be2da6
Resolving conflicts with master
asitstands 0dce3f9
Merge branch 'master' into fix_cython
asitstands ec37d87
Merge branch 'master' into fix_cython
asitstands d5de9c4
Trigger tests
asitstands 11e30ca
Merge branch 'master' into fix_cython
asitstands d8c435c
Trigger tests
asitstands bc526f2
Merge branch 'master' into fix_cython
asitstands 25a3dfd
Merge branch 'master' into fix_cython
asitstands e300834
Trigger tests
asitstands 8dbc12f
Trigger tests
asitstands 10bc51e
Trigger tests
asitstands a6005c7
Trigger tests
asitstands db80ee7
Trigger tests
asitstands a5ad3c0
Merge branch 'master' into fix_cython
asitstands 1443088
Trigger tests
asitstands File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,26 @@ clean_repo() { | |
git submodule update --init --recursive | ||
} | ||
|
||
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 | ||
|
||
|
@@ -64,6 +84,22 @@ build_ccache_wrappers() { | |
export CXX=`pwd`/cxx | ||
} | ||
|
||
build_cython() { | ||
set -ex | ||
pushd . | ||
|
||
PYTHON_DIR=${1:-/work/mxnet/python} | ||
BUILD_DIR=${2:-/work/build} | ||
|
||
export MXNET_LIBRARY_PATH=${BUILD_DIR}/libmxnet.so | ||
|
||
cd ${PYTHON_DIR} | ||
python2 setup.py build_ext --inplace --with-cython | ||
python3 setup.py build_ext --inplace --with-cython | ||
|
||
popd | ||
} | ||
|
||
build_wheel() { | ||
|
||
set -ex | ||
|
@@ -315,6 +351,11 @@ build_ubuntu_cpu_openblas() { | |
USE_BLAS=openblas \ | ||
USE_DIST_KVSTORE=1 \ | ||
-j$(nproc) | ||
|
||
export CC="gcc" | ||
export CXX="g++" | ||
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_cmake_debug() { | ||
|
@@ -496,20 +537,35 @@ build_ubuntu_gpu_cmake_mkldnn() { | |
|
||
build_ubuntu_gpu_cmake() { | ||
set -ex | ||
cd /work/build | ||
cmake \ | ||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
-DUSE_CUDA=1 \ | ||
-DUSE_CUDNN=1 \ | ||
-DUSE_MKLML_MKL=0 \ | ||
-DUSE_MKLDNN=0 \ | ||
-DUSE_DIST_KVSTORE=1 \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-G Ninja \ | ||
/work/mxnet | ||
|
||
ninja -v | ||
# cd /work/build | ||
# cmake \ | ||
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | ||
# -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | ||
# -DUSE_CUDA=1 \ | ||
# -DUSE_CUDNN=1 \ | ||
# -DUSE_MKLML_MKL=0 \ | ||
# -DUSE_MKLDNN=0 \ | ||
# -DUSE_DIST_KVSTORE=1 \ | ||
# -DCMAKE_BUILD_TYPE=Release \ | ||
# -G Ninja \ | ||
# /work/mxnet | ||
|
||
# ninja -v | ||
# build_cython | ||
|
||
# TMP for debugging | ||
make \ | ||
DEV=1 \ | ||
USE_CUDA=1 \ | ||
USE_CUDNN=1 \ | ||
USE_CUDA_PATH=/usr/local/cuda \ | ||
USE_MKLML_MKL=0 \ | ||
USE_MKLDNN=0 \ | ||
USE_DIST_KVSTORE=1 \ | ||
-j$(nproc) | ||
|
||
make cython PYTHON=python2 | ||
make cython PYTHON=python3 | ||
} | ||
|
||
|
||
|
@@ -531,6 +587,22 @@ unittest_ubuntu_python2_cpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_train.xml --verbose tests/python/train | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
} | ||
|
||
unittest_ubuntu_python2_cpu_cython() { | ||
set -ex | ||
export PYTHONPATH=./python/ | ||
# MXNET_MKLDNN_DEBUG is buggy and produces false positives | ||
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
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 --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_train.xml --verbose tests/python/train | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
|
@@ -543,6 +615,7 @@ unittest_ubuntu_python3_cpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization.xml --verbose tests/python/quantization | ||
} | ||
|
@@ -554,6 +627,7 @@ unittest_ubuntu_python3_cpu_mkldnn() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_unittest.xml --verbose tests/python/unittest | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_mkl.xml --verbose tests/python/mkl | ||
} | ||
|
@@ -565,6 +639,7 @@ unittest_ubuntu_python2_gpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
|
@@ -574,6 +649,7 @@ tutorialtest_ubuntu_python3_gpu() { | |
export MXNET_DOCS_BUILD_MXNET=0 | ||
make html | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
export PYTHONPATH=/work/mxnet/python/ | ||
export MXNET_TUTORIAL_TEST_KERNEL=python3 | ||
cd /work/mxnet/tests/tutorials | ||
|
@@ -586,6 +662,7 @@ tutorialtest_ubuntu_python2_gpu() { | |
export MXNET_DOCS_BUILD_MXNET=0 | ||
make html | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
export PYTHONPATH=/work/mxnet/python/ | ||
export MXNET_TUTORIAL_TEST_KERNEL=python2 | ||
cd /work/mxnet/tests/tutorials | ||
|
@@ -599,6 +676,20 @@ unittest_ubuntu_python3_gpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
unittest_ubuntu_python3_gpu_cython() { | ||
set -ex | ||
export PYTHONPATH=./python/ | ||
# MXNET_MKLDNN_DEBUG is buggy and produces false positives | ||
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=1 | ||
export MXNET_ENFORCE_CYTHON=1 | ||
check_cython 3 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
|
@@ -607,6 +698,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 --with-xunit --xunit-file nosetests_gpu.xml --verbose tests/python/gpu | ||
} | ||
|
||
|
@@ -619,6 +711,7 @@ unittest_ubuntu_python2_quantization_gpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-2.7 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization_gpu.xml --verbose tests/python/quantization_gpu | ||
} | ||
|
||
|
@@ -631,6 +724,7 @@ unittest_ubuntu_python3_quantization_gpu() { | |
# /~https://github.com/apache/incubator-mxnet/issues/10026 | ||
#export MXNET_MKLDNN_DEBUG=1 # Ignored if not present | ||
export MXNET_STORAGE_FALLBACK_LOG_VERBOSE=0 | ||
export MXNET_ENABLE_CYTHON=0 | ||
nosetests-3.4 $NOSE_COVERAGE_ARGUMENTS --with-xunit --xunit-file nosetests_quantization_gpu.xml --verbose tests/python/quantization_gpu | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,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_CUDNN_AUTOTUNE_DEFAULT | ||
|
@@ -146,7 +162,7 @@ When USE_PROFILER is enabled in Makefile or CMake, the following environments ca | |
- Performance tests are run to pick the convolution algo when value is 1 or 2 | ||
- Value of 1 chooses the best algo in a limited workspace | ||
- Value of 2 chooses the fastest algo whose memory requirements may be larger than the default workspace threshold | ||
|
||
|
||
* MXNET_GLUON_REPO | ||
- Values: String ```(default='https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/'``` | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.