Import SVM Classifier trained with sklearn on Jetson TX1

I have done the following:

  1. Trained a one class classifier in Python using sklearn (svm.OneClassClassifier())
  2. Dumped the model using joblib dump into a .joblib file

Then I deployed the .joblib file on the Jetson TX1.

Now I am trying to import it using load from joblib

joblib and sklearn are installed on the JetsonTX1
joblib - pip3 install joblib
sklearn - sudo apt install python3-sklearn

But I get the following error when I try to load the model for inference on the Jetson TX1

Traceback (most recent call last):
File “roi.py”, line 19, in
clf = load(“oneclass_hog.joblib”)
File “/home/nvidia/.local/lib/python3.5/site-packages/joblib/numpy_pickle.py”, line 598, in load
obj = _unpickle(fobj, filename, mmap_mode)
File “/home/nvidia/.local/lib/python3.5/site-packages/joblib/numpy_pickle.py”, line 526, in _unpickle
obj = unpickler.load()
File “/usr/lib/python3.5/pickle.py”, line 1039, in load
dispatchkey[0]
File “/usr/lib/python3.5/pickle.py”, line 1334, in load_global
klass = self.find_class(module, name)
File “/usr/lib/python3.5/pickle.py”, line 1384, in find_class
import(module, level=0)
File “/usr/lib/python3/dist-packages/sklearn/svm/init.py”, line 13, in
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC,
File “/usr/lib/python3/dist-packages/sklearn/svm/classes.py”, line 4, in
from .base import _fit_liblinear, BaseSVC, BaseLibSVM
File “/usr/lib/python3/dist-packages/sklearn/svm/base.py”, line 12, in
from …multiclass import _ovr_decision_function
File “/usr/lib/python3/dist-packages/sklearn/multiclass.py”, line 44, in
from .metrics.pairwise import euclidean_distances
File “/usr/lib/python3/dist-packages/sklearn/metrics/init.py”, line 33, in
from . import cluster
File “/usr/lib/python3/dist-packages/sklearn/metrics/cluster/init.py”, line 19, in
from .unsupervised import silhouette_samples
File “/usr/lib/python3/dist-packages/sklearn/metrics/cluster/unsupervised.py”, line 10, in
from …pairwise import pairwise_distances
File “/usr/lib/python3/dist-packages/sklearn/metrics/pairwise.py”, line 27, in
from …externals.joblib import parallel
ImportError: cannot import name ‘parallel’

Any ideas? Any suggestions to try an alternative way to transfer and use the classifier on Jetson TX1 are also welcome!
Note: The code which is failing (roi.py) is working absolutely fine on my personal computer, its failing only on the Jetson.

Hi,

The error indicates a missing library:

ImportError: cannot import name 'parallel'

Could you try this command:

sudo pip install <b>-U</b> scikit-learn

Thanks.

Hi,

Thanks a lot for your response.

Installation of scikit-learn is not working on the Jetson TX1 using pip.

This is the error message I get when I try to install it with the command you posted.
Can’t rollback scipy, nothing uninstalled.
Command “/usr/bin/python -u -c “import setuptools, tokenize;file=’/tmp/pip-build-XoU7LO/scipy/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-Od9q1Q-record/install-record.txt --single-version-externally-managed --compile” failed with error code 1 in /tmp/pip-build-XoU7LO/scipy/

Cheers,
Ritvik

Hi,

I was able to get it working, used the following commands:

sudo pip3 install --upgrade setuptools
sudo pip3 install -U setuptools
sudo apt-get install libpcap-dev libpq-dev
sudo pip3 install cython
sudo pip3 install git+https://github.com/scikit-learn/scikit-learn.git

Found them on the following post related to Jetson Xavier but it worked on the TX1 too.

https://devtalk.nvidia.com/default/topic/1044958/jetson-agx-xavier/scikit-learn-for-python-3-on-jetson-xavier/

Cheers,
Ritvik

Good to know this : )