Skip to content

speed up tests with CLI#2121

Merged
wanghan-iapcm merged 1 commit intodeepmodeling:develfrom
njzjz:speed-up-test-args
Nov 23, 2022
Merged

speed up tests with CLI#2121
wanghan-iapcm merged 1 commit intodeepmodeling:develfrom
njzjz:speed-up-test-args

Conversation

@njzjz
Copy link
Member

@njzjz njzjz commented Nov 22, 2022

Currently, all tests use a subprocess to call CLI. This might be slow, as it's expensive to import TensorFlow (takes 2s on my computer). This patch adds a new argument to deepmd.entrypoints.main.main to allow arguments passed, so tests can call CLI without starting a new subprocess.

Attached is the time of import deepmd:
image
We can see import tensorflow takes about 90% of the total time and import numpy takes about 4%.

Currently all tests use subprocess to call CLI. This might be slow, as it's expensive to import tensorflow (takes 2s on my computer). This patch adds a new argument to `deepmd.entrypoints.main.main` to allow arguments passed, so tests can call CLI without start a new subprocess.
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2022

Codecov Report

Base: 73.97% // Head: 73.98% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (3fb2a39) compared to base (41d2487).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2121      +/-   ##
==========================================
+ Coverage   73.97%   73.98%   +0.01%     
==========================================
  Files         201      201              
  Lines       19712    19720       +8     
  Branches     1406     1408       +2     
==========================================
+ Hits        14581    14589       +8     
- Misses       4196     4197       +1     
+ Partials      935      934       -1     
Impacted Files Coverage Δ
deepmd/common.py 84.37% <100.00%> (+0.29%) ⬆️
deepmd/entrypoints/main.py 91.20% <100.00%> (+0.36%) ⬆️
deepmd/utils/data.py 91.15% <0.00%> (-0.22%) ⬇️
source/lib/include/ComputeDescriptor.h 76.87% <0.00%> (+0.22%) ⬆️

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.

@wanghan-iapcm wanghan-iapcm merged commit 15b7135 into deepmodeling:devel Nov 23, 2022
njzjz added a commit to njzjz/deepmd-kit that referenced this pull request Nov 27, 2022
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)
wanghan-iapcm pushed a commit that referenced this pull request 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)

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
mingzhong15 pushed a commit to mingzhong15/deepmd-kit that referenced this pull request Jan 15, 2023
Currently, all tests use a subprocess to call CLI. This might be slow,
as it's expensive to import TensorFlow (takes 2s on my computer). This
patch adds a new argument to `deepmd.entrypoints.main.main` to allow
arguments passed, so tests can call CLI without starting a new
subprocess.

Attached is the time of `import deepmd`:

![image](https://user-images.githubusercontent.com/9496702/203431388-7ebdc106-8a00-4d58-ae65-f83cad5ca585.png)
We can see `import tensorflow` takes about 90% of the total time and
`import numpy` takes about 4%.
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