-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Cross endianness and bitness pickle issues with KNeighborsClassifier / KDTree #21553
Copy link
Copy link
Open
Labels
Description
Reported in #21237 (cross endianness). There is a similar issue for the cross bitness, to reproduce:
Generate a pickle on a 64bit machine:
from sklearn.datasets import make_classification
X, y = make_classification(random_state=0)
from sklearn.neighbors import KNeighborsClassifier
clf = KNeighborsClassifier(algorithm='kd_tree')
clf.fit(X, y)
import pickle
pickle.dump(clf, open('/tmp/kneighbors.pkl', 'wb'))Open it on a 32bit machine:
docker run -it -v /tmp:/io lesteve/i386-scikit-learn python3 -c 'import pickle; pickle.load(open("/io/kneighbors.pkl", "rb"))'
Output:
WARNING: The requested image's platform (linux/386) does not match the detected host platform (linux/amd64) and no specific platform was requested
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "sklearn/neighbors/_binary_tree.pxi", line 1062, in sklearn.neighbors._kd_tree.BinaryTree.__setstate__
self._update_memviews()
File "sklearn/neighbors/_binary_tree.pxi", line 1004, in sklearn.neighbors._kd_tree.BinaryTree._update_memviews
self.idx_array = self.idx_array_arr
ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long long'
Quite likely solving the issue is rather similar to #21552 and #21539.
Reactions are currently unavailable