danielgatis / rembg

Rembg is a tool to remove images background
MIT License
15.46k stars 1.76k forks source link

[BUG] Segmentation Fault when using the library to remove background form an image #575

Closed umutyazgan closed 4 months ago

umutyazgan commented 5 months ago

Describe the bug I get a "Segmentation fault" when I try to remove the background from a PIL image, using the library with GPU support.

To Reproduce Steps to reproduce the behavior:

  1. Write this script:
    
    from rembg import remove
    from PIL import Image

input_path = 'input.png' output_path = 'output.png'

input = Image.open(input_path) output = remove(input) output.save(output_path)

2. Use this input image:
![input](https://github.com/danielgatis/rembg/assets/6518368/6d6a25d9-c9aa-4024-b35d-465534a10323)

3. run it: `python rembg_test.py`
4. 

OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead. 2024-01-24 16:35:14.315665635 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:14 WARNING] onnx2trt_utils.cpp:364: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32. 2024-01-24 16:35:16.588285820 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:16 WARNING] TensorRT was linked against cuBLAS/cuBLAS LT 11.5.1 but loaded cuBLAS/cuBLAS LT 11.3.0 2024-01-24 16:35:17.065906556 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:17 WARNING] TensorRT was linked against cuDNN 8.2.1 but loaded cuDNN 8.0.5 2024-01-24 16:35:17.069822559 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:17 WARNING] Detected invalid timing cache, setup a local cache instead 2024-01-24 16:35:50.336724380 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:50 WARNING] TensorRT was linked against cuBLAS/cuBLAS LT 11.5.1 but loaded cuBLAS/cuBLAS LT 11.3.0 2024-01-24 16:35:50.339813076 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:50 WARNING] TensorRT was linked against cuDNN 8.2.1 but loaded cuDNN 8.0.5 2024-01-24 16:35:50.351736494 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:50 WARNING] TensorRT was linked against cuBLAS/cuBLAS LT 11.5.1 but loaded cuBLAS/cuBLAS LT 11.3.0 2024-01-24 16:35:50.355949247 [W:onnxruntime:Default, tensorrt_execution_provider.h:77 log] [2024-01-24 16:35:50 WARNING] TensorRT was linked against cuDNN 8.2.1 but loaded cuDNN 8.0.5 Segmentation fault


**Expected behavior**
Shoud run without a SegFault and remove the background from the image.

**Images**
Another input image I tried:
![cam000010](https://github.com/danielgatis/rembg/assets/6518368/59ea76dc-55da-4930-b36d-b0f5508356d7)

**OS Version:**
Debian GNU/Linux 11 (bullseye) x86_64
Kernel: 5.10.0-27-cloud-amd64

**Rembg version:**
v2.0.53

**Additional context**
The machine is on Google Compute Engine.
GPU: NVIDIA Tesla T4 16 GB
`nvidia-smi`

+---------------------------------------------------------------------------------------+ | NVIDIA-SMI 545.23.08 Driver Version: 545.23.08 CUDA Version: 12.3 | |-----------------------------------------+----------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 Tesla T4 On | 00000000:00:04.0 Off | 0 | | N/A 37C P8 12W / 70W | 2MiB / 15360MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | No running processes found | +---------------------------------------------------------------------------------------+

Some packages in my conda environment that may be relevant:

cuda-cudart 12.1.105 0 nvidia cuda-cupti 12.1.105 0 nvidia cuda-libraries 12.1.0 0 nvidia cuda-nvrtc 12.1.105 0 nvidia cuda-nvtx 12.1.105 0 nvidia cuda-opencl 12.3.101 0 nvidia cuda-runtime 12.1.0 0 nvidia cudatoolkit 11.1.1 hb139c0e_12 conda-forge imageio 2.9.0 pypi_0 pypi imageio-ffmpeg 0.4.4 pypi_0 pypi nvidia-cublas-cu12 12.1.3.1 pypi_0 pypi nvidia-cuda-cupti-cu12 12.1.105 pypi_0 pypi nvidia-cuda-nvrtc-cu12 12.1.105 pypi_0 pypi nvidia-cuda-runtime-cu12 12.1.105 pypi_0 pypi nvidia-cudnn-cu12 8.9.2.26 pypi_0 pypi nvidia-cufft-cu12 11.0.2.54 pypi_0 pypi nvidia-curand-cu12 10.3.2.106 pypi_0 pypi nvidia-cusolver-cu12 11.4.5.107 pypi_0 pypi nvidia-cusparse-cu12 12.1.0.106 pypi_0 pypi nvidia-nccl-cu12 2.18.1 pypi_0 pypi nvidia-nvjitlink-cu12 12.3.101 pypi_0 pypi nvidia-nvtx-cu12 12.1.105 pypi_0 pypi onnxruntime 1.16.3 pypi_0 pypi onnxruntime-gpu 1.16.3 pypi_0 pypi opencv-contrib-python 4.9.0.80 pypi_0 pypi opencv-python 4.9.0.80 pypi_0 pypi opencv-python-headless 4.9.0.80 pypi_0 pypi pillow 8.1.0 pypi_0 pypi python 3.8.5 h1103e12_9_cpython conda-forge pytorch 2.1.2 py3.8_cuda12.1_cudnn8.9.2_0 pytorch pytorch-cuda 12.1 ha16c6d3_5 pytorch torch 2.1.2 pypi_0 pypi torchaudio 2.1.2 py38_cu121 pytorch torchdiffeq 0.2.3 pypi_0 pypi torchmetrics 1.3.0.post0 pypi_0 pypi torchsde 0.2.6 pypi_0 pypi torchtriton 2.1.0 py38 pytorch torchvision 0.10.1 py38_cu111 pytorch

github-actions[bot] commented 4 months ago

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

github-actions[bot] commented 4 months ago

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