KupynOrest / DeblurGAN

Image Deblurring using Generative Adversarial Networks
Other
2.52k stars 522 forks source link

macOS thread error and timeout using CPU—Warning: Cannot set number of intraop threads after parallel work has started #216

Open KeygenLLC opened 3 years ago

KeygenLLC commented 3 years ago

Testing out DeblurGAN on macOS Big Sur using anaconda and python 3.7.

I got the error using the basic test command or a command with more flags with flag set for CPU:

## either command will timeout
python test.py --dataroot blur_test --model test --dataset_mode single --gpu_ids -1

python test.py --dataroot blur_test --model test --dataset_mode single --gpu_ids -1 --resize_or_crop scale_width --loadSizeX 720 --loadSizeY 960 --fineSize 720

I tried setting --nThreads 1 but got the same error. However, I was able to bypass this by adding an environment variable to the command:

### both of these commands work
OMP_NUM_THREADS=1 python test.py --dataroot blur_test --model test --dataset_mode single --gpu_ids -1

OMP_NUM_THREADS=1 python test.py --dataroot blur_test --model test --dataset_mode single --gpu_ids -1 --resize_or_crop scale_width --loadSizeX 720 --loadSizeY 960 --fineSize 720

Any way to avoid this error?

Here is the full error and traceback:

model [TestModel] was created
[2021-11-11 15:22:47,942] WARNING: Setting up a new session...
[2021-11-11 15:22:47,961] INFO: Visdom successfully connected to server
[W ParallelNative.cpp:214] 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)
[2021-11-11 15:22:48,107] DEBUG: STREAM b'IHDR' 16 13
[2021-11-11 15:22:48,108] DEBUG: STREAM b'pHYs' 41 9
[2021-11-11 15:22:48,109] DEBUG: STREAM b'IDAT' 62 380148
^CTraceback (most recent call last):
  File "test.py", line 31, in <module>
    for i, data in enumerate(dataset):
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
    data = self._next_data()
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1186, in _next_data
    idx, data = self._get_data()
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1152, in _get_data
    success, data = self._try_get_data()
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 990, in _try_get_data
    data = self._data_queue.get(timeout=timeout)
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/multiprocessing/queues.py", line 104, in get
    if not self._poll(timeout):
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/multiprocessing/connection.py", line 257, in poll
    return self._poll(timeout)
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/multiprocessing/connection.py", line 414, in _poll
    r = wait([self], timeout)
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/multiprocessing/connection.py", line 921, in wait
    ready = selector.select(timeout)
  File "/opt/anaconda3/envs/DEBLURGAN/lib/python3.7/selectors.py", line 415, in select
    fd_event_list = self._selector.poll(timeout)
KeyboardInterrupt