BufferError: memoryview has 1 exported buffer

Hi. I’m doing parameters tuning of XGBoost classifier for a multilabel problem:

cv_inner = StratifiedShuffleSplit(n_splits=5, test_size=0.3, random_state=109)
clf = RandomizedSearchCV(cl, dist, scoring='r2', cv=cv_inner, refit=True, n_jobs=-1)
search = clf.fit(Xtrain, ytrain)
cv_outer = StratifiedShuffleSplit(n_splits=3, test_size=0.3, random_state=109)
scores = cross_val_score(search, Xtrain, ytrain, scoring='accuracy', cv=cv_outer)

Could someone explain me why I get this error (BufferError: memoryview has 1 exported buffer) and how to fix it?

This question seems to be unrelated to PyTorch, so I would recommend to cross-post it into an XGBoost-specific discussion board or their GitHub repository in case you think it’s a bug in their library.

Actually, I tried also with other classifiers such as SVM and RF and the same error happens. In an other pc the code works so it is my pc problem. Do you have any idea of what is the cause?

I don’t know what might be causing the issue and cannot find a lot of references.
My first idea would be to create a new and clean virtual environment and reinstall the used packages there so check if somehow the environment is broken.

Ok. I’ll try it. Thank you for the help!

I created a new virtual environment but the error still persists. Please, if you have other ideas, let me know!

Try to narrow down the issue by checking the stacktrace via gdb which should give you more information about the root cause.

@John4 I’ve been getting the same error in generic multprocessing.Pool code. This discussion https://youtrack.jetbrains.com/issue/PY-54447/BufferError-memoryview-has-1-exported-buffer suggests that the issue is related to Python 3.10 and PyCharm interaction (my experience too). Switching back to Python 3.9 I had no issues. What you are seeing may be unrelated to PyTorch at all. Hope it helps.