Skip to content

skip get_gpus subprocess when TF is cpu only#2135

Merged
wanghan-iapcm merged 4 commits intodeepmodeling:develfrom
njzjz:skip-gpu-for-cpu
Nov 27, 2022
Merged

skip get_gpus subprocess when TF is cpu only#2135
wanghan-iapcm merged 4 commits intodeepmodeling:develfrom
njzjz:skip-gpu-for-cpu

Conversation

@njzjz
Copy link
Member

@njzjz njzjz commented Nov 27, 2022

When I benchmark deepmd-kit on my machine, I found get_gpus takes about 2s and is quite slow. In #905, a subprocess was added to get available GPUs. As benchmarked in #2121, it's quite slow to import tensorflow.

I don't have better ideas not to call a subprocess, but we can skip this process when TensorFlow is not built against GPUs. The tests on the GitHub Actions will also benefit.

Attached is the selected profiling:

ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 2.141 2.141 local.py:15(get_gpus)
1 0.000 0.000 2.133 2.133 subprocess.py:1090(communicate)

When I benchmark deepmd-kit on my machine, I found `get_gpus` takes about 2s and is quite slow. In deepmodeling#905, a subprocess is added to get available GPUs. As benchmarked in deepmodeling#2121, it's quite slow to import tensorflow.

I don't have better ideas not to call a subprocess, but we can skip this process when TensorFlow is not built against GPUs. The tests on the GitHub Actions will also benefit.

Attached selected profiling:
>  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
> 1    0.000    0.000    2.141    2.141 local.py:15(get_gpus)
> 1    0.000    0.000    2.133    2.133 subprocess.py:1090(communicate)
@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2022

Codecov Report

Base: 74.22% // Head: 74.22% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (d545150) compared to base (47a82df).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2135      +/-   ##
==========================================
- Coverage   74.22%   74.22%   -0.01%     
==========================================
  Files         201      201              
  Lines       19790    19792       +2     
  Branches     1416     1416              
==========================================
+ Hits        14689    14690       +1     
  Misses       4162     4162              
- Partials      939      940       +1     
Impacted Files Coverage Δ
deepmd/cluster/local.py 100.00% <100.00%> (ø)
source/lib/include/ComputeDescriptor.h 76.65% <0.00%> (-0.23%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@njzjz njzjz requested a review from wanghan-iapcm November 27, 2022 01:41
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@wanghan-iapcm wanghan-iapcm merged commit 243c35a into deepmodeling:devel Nov 27, 2022
mingzhong15 pushed a commit to mingzhong15/deepmd-kit that referenced this pull request Jan 15, 2023
When I benchmark deepmd-kit on my machine, I found `get_gpus` takes
about 2s and is quite slow. In deepmodeling#905, a subprocess was added to get
available GPUs. As benchmarked in deepmodeling#2121, it's quite slow to import
tensorflow.

I don't have better ideas not to call a subprocess, but we can skip this
process when TensorFlow is not built against GPUs. The tests on the
GitHub Actions will also benefit.

Attached is the selected profiling:
>  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
> 1    0.000    0.000    2.141    2.141 local.py:15(get_gpus)
> 1    0.000    0.000    2.133    2.133 subprocess.py:1090(communicate)

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants