Skip to content

[WIP]: Add 32bit testing in CI for scikit-learn - #11515

Closed
jrmlhermitte wants to merge 9 commits into
scikit-learn:masterfrom
jrmlhermitte:docker-32bit
Closed

jrmlhermitte wants to merge 9 commits into
scikit-learn:masterfrom
jrmlhermitte:docker-32bit

Conversation

@jrmlhermitte

@jrmlhermitte jrmlhermitte commented Jul 14, 2018 •

Copy link
Copy Markdown

WIP: Not complete yet. Tested locally. 3 tests fail (and 10 docstring tests fail, which I disabled). Now trying to run on Travis.

Reference Issues/PRs

Attempt to close #9352

What does this implement/fix? Explain your changes.

Any other comments?

@jrmlhermitte

Copy link
Copy Markdown
Author

Current failed tests:
10 DocTestFailures:

737     >>> from sklearn.cluster import AgglomerativeClustering
738     >>> import numpy as np
739     >>> X = np.array([[1, 2], [1, 4], [1, 0],
740     ...               [4, 2], [4, 4], [4, 0]])
741     >>> clustering = AgglomerativeClustering().fit(X)
742     >>> clustering # doctest: +NORMALIZE_WHITESPACE
743     AgglomerativeClustering(affinity='euclidean', compute_full_tree='auto',
744                 connectivity=None, linkage='ward', memory=None, n_clusters=2,
745                 pooling_func='deprecated')
746     >>> clustering.labels_
Expected:
    array([1, 1, 1, 0, 0, 0])
Got:
    array([1, 1, 1, 0, 0, 0], dtype=int32)

/io/sklearn/cluster/hierarchical.py:746: DocTestFailure

3 AssertionErrors , example:

sklearn/utils/estimator_checks.py:1492: AssertionError
_____________________________ test_non_meta_estimators[OneClassSVM-OneClassSVM-check_outliers_train(readonly_memmap=True)] _____________________________
...
>       assert_array_equal(y_dec, decision)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 87.33333333333333%)
E        x: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...
E        y: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...


Comment thread build_tools/travis/install.sh Outdated
elif [[ "$DISTRIB" == "32bit" ]]; then
# At the time of writing numpy 1.9.1 is included in the travis
# virtualenv but we want to use the numpy installed through apt-get
docker run --rm -v`pwd`:/io quay.io/pypa/manylinux1_i686 /bin/bash -c "set -e; export PATH=/opt/python/cp36-cp36m/bin:$PATH; pip install numpy scipy cython nose pytest; cd /io; pip install -e l; pytest -l sklearn"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a script with the commands under build_tools/travis/install_docker_32bit.sh ?

Comment thread .travis.yml Resolved
Comment thread .travis.yml Resolved
@amueller

Copy link
Copy Markdown
Member

doctests are explicitly skipped on 32bit in the makefile because we didn't felt it was worth fixing them.

@jrmlhermitte

Copy link
Copy Markdown
Author

I agree on CircleCI and will get this started later. For now, three tests don't pass. I'll start with the first, any ideas on this one?

        assert_array_almost_equal(dense_svm.dual_coef_,
>                                 sparse_svm.dual_coef_.toarray())
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       (mismatch 83.33333333333333%)
E        x: array([[0.993464, 0.258659, 0.264268, 0.212662, 0.270947, 1.      ]])
E        y: array([[0.993326, 0.263301, 0.259931, 0.216799, 0.266643, 1.      ]])

sklearn/svm/tests/test_sparse.py:53: AssertionError

When I debug, the main difference I see is that the dataset in the 32bit version is a np.
In debugger:

(Pdb) p datasets
[[<6x2 sparse matrix of type '<class 'numpy.int32'>'
        with 12 stored elements in LInked List format>, None, array([[-1, -1],
       [ 2,  2],
       [ 3,  2]])], [<5x3 sparse matrix of type '<class 'numpy.int32'>'
        with 8 stored elements in Dictionary Of Keys format>, None, array([[-1, -1, -1],
       [ 1,  1,  1],
       [ 2,  2,  2]])], [<80x2 sparse matrix of type '<class 'numpy.float64'>'
        with 160 stored elements in Compressed Sparse Row format>, None, <20x2 sparse matrix of type '<class 'numpy.float64'>'
        with 40 stored elements in Compressed Sparse Row format>], [<150x4 sparse matrix of type '<class 'numpy.float64'>'
        with 600 stored elements in Compressed Sparse Row format>, None, <150x4 sparse matrix of type '<class 'numpy.float64'>'
        with 600 stored elements in Compressed Sparse Row format>]]
(Pdb) p dataset
[<6x2 sparse matrix of type '<class 'numpy.int32'>'
        with 12 stored elements in LInked List format>, None, array([[-1, -1],
       [ 2,  2],
       [ 3,  2]])]

I tested and raised an Exception purposely to see the datasets on a 64bit machine:

> /home/lhermitte/research/projects/scikit-learn/sklearn/svm/tests/test_sparse.py(278)test_sparse_oneclasssvm()
-> raise
(Pdb) p datasets
[[<6x2 sparse matrix of type '<class 'numpy.int64'>'
        with 12 stored elements in LInked List format>, None, array([[-1, -1],
       [ 2,  2],
       [ 3,  2]])], [<5x3 sparse matrix of type '<class 'numpy.int64'>'
        with 8 stored elements in Dictionary Of Keys format>, None, array([[-1, -1, -1],
       [ 1,  1,  1],
       [ 2,  2,  2]])], [<80x2 sparse matrix of type '<class 'numpy.float64'>'
        with 160 stored elements in Compressed Sparse Row format>, None, <20x2 sparse matrix of type '<class 'numpy.float64'>'
        with 40 stored elements in Compressed Sparse Row format>], [<150x4 sparse matrix of type '<class 'numpy.float64'>'
        with 600 stored elements in Compressed Sparse Row format>, None, <150x4 sparse matrix of type '<class 'numpy.float64'>'
        with 600 stored elements in Compressed Sparse Row format>]]

Any ideas on this? I'll dig but if someone with knowledge of this function has a good idea it would help, thanks!

@amueller

Copy link
Copy Markdown
Member

changing tol might also help, but not sure.

Comment thread sklearn/svm/tests/test_sparse.py Outdated
# test sample 1
X = np.array([[-2, -1], [-1, -1], [-1, -2], [1, 1], [1, 2], [2, 1]])
X_sp = sparse.lil_matrix(X)
X_sp = sparse.lil_matrix(X, dtype=np.int64)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought this would fix it but did not. Will wait for travis to run so that we may all see the errors.

@jrmlhermitte

jrmlhermitte commented Jul 14, 2018 •

Copy link
Copy Markdown
Author

The Travis tests take forever to pass so I'm looking into this first error.
This is the isolated test that fails here

The difference is here:

32 bit:

ipdb> p dense_svm.dual_coef_
array([[0.99346436, 0.25865861, 0.26426828, 0.2126619 , 0.27094685,
        1.        ]])
ipdb> p sparse_svm.dual_coef_.toarray()
array([[0.9933257 , 0.26330099, 0.25993133, 0.21679869, 0.26664329,
        1.        ]])

64 bit:

ipdb> p dense_svm.dual_coef_
array([[0.9933257 , 0.26330099, 0.25993133, 0.21679869, 0.26664329,
        1.        ]])
ipdb> sparse_svm.dual_coef_.toarray()
array([[0.9933257 , 0.26330099, 0.25993133, 0.21679869, 0.26664329,
        1.        ]])

EDIT: updated the 64 bit test output which was incorrect.

@jrmlhermitte

Copy link
Copy Markdown
Author

update: the tests were not the same. The test faisl on the 'poly' kernel. For 64 bit:

ipdb> p dense_svm.dual_coef_
array([[0.9933257 , 0.26330099, 0.25993133, 0.21679869, 0.26664329,
        1.        ]])
ipdb> sparse_svm.dual_coef_.toarray()
array([[0.9933257 , 0.26330099, 0.25993133, 0.21679869, 0.26664329,
        1.        ]])

@jrmlhermitte
jrmlhermitte force-pushed the docker-32bit branch 5 times, most recently from a04156b to 34136f6 Compare July 15, 2018 06:31
@jrmlhermitte

jrmlhermitte commented Jul 15, 2018 •

Copy link
Copy Markdown
Author

It works but there is one problem with the building. We can't use the compiler cache.
How travis caches C code is roughly here.

From quickly reading the code, it appears to me that /usr/lib/ccache offers a cache aware version of gcc and g++. However, since these are compilers from a 64 bit machine, we can't use them.

I don't know too much about this, does anyone else possibly have a clever idea around this?

If we can't fix this, then testing on 32 bit will take much longer (currently seems like it's twice as long)

@jrmlhermitte jrmlhermitte changed the title WIP: Add 32bit testing in travis for scikit-learn [WIP]: Add 32bit testing in travis for scikit-learn Jul 15, 2018
@jrmlhermitte

Copy link
Copy Markdown
Author

Here is a summary of the failing functions below.

After discussion with @rth we can either:

  • fix the issue (if there is one, for ex: maybe force 64 bit dtypes in numpy on the 32 bit machine)
  • reduce the tolerance (some of these have near 5% error though)
  • add the @skip_if_32bit decorator to skip the function

test_sparse_oneclasssvm()
sklearn/svm/tests/test_sparse.py:282:

        assert_array_almost_equal(dense_svm.dual_coef_,
>                                 sparse_svm.dual_coef_.toarray())
E       AssertionError: 
E       Arrays are not almost equal to 6 decimals
E       
E       (mismatch 83.33333333333333%)
E        x: array([[0.993464, 0.258659, 0.264268, 0.212662, 0.270947, 1.      ]])
E        y: array([[0.993326, 0.263301, 0.259931, 0.216799, 0.266643, 1.      ]])

test_non_meta_estimators[OneClassSVM-OneClassSVM-check_outliers_train]
sklearn/tests/test_common.py:99:

>       assert_array_equal(y_dec, decision)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 87.33333333333333%)
E        x: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...
E        y: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...

sklearn/utils/estimator_checks.py:1498: AssertionError

>       assert_array_equal(y_dec, decision)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 87.33333333333333%)
E        x: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...
E        y: array([ 1.391007e-02, -4.891122e-02, -3.351924e-04,  6.477238e-02,
E               3.719500e-01,  3.490890e-01,  6.006356e-01, -5.366954e-01,
E              -3.715464e+00,  1.978421e-01, -1.798778e-04, -5.190478e+00,...

@rth

rth commented Jul 15, 2018

Copy link
Copy Markdown
Member

Thanks for this analysis @jrmlhermitte , it is very much appreciated!

Maybe @ogrisel or @lesteve would have some suggestions?

@jrmlhermitte

Copy link
Copy Markdown
Author

Looked at the first of the three errors with @ogrisel . After some investigation, we found that the problem seems to lie in the non-sparse libsvm code. This is not using BLAS.
We played with max_iter. Once max_iter=4, the values diverge more than 6 decimals.

An option suggested by @ogrisel is to raise an Exception if the user is running this code in 32 bit mode and raise another issue.

Comment thread sklearn/svm/classes.py Resolved
Comment thread sklearn/svm/tests/test_sparse.py Resolved
@rth

rth commented Jan 3, 2019

Copy link
Copy Markdown
Member

@jrmlhermitte Thanks for your work on this. Do you plan to continue this PR?

FYI I merged master in, so you would need to run a git pull to sync your local branch.

@jrmlhermitte

Copy link
Copy Markdown
Author

A little busy today but could look at it near end of week. If someone wants to take over feel free as well :).
But happy to try to get this in.

@jrmlhermitte

Copy link
Copy Markdown
Author

Sorry for my delay. Going to let it run to see if we have more failures. I'll try to check back on it later.

@jrmlhermitte

jrmlhermitte commented Mar 2, 2019 •

Copy link
Copy Markdown
Author
git clone https://www.github.com/jrmlhermitte/scikit-learn
cd scikit-learn
git checkout docker-32bit
# run docker container in interactive mode:
docker run --rm  -it -v`pwd`:/io quay.io/pypa/manylinux1_i686 /bin/bash
export PATH=/opt/python/cp36-cp36m/bin:$PATH
pip install numpy scipy cython pytest; cd /io;python setup.py develop;sed -i '/--doctest-modules/d' setup.cfg;pytest -l sklearn

Still a failure, not sure what is going on (will check later):

Python 2.7.15
numpy 1.16.0
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named scipy

Note: I have changed the NotImplementedError to a RuntimeWarning. The reason for this is that it seems that test_common.py tests walk through all classifiers and run basic tests on them. I didn't know how else to ensure this didn't fail in a simple way.

@adrinjalali

Copy link
Copy Markdown
Member

Since we're moving away from travis (we've already disabled all non-cron-jobs from our CI), I guess it makes sense to maintain new CI tests envs for Azure only, doesn't it?

@jrmlhermitte

Copy link
Copy Markdown
Author

yes, that would be nice. Travis is very out of date.
Azure looks great. I can try to give it a try when I have some free time today.
If I don't get to it, I'll let you know (and maybe someone else can take over if they have the time)

@jrmlhermitte

jrmlhermitte commented Mar 3, 2019 •

Copy link
Copy Markdown
Author

Azure works. tests moved along. going to try finishing this up later today, and remove Travis. Please let me know if anyone disagrees.
The previous image I was using was 64-bit. I have tried two other docker images and there seem to be failures in starting them.

Best option may be to try i386/ubuntu:18.04 and install everything from scratch.

Will need to investigate another week unless someone else wants to take a crack at it.

Update:
No matter what container I run I get something like:

##[command]/usr/bin/docker exec  875f2df41fcd9e3c13fecb78b3ba51ee020c93c3f9b6532331dc295524a875e8 sh -c "command -v bash"
Error response from daemon: Container 875f2df41fcd9e3c13fecb78b3ba51ee020c93c3f9b6532331dc295524a875e8 is not running

I'm not sure what is causing this.

Julien Lhermitte added 3 commits March 3, 2019 22:59
@jrmlhermitte

Copy link
Copy Markdown
Author

Tried a very simple test just now. Tried these two docker images:

  • container: 32bit/ubuntu:16.04
  • container: amd64/ubuntu

First one fails, but second one passes just fine.

The first one fails during the "Initialize Containers" step:

##[command]/usr/bin/docker start 559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506
559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506
##[command]/usr/bin/docker ps --all --filter id=559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506 --filter status=running --no-trunc --format "{{.ID}} {{.Status}}"
559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506 Up Less than a second
##[command]/usr/bin/docker exec  559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506 sh -c "command -v bash"
Error response from daemon: Container 559a48557b0b30951a126ec9980c6f929ea09acbb5aca1e7de0071c9f3cc0506 is not running
##[error]Docker exec fail with exit code 1
##[section]Finishing: Initialize containers

I suspect the 32 bit image is incompatible with something azure needs to get working with the docker image. Maybe the version of node they install? It's all a bit opaque to me.

Anyone know someone knowledgeable in azure?

@rth

rth commented Apr 1, 2019

Copy link
Copy Markdown
Member

How about the 32bit Debian image? Do you get the same error? (it should work mostly without changing the setup otherwise)

@jrmlhermitte

Copy link
Copy Markdown
Author

Yeah same thing with the quay.io image :-(

@rth rth changed the title [WIP]: Add 32bit testing in travis for scikit-learn [WIP]: Add 32bit testing in CI for scikit-learn Apr 1, 2019
@rth

rth commented Apr 1, 2019

Copy link
Copy Markdown
Member

I suspect the 32 bit image is incompatible with something azure needs to get working with the docker image. Maybe the version of node they install? It's all a bit opaque to me.

Maybe @mickeygousset would have some suggestions.

@thomasjpfan

Copy link
Copy Markdown
Member

@jrmlhermitte

jrmlhermitte commented Apr 13, 2019 •

Copy link
Copy Markdown
Author

Thanks, I think I tried that as well with a few other things (I found it at some point but couldn't find that link again). It doesn't work.

Here it is to keep it documented. Tried this just now:

FROM i386/ubuntu
RUN apt-get update
RUN apt-get -y install nodejs npm

uploaded to:

jrmlhermitte/test_docker_32:v2

got:

docker.io/jrmlhermitte/test_docker_32:v2
##[command]/usr/bin/docker inspect --format="{{index .Config.Labels \"com.azure.dev.pipelines.agent.handler.node.path\"}}" jrmlhermitte/test_docker_32:v2
##[command]/usr/bin/docker create --name e3712c26caa542f4adc08d5fa9bfeb4e_jrmlhermittetest_docker_32v2_377f8b --label 3744aa --network vsts_network_8fd1c0f2fc1d48efb5194fcc77ae650f  -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/vsts/work/1":"/__w/1" -v "/home/vsts/work/_temp":"/__w/_temp" -v "/opt/hostedtoolcache":"/__t" -v "/home/vsts/work/_tasks":"/__w/_tasks" -v "/home/vsts/agents/2.149.2/externals":"/__a/externals":ro -v "/home/vsts/work/.taskkey":"/__w/.taskkey" jrmlhermitte/test_docker_32:v2 "/__a/externals/node/bin/node" -e "setInterval(function(){}, 24 * 60 * 60 * 1000);"
38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9
##[command]/usr/bin/docker start 38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9
38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9
##[command]/usr/bin/docker ps --all --filter id=38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9 --filter status=running --no-trunc --format "{{.ID}} {{.Status}}"
38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9 Up Less than a second
##[command]/usr/bin/docker exec  38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9 sh -c "command -v bash"
Error response from daemon: Container 38cc32e90768b9fabcdefa704277b510a4227e83e98ac72006967ba43c98add9 is not running
##[error]Docker exec fail with exit code 1
##[section]Finishing: Initialize containers

I wish azure were more descriptive of their errors :(

@jrmlhermitte

Copy link
Copy Markdown
Author

Oh and in the docker image, I see:

root@225a99143096:/# nodejs --version
v8.10.0

@jrmlhermitte

Copy link
Copy Markdown
Author

I'm closing this because it has grown quite stale, and azure doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add travis configuration to run the tests on 32 bit linux

6 participants