CVHub520 / X-AnyLabeling

Effortless data labeling with AI support from Segment Anything and other awesome models.
GNU General Public License v3.0
3.79k stars 438 forks source link

GPU is not working while auto labeling with AI models #464

Closed JasonSloan closed 3 months ago

JasonSloan commented 3 months ago

Environment: PyTorch version: 1.13.0+cu117 Is debug build: False CUDA used to build PyTorch: 11.7 ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64) GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 Clang version: Could not collect CMake version: version 3.27.5 Libc version: glibc-2.35

Python version: 3.9.17 (main, Jul 5 2023, 20:41:20) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.15.0-88-generic-x86_64-with-glibc2.35 Is CUDA available: True CUDA runtime version: 11.5.119 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 2070 SUPER Nvidia driver version: 535.129.03 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

Versions of relevant libraries: [pip3] numpy==1.23.5 [pip3] torch==1.13.0 [pip3] torchmetrics==1.1.2 [pip3] torchvision==0.14.0 [conda] numpy 1.23.5 pypi_0 pypi [conda] torch 1.13.0 pypi_0 pypi [conda] torchmetrics 1.1.2 pypi_0 pypi [conda] torchvision 0.14.0 pypi_0 pypi onnxruntime 1.16.1 onnxruntime-gpu 1.18.0

Description: I installed the gpu environment with "pip install -r requirements-gpu.txt" in a conda env. I modified the device from "CPU" to "GPU" in file "app_info.py". I run the "GroudingDino" model with anylabeling app. The gpu wasnt used at all when I tried tp auto-label the images while the cpu was used heavily. The usage of gpu and cpu is below: question

How can I make use of gpu? Thanks!

Besides, my gpu works well with torch. q2

CVHub520 commented 3 months ago

@JasonSloan, Hey!

To utilize your GPU with X-AnyLabeling, you need to ensure that the environment supports GPU acceleration. Currently, the inference backend is onnxruntime-gpu, which means that your GPU should be compatible with the version of ONNX Runtime you have installed.

Here's how you can proceed:

  1. Install ONNX Runtime GPU: Make sure you have the ONNX Runtime GPU version installed. You can find installation instructions on the ONNX Runtime official documentation.

  2. Check GPU Support: ONNX Runtime has a list of supported GPUs. You should check if your GPU is on that list. If it's not, you might not be able to use GPU acceleration with ONNX Runtime.

  3. Enable GPU in X-AnyLabeling: Once ONNX Runtime GPU is installed and your GPU is supported, you should be able to enable GPU acceleration in X-AnyLabeling. This is usually done through the settings or configuration file.

  4. Verify GPU Usage: After enabling GPU acceleration, you should check if X-AnyLabeling is actually using the GPU. This can be done by looking at the system resource usage or by checking the GPU utilization in the X-AnyLabeling interface.

If you have any issues with GPU support or if you need further assistance, please feel free to reach out, and we'll do our best to help you.

Best regards, CVHub

JasonSloan commented 3 months ago

@JasonSloan, Hey!

To utilize your GPU with X-AnyLabeling, you need to ensure that the environment supports GPU acceleration. Currently, the inference backend is onnxruntime-gpu, which means that your GPU should be compatible with the version of ONNX Runtime you have installed.

Here's how you can proceed:

  1. Install ONNX Runtime GPU: Make sure you have the ONNX Runtime GPU version installed. You can find installation instructions on the ONNX Runtime official documentation.
  2. Check GPU Support: ONNX Runtime has a list of supported GPUs. You should check if your GPU is on that list. If it's not, you might not be able to use GPU acceleration with ONNX Runtime.
  3. Enable GPU in X-AnyLabeling: Once ONNX Runtime GPU is installed and your GPU is supported, you should be able to enable GPU acceleration in X-AnyLabeling. This is usually done through the settings or configuration file.
  4. Verify GPU Usage: After enabling GPU acceleration, you should check if X-AnyLabeling is actually using the GPU. This can be done by looking at the system resource usage or by checking the GPU utilization in the X-AnyLabeling interface.

If you have any issues with GPU support or if you need further assistance, please feel free to reach out, and we'll do our best to help you.

Best regards, CVHub

Thanks for your guidance, all the problems are solved and i would like to make a record.

The app cant be used in docker container, it must be used in the hostmachine.

The problem below solved by "sudo apt install libxcb-*" q3

The problem below solved by "pip install onnxruntime==1.11.0" and "pip uninstall opencv-python && pip install opencv-python-headless" image

The problem below solved by 'pip install torch' and 'find libcublasLt**' and set 'LD_LIBRARY_PATH' to '~/.bashrc' image

Still a lots of libraries related to cuda are reported missing for example "libcudnn_ops_train.so.8" "libcufft.so.10" etc. And I add there path to 'LD_LIBRARY_PATH' one by one. So I think there must be some steps that be omitted according to the missing libraries , could you give some hints plz?

CVHub520 commented 3 months ago

It's great to hear that you've been able to resolve some issues with your system! Here’s a summary of the solutions you applied:

  1. Missing XCB Libraries

    • You encountered an issue related to missing libxcb libraries which was resolved by running:
      sudo apt install libxcb-*
  2. ONNX Runtime and OpenCV Compatibility

    • The problem regarding ONNX Runtime and OpenCV compatibility was fixed by installing a specific version of ONNX Runtime and then reinstalling OpenCV in headless mode:
      pip install onnxruntime==1.11.0
      pip uninstall opencv-python
      pip install opencv-python-headless

      Please refer to this document to install the matching version of GPU.

  3. PyTorch Installation and CUDA Library Path

Please note that X-AnyLabeling does not depend on any pytorch environment. It is recommended to create a new virtual environment and install it according to the tutorial

These steps should help others who might face similar issues when setting up their development environments. If you have any further questions or need additional assistance, feel free to ask! Your contributions to troubleshooting can also be very helpful to the community, so consider sharing your solutions on forums or documentation sites if you haven't already.

JasonSloan commented 3 months ago

It's great to hear that you've been able to resolve some issues with your system! Here’s a summary of the solutions you applied:

  1. Missing XCB Libraries

    • You encountered an issue related to missing libxcb libraries which was resolved by running:
      sudo apt install libxcb-*
  2. ONNX Runtime and OpenCV Compatibility

    • The problem regarding ONNX Runtime and OpenCV compatibility was fixed by installing a specific version of ONNX Runtime and then reinstalling OpenCV in headless mode:
      pip install onnxruntime==1.11.0
      pip uninstall opencv-python
      pip install opencv-python-headless

Please refer to this document to install the matching version of GPU.

  1. PyTorch Installation and CUDA Library Path

Please note that X-AnyLabeling does not depend on any pytorch environment. It is recommended to create a new virtual environment and install it according to the tutorial

These steps should help others who might face similar issues when setting up their development environments. If you have any further questions or need additional assistance, feel free to ask! Your contributions to troubleshooting can also be very helpful to the community, so consider sharing your solutions on forums or documentation sites if you haven't already.

OK, thanks, I will close the issue now.