OPHoperHPO / image-background-remove-tool

✂️ Automated high-quality background removal framework for an image using neural networks. ✂️
https://carve.photos
Apache License 2.0
1.39k stars 272 forks source link

ImportError: libtorch_cpu.so: cannot enable executable stack as shared object requires: Permission denied #123

Closed instantestore closed 1 year ago

instantestore commented 1 year ago

Hey, @OPHoperHPO. I tried installing this on a fresh CentOS 9 Stream X64 installation and it looked like it installed properly. I basically ran "pip install carvekit --extra-index-url https://download.pytorch.org/whl/cpu" and it installed without any errors.

However, when I then tried to use it by running

python3 -m carvekit -i /path/to/file -o /path/to/output --engine cpu

I get the following error message.

Traceback (most recent call last): File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.9/site-packages/carvekit/main.py", line 6, in from carvekit.utils.image_utils import ALLOWED_SUFFIXES File "/usr/local/lib/python3.9/site-packages/carvekit/utils/image_utils.py", line 12, in import torch File "/usr/local/lib64/python3.9/site-packages/torch/init.py", line 199, in from torch._C import * # noqa: F403 ImportError: libtorch_cpu.so: cannot enable executable stack as shared object requires: Permission denied

I checked the libtorch_cpu.so file and it's executable.

[root@theo lib]# ls -la total 449104 drwxr-xr-x. 2 root root 4096 Jan 27 10:39 . drwxr-xr-x. 36 root root 4096 Jan 27 10:39 .. -rwxr-xr-x. 1 root root 279184 Jan 27 10:39 libbackend_with_compiler.so -rwxr-xr-x. 1 root root 715904 Jan 27 10:39 libc10.so -rwxr-xr-x. 1 root root 168720 Jan 27 10:39 libgomp-a34b3233.so.1 -rwxr-xr-x. 1 root root 233248 Jan 27 10:39 libjitbackend_test.so -rwxr-xr-x. 1 root root 35344 Jan 27 10:39 libshm.so -rwxr-xr-x. 1 root root 595776 Jan 27 10:39 libtorchbind_test.so -rwxr-xr-x. 1 root root 442238200 Jan 27 10:39 libtorch_cpu.so -rwxr-xr-x. 1 root root 8720 Jan 27 10:39 libtorch_global_deps.so -rwxr-xr-x. 1 root root 15571344 Jan 27 10:39 libtorch_python.so -rwxr-xr-x. 1 root root 7192 Jan 27 10:39 libtorch.so

Can you please help me?

Thanks!

Charles Tang

OPHoperHPO commented 1 year ago

Hello @instantestore

This error is not related to our framework. The error is caused by incorrect installation of PyTorch. Remove the current torch installation and install it according to the instructions for your distribution. You can also try the execstack command. Also make sure the location where you have the Python environment is not mounted with the noexec flag.

instantestore commented 1 year ago

Thank you very much for your very fast response! What distribution would you recommend? I'm pretty free to use any Linux distro.

Thanks.

Charles

OPHoperHPO commented 1 year ago

I recommend using Ubuntu or Arch Linux