danielgatis / rembg

Rembg is a tool to remove images background
MIT License
16.48k stars 1.84k forks source link

[BUG] Specify the number of threads explicitly so the affinity is not set. #448

Closed NourJemmali closed 1 year ago

NourJemmali commented 1 year ago

Hi I got this error when I tried to remove the background : 2023-05-18 08:24:58.694297027 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 531, index: 6, mask: {7, 39, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.698247687 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 532, index: 7, mask: {8, 40, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.702247091 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 533, index: 8, mask: {9, 41, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.710247596 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 541, index: 16, mask: {17, 49, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.714246627 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 542, index: 17, mask: {18, 50, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.718245858 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 543, index: 18, mask: {19, 51, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.722246161 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 544, index: 19, mask: {20, 52, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.726246856 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 545, index: 20, mask: {21, 53, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.730245716 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 546, index: 21, mask: {22, 54, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.734244407 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 547, index: 22, mask: {23, 55, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.738241679 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 548, index: 23, mask: {24, 56, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.742244365 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 549, index: 24, mask: {25, 57, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.746244715 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 550, index: 25, mask: {26, 58, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.750244878 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 530, index: 5, mask: {6, 38, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.754248889 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 551, index: 26, mask: {27, 59, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.758246263 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 552, index: 27, mask: {28, 60, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.766262442 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 553, index: 28, mask: {29, 61, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.770244975 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 554, index: 29, mask: {30, 62, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.774245495 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 555, index: 30, mask: {31, 63, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.778245839 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 529, index: 4, mask: {5, 37, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.780957340 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 525, index: 0, mask: {1, 33, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.782258554 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 528, index: 3, mask: {4, 36, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.786006276 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 526, index: 1, mask: {2, 34, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set. 2023-05-18 08:24:58.786252034 [E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 527, index: 2, mask: {3, 35, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set.

The output The background is successfully removed , but it is black not white or transparent and the error is still shown. The images I'm editing are AI generated (diffusers-Stable diffusion) , I'm using Jarvislabs.ai and the latest version of rembg. I tried this line of code but the error is still there "os.environ['OMP_NUM_THREADS'] = "

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

flux627 commented 1 year ago

Getting the same thing, however my backgrounds are transparent.

Sharkum commented 1 year ago

Facing the same issue. I am able to process the images and the background is being removed, but keep getting these errors.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sieboldianus commented 1 year ago

Same error here (on webui latest version 1.6.0, and I don't have a solution). This issue should be opened again.

xizi commented 12 months ago

Meet same error.

jiagaoxiang commented 9 months ago

Meet the same error.

wolfgangmeyers commented 8 months ago

I'm getting this error when running in replicate. Don't see it when running in a linux test env or on windows.

sanchitd5 commented 8 months ago

keeping the issue alive

zhizdev commented 7 months ago

Experiencing this issue on Slurm, fixed by adding environment variable

OMP_NUM_THREADS=10 # or adjust to however many threads

ByChelsea commented 7 months ago

Hey, guys. For those using the slurm system, the os.environ does not contain the OMP_NUM_THREADS environment variable, which resulted in two important lines of code not being executed, causing the error:

"[E:onnxruntime:Default, env.cc:251 ThreadMain] pthread_setaffinity_np failed for thread: 527, index: 2, mask: {3, 35, }, error code: 22 error msg: Invalid argument. Specify the number of threads explicitly so the affinity is not set."

Therefore, you can change it to direct assignment, like this:

sess_opts.inter_op_num_threads = 8 sess_opts.intra_op_num_threads = 8

The integer value here can be the same as your CPU (core) count.

pocketens commented 4 months ago

I'm getting this error when running in replicate. Don't see it when running in a linux test env or on windows.

Same. Completely stuck on this issue (using an API)

wwfcnu commented 2 months ago

使用onnxruntime-gpu为什么也会出现这个错误

satyaai commented 3 weeks ago

@NourJemmali , I am facing the same issue, I am also using Jarvislab.ai system. Can you please let me know How did you solve that particular issue? Thanks in advance.