Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytorch Exception in Thread: ValueError: signal number 32 out of range

Tags:

python

pytorch

I'm getting this error:

Exception in Thread: ValueError: signal number 32 out of range

The specific tutorial that raises an issue for me is the training a classifier (https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html), the specific line is:

dataiter = iter(trainloader) 

and the full error traceback is:

Exception in thread Thread-5:
Traceback (most recent call last):
File "/home/chenchen/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/chenchen/anaconda3/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/chenchen/anaconda3/lib/python3.6/multiprocessing/resource_sharer.py", line 139, in _serve
signal.pthread_sigmask(signal.SIG_BLOCK, range(1, signal.NSIG))
File "/home/chenchen/anaconda3/lib/python3.6/signal.py", line 60, in pthread_sigmask
sigs_set = _signal.pthread_sigmask(how, mask)
ValueError: signal number 32 out of range

My operation system is Ubuntu 18.10 and my python env is Anaconda3 for python 3.6. I installed pytorch from the latest source. My cuda version is 10.0.

like image 461
Wu Qili Avatar asked Nov 14 '18 13:11

Wu Qili


3 Answers

I have faced a similar issue and it got resolved when I set:

num_workers=0
like image 161
sumesh Avatar answered Nov 14 '22 23:11

sumesh


Looks like this was a bug in Python (https://bugs.python.org/issue33329).

For Python 3.6, it got fixed in 3.6.6, released around July 2019 (see the release notes mentioning it). (You can check which version you have by running python3 --version.)

For Python 3.5, you'd want at least 3.5.7 (... release notes).

Meanwhile... I haven't tried this personally, but Ubuntu 18.10 seems to have Python 3.6.7 available, so a simple sudo apt install python3.6 might solve this?

like image 35
Latanius Avatar answered Nov 14 '22 21:11

Latanius


I updated the python version from 3.5 to 3.6.1 by using pip install python==3.6.1 and that resolved the problem.

like image 44
VK-imt Avatar answered Nov 14 '22 21:11

VK-imt