Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytorch : W ParallelNative.cpp:206

I'm trying to use a pre-trained template on my image set by following the tutorial right here : https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html

Only I always get this "error" when I run my code and the console locks up :

[W ParallelNative.cpp:206] Warning: Cannot set number of intraop threads after parallel work has started or after set_num_threads call when using native parallel backend (function set_num_threads)

Thank you in advance for your help,

like image 202
Marcel Avatar asked Nov 10 '20 15:11

Marcel


People also ask

Can PyTorch run in C++?

TorchScript C++ API TorchScript allows PyTorch models defined in Python to be serialized and then loaded and run in C++ capturing the model code via compilation or tracing its execution. You can learn more in the Loading a TorchScript Model in C++ tutorial.

What is the PyTorch C++ frontend?

The PyTorch C++ frontend provides a high level, pure C++ modeling interface for neural network and general ML(Machine Learning) research and production use cases, largely following the Python API in design and provided functionality. The C++ frontend includes the following:

Why does PyTorch take so long to load?

From this article, it appears that Pytorch has an error in 1.7 related to parallel processing. (Potentially) as a result of it CPU load is very low (no parallel computing?) and training is slow too.

What is the best entry point to the PyTorch C++ ecosystem?

Unless you have a particular reason to constrain yourself exclusively to ATen or the Autograd API, the C++ frontend is the recommended entry point to the PyTorch C++ ecosystem. While it is still in beta as we collect user feedback (from you!), it provides both more functionality and better stability guarantees than the ATen and Autograd APIs.


1 Answers

I have the same problem. Mac. Python 3.6 (also reproduces on 3.8). Pytorch 1.7.

It seems that with this error dataloaders don't (or can't) use parallel computing. You can remove the error (this will not fix the problem) in two ways.

  1. If you can access your dataloaders, set num_workers=0 when creating a dataloader
  2. Set environment variable export OMP_NUM_THREADS=1

Again, both solutions kill parallel computing and may slow down data loading (and therefore training). I look forward to efficient solutions or a patch in Pytorch 1.7

like image 129
Dim Avatar answered Sep 21 '22 11:09

Dim