Skip to content

GPU not used without error #2292

Closed
Closed

Description

@tianboqi

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

I am using DeepLabCut with a NVIDIA RTX A5000 graphic card. Below is the console output (I omitted the parameter part, only put the part that is related to GPU), which doesn't show anything wrong. However, it seems it is not using GPU. nvidia-smi showed it only used 30% and the training was not faster than CPU runs.

C:\Users\Ye Lab\.conda\envs\DEEPLABCUT\lib\site-packages\tensorflow\python\keras\engine\base_layer_v1.py:1694: UserWarning: `layer.apply` is deprecated and will be removed in a future version. Please use `layer.__call__` method instead.
  warnings.warn('`layer.apply` is deprecated and '
2023-06-27 11:28:23.604756: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-06-27 11:28:24.870769: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:42] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2023-06-27 11:28:24.871083: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21621 MB memory:  -> device: 0, name: NVIDIA RTX A5000, pci bus id: 0000:02:00.0, compute capability: 8.6
Loading already trained DLC with backbone: mobilenet_v2_1.0
2023-06-27 11:28:25.975838: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21621 MB memory:  -> device: 0, name: NVIDIA RTX A5000, pci bus id: 0000:02:00.0, compute capability: 8.6
2023-06-27 11:28:28.451012: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:354] MLIR V1 optimization pass is not enabled
Starting training....
2023-06-27 11:28:37.890882: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8901
2023-06-27 11:28:40.081595: I tensorflow/stream_executor/cuda/cuda_blas.cc:1614] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.

Here's the nvidia-smi output:

Tue Jun 27 11:33:42 2023
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 536.25                 Driver Version: 536.25       CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                     TCC/WDDM  | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA RTX A5000             WDDM  | 00000000:02:00.0  On |                  Off |
| 30%   48C    P5              33W / 230W |   2174MiB / 24564MiB |     17%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      1656    C+G   ...1.0_x64__8wekyb3d8bbwe\Video.UI.exe    N/A      |
|    0   N/A  N/A      2604    C+G   ...ekyb3d8bbwe\PhoneExperienceHost.exe    N/A      |
|    0   N/A  N/A      8040    C+G   ...5n1h2txyewy\ShellExperienceHost.exe    N/A      |
|    0   N/A  N/A      9324    C+G   C:\Windows\explorer.exe                   N/A      |
|    0   N/A  N/A      9528    C+G   ...2txyewy\StartMenuExperienceHost.exe    N/A      |
|    0   N/A  N/A     10456    C+G   ....Search_cw5n1h2txyewy\SearchApp.exe    N/A      |
|    0   N/A  N/A     10924      C   ...b\.conda\envs\DEEPLABCUT\python.exe    N/A      |
|    0   N/A  N/A     11816    C+G   ..._8wekyb3d8bbwe\Microsoft.Photos.exe    N/A      |
|    0   N/A  N/A     12620    C+G   ...oogle\Chrome\Application\chrome.exe    N/A      |
|    0   N/A  N/A     13056    C+G   ...h2txyewy\InputApp\TextInputHost.exe    N/A      |
|    0   N/A  N/A     13628    C+G   ...03.0_x64__8wekyb3d8bbwe\Cortana.exe    N/A      |
|    0   N/A  N/A     13724    C+G   ...b3d8bbwe\Microsoft.Media.Player.exe    N/A      |
|    0   N/A  N/A     13752    C+G   ...cal\Microsoft\OneDrive\OneDrive.exe    N/A      |
|    0   N/A  N/A     14888    C+G   ...es (x86)\Dropbox\Client\Dropbox.exe    N/A      |
|    0   N/A  N/A     18564    C+G   ...siveControlPanel\SystemSettings.exe    N/A      |
+---------------------------------------------------------------------------------------+

Operating System

Windows 10

DeepLabCut version

DLC 2.3.5

DeepLabCut mode

single animal

Device type

GPU: NVIDIA RTX A5000

Steps To Reproduce

No response

Relevant log output

No response

Anything else?

No response

Code of Conduct

Activity

  1. NSGregory commented on Jun 28, 2023

    @NSGregory

    Fwiw, I see a similar pattern in single vs multi animal. Intel Mac, osx Ventura, tf-metal plugin installed, amd 6900. Much higher GPU use in multi (15-30%) while single may get up to 4-5% then drifts to zero. Takes a few minutes per iteration during training.

  2. n-poulsen commented on Jun 28, 2023

    @n-poulsen
    Contributor

    Hi @tianboqi, the 30% you see there is the fan utilisation (which just means your fan is running at 30% of its maximum speed). The actual utilisation is shown in the second column (Memory-Usage), where you're using 2174MiB / 24564MiB (so less than 10% of your total GPU memory).

    GPUs are used to parallelize operations. In general terms (it's more complicated than this but you can use this as a basic guideline) the larger the models used, the more performance improvements you'll get (as indicated in the documentation, you get a large speed boost with ResNets, and a smaller one with EfficientNets and MobileNets). So maybe check when training a ResNet if you get more of an improvement in training speed. You can look at our documentation for model trade-offs when choosing an architecture to use.

    To speed up your code, you can also try increasing the batch size (which makes use of more of the GPU, i.e. you should see your GPU memory usage increase). The value you want to use depends on how much memory you have in your GPU, the size of the model and the size of the images passed as input, but you could try 8, 16 and 32.

    And @NSGregory, when it comes to training on Macs, the issues have already been documented (having an M1 or Intel chip doesn't change the core issue, which is that to train deep learning quickly, the way to go is really to have an Nvidia GPU).

  3. NSGregory commented on Jun 28, 2023

    @NSGregory
  4. tianboqi commented on Jun 28, 2023

    @tianboqi
    Author

    Thank you @n-poulsen ! I increased the batch size to 50, and and the VRAM usage increased but still pretty low (3.7/2.4G). Is this normal?

  5. n-poulsen commented on Jul 5, 2023

    @n-poulsen
    Contributor

    @tianboqi It's likely normal, and the amount of memory used by the GPU will depend on how big the model and images you use as input are.

    @NSGregory Yes, DeepLabCut interacts with TensorFlow as a black box (we plug in to their code). If you want to train large machine learning models, currently the best way to do so is with NVIDIA GPUs. They have many optimizations that can be used for deep learning, and deep learning libraries (such as Tensorflow and PyTorch) have a lot of code that utilizes these optimizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions