Sklearn/skimage cannot allocate memory in static TLS block

After running a sudo apt-get update/upgrade which updated my python3-dev/distutils etc. I can’t run my program where I import sklearn and skimage.

Traceback (most recent call last):
File “/home/user/.local/lib/python3.9/site-packages/skimage/”, line 151, in
from ._shared import geometry
ImportError: /home/user/.local/lib/python3.9/site-packages/skimage/_shared/…/…/scikit_image.libs/ cannot allocate memory in static TLS block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/user/user/code/”, line 7, in
from vision_worker import VisionWorker
File “/home/user/user/code/”, line 8, in
from services import CameraService, ClassificationService, PointCloudService, ObjectRGBExtractionService, PredictionReviewService
File “/home/user/user/code/services/”, line 6, in
from .classification_service import ClassificationService, Classifier
File “/home/user/user/code/services/”, line 11, in
from .embedded_feature_classifier import EmbeddedFeatureClassifier
File “/home/user/user/code/services/”, line 2, in
from .embedding_classifier import KnownDataset, ImageTransform, EmbeddingExtractor, IndexBuilder, IndexSearcher,
File “/home/user/user/code/services/embedding_classifier/”, line 3, in
from .known_dataset import KnownDataset
File “/home/user/user/code/services/embedding_classifier/”, line 1, in
from skimage import io
File “/home/user/.local/lib/python3.9/site-packages/skimage/”, line 154, in
File “/home/user/.local/lib/python3.9/site-packages/skimage/”, line 131, in _raise_build_error
raise ImportError(“”"%s
ImportError: /home/user/.local/lib/python3.9/site-packages/skimage/_shared/…/…/scikit_image.libs/ cannot allocate memory in static TLS block
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
Installing scikit-image — skimage v0.19.2 docs

I have tried using:

export LD_PRELOAD=‘/home/user/.local/lib/python3.9/site-packages/scikit_image.libs/’

but it does not make a difference.
My last resort will be to try and reorder the whole import order of all my modules, so that whatever is conflicting with Scikit can be imported afterwards.

I have tried running an empty python3 shell and importing sklearn and skimage without issues.


Could you share which JetPack you used with us first?

Hi AastaLLL
I am on Xavier NX16 running Jetpack4.6

I added:

import sklearn
import skimage

to the beginning of my script and it seems to have resolved the issue because scikit is the first thing that gets memory allocated.
I am still not sure how this started to appear after running a standard update/upgrade process.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.