-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add install.py for test_bench (#2546)
Summary: Add install.py for test_bench introduced in #2052 ### Usage ```bash $ python install.py --userbenchmark test_bench --models BERT_pytorch hf_GPT2 --skip hf_GPT2 checking packages numpy, torch are installed, generating constaints...OK Installing userbenchmark test_bench with extra args: ['--models'] Installing BERT_pytorch... Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Obtaining file:///Users/shenke/workspace/benchmark/torchbenchmark/models/BERT_pytorch Preparing metadata (setup.py) ... done Requirement already satisfied: tqdm in /opt/anaconda3/envs/nightlypth/lib/python3.11/site-packages (from bert_pytorch==0.0.1a4) (4.66.4) Requirement already satisfied: numpy in /opt/anaconda3/envs/nightlypth/lib/python3.11/site-packages (from bert_pytorch==0.0.1a4) (1.24.4) Installing collected packages: bert_pytorch Attempting uninstall: bert_pytorch Found existing installation: bert_pytorch 0.0.1a4 Uninstalling bert_pytorch-0.0.1a4: Successfully uninstalled bert_pytorch-0.0.1a4 Running setup.py develop for bert_pytorch Successfully installed bert_pytorch-0.0.1a4 ``` Pull Request resolved: #2546 Reviewed By: xuzhao9 Differential Revision: D66457458 Pulled By: FindHao fbshipit-source-id: 73b5f88dc50bd27eceb91c456279d7a687656c7c
- Loading branch information
1 parent
341ad14
commit 9ff23ab
Showing
3 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import argparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
parser = argparse.ArgumentParser(allow_abbrev=False) | ||
parser.add_argument( | ||
"models", | ||
nargs="*", | ||
default=[], | ||
help="Specify one or more models to install. If not set, install all models.", | ||
) | ||
parser.add_argument("--skip", nargs="*", default=[], help="Skip models to install.") | ||
parser.add_argument("--canary", action="store_true", help="Install canary model.") | ||
args, extra_args = parser.parse_known_args() | ||
|
||
|
||
def install_test_bench_requirements(): | ||
from torchbenchmark import _filter_model_paths | ||
|
||
model_paths = _filter_model_paths(args.models, args.skip, args.canary) | ||
for path in model_paths: | ||
print(f"Installing {os.path.basename(path)}...") | ||
install_py_path = os.path.join(path, "install.py") | ||
requirements_txt_path = os.path.join(path, "requirements.txt") | ||
if os.path.exists(install_py_path): | ||
subprocess.check_call([sys.executable, install_py_path], cwd=path) | ||
elif os.path.exists(requirements_txt_path): | ||
subprocess.check_call( | ||
[ | ||
sys.executable, | ||
"-m", | ||
"pip", | ||
"install", | ||
"-q", | ||
"-r", | ||
f"{requirements_txt_path}", | ||
], | ||
cwd=path, | ||
) | ||
else: | ||
print(f"SKipped: {os.path.basename(path)}") | ||
|
||
|
||
if __name__ == "__main__": | ||
install_test_bench_requirements() |