Skip to content

Commit

Permalink
Use python utils to handle pip requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhao9 committed Jun 19, 2024
1 parent 1db74ee commit e6ee538
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 199 deletions.
6 changes: 1 addition & 5 deletions torchbenchmark/models/LearningToPaint/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import subprocess
import sys
from utils import s3_utils
from utils.python_utils import pip_install_requirements


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])

if __name__ == '__main__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "Super_SloMo_inputs.tar.gz", decompress=True)
pip_install_requirements()
8 changes: 1 addition & 7 deletions torchbenchmark/models/Super_SloMo/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import subprocess
import sys
from utils import s3_utils


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])

from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "Super_SloMo_inputs.tar.gz", decompress=True)
Expand Down
6 changes: 1 addition & 5 deletions torchbenchmark/models/dlrm/install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import subprocess
import sys

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
10 changes: 4 additions & 6 deletions torchbenchmark/models/doctr_det_predictor/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import warnings
import subprocess
import sys
from utils.python_utils import pip_install_requirements


def pip_install_requirements():
def pip_install_requirements_doctr():
try:
subprocess.check_call(
[
Expand All @@ -21,10 +21,8 @@ def pip_install_requirements():
warnings.warn(
"The doctr_det_predictor model requires conda binary libaries to be installed. Missing conda packages might break this model."
)
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-q", "-r", "requirements.txt"]
)
pip_install_requirements()


if __name__ == "__main__":
pip_install_requirements()
pip_install_requirements_doctr()
12 changes: 5 additions & 7 deletions torchbenchmark/models/doctr_reco_predictor/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import warnings
import subprocess
import sys
from utils.python_utils import pip_install_requirements


def pip_install_requirements():
def pip_install_requirements_doctr():
try:
subprocess.check_call(
[
Expand All @@ -19,12 +19,10 @@ def pip_install_requirements():
)
except:
warnings.warn(
"The doctr_reco_predictor model requires conda binary libaries to be installed. Missing conda packages might break this model."
"The doctr_det_predictor model requires conda binary libaries to be installed. Missing conda packages might break this model."
)
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-q", "-r", "requirements.txt"]
)
pip_install_requirements()


if __name__ == "__main__":
pip_install_requirements()
pip_install_requirements_doctr()
6 changes: 1 addition & 5 deletions torchbenchmark/models/drq/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import subprocess
import sys
from utils import s3_utils

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
6 changes: 1 addition & 5 deletions torchbenchmark/models/fastNLP_Bert/install.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import subprocess
import os
import sys
import patch
from utils.python_utils import pip_install_requirements

def patch_fastnlp():
import fastNLP
Expand All @@ -14,9 +13,6 @@ def patch_fastnlp():
print("Failed to patch fastNLP. Exit.")
exit(1)

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])

if __name__ == '__main__':
pip_install_requirements()
patch_fastnlp()
7 changes: 1 addition & 6 deletions torchbenchmark/models/functorch_dp_cifar10/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import subprocess
import sys


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
7 changes: 1 addition & 6 deletions torchbenchmark/models/functorch_maml_omniglot/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import subprocess
import sys
from utils import s3_utils


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Albert/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Bart/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Bert/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Bert_large/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
9 changes: 2 additions & 7 deletions torchbenchmark/models/hf_BigBird/install.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
patch_transformers()
model_name = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
cache_model(model_name)
cache_model(model_name)
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_DistilBert/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_GPT2/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_GPT2_large/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Longformer/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_Reformer/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_T5/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
2 changes: 1 addition & 1 deletion torchbenchmark/models/hf_T5_base/install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from utils.python_utils import pip_install_requirements
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/hf_distil_whisper/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/lennard_jones/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import subprocess
import sys


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
8 changes: 2 additions & 6 deletions torchbenchmark/models/llama/install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import subprocess
import sys

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
pip_install_requirements()
8 changes: 2 additions & 6 deletions torchbenchmark/models/llava/install.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
pip_install_requirements()
patch_transformers()
model_name = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
cache_model(model_name)
cache_model(model_name)
7 changes: 1 addition & 6 deletions torchbenchmark/models/tacotron2/install.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import os
from pathlib import Path
import subprocess
import sys
from utils import s3_utils
from utils.python_utils import pip_install_requirements


def check_data_dir():
current_dir = Path(os.path.dirname(os.path.realpath(__file__)))
tacotron2_data_dir = os.path.join(current_dir.parent.parent, "data", ".data", "tacotron2-minimal")
assert os.path.exists(tacotron2_data_dir), "Couldn't find tacotron2 minimal data dir, please run install.py again."


def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])

if __name__ == '__main__':
pip_install_requirements()
s3_utils.checkout_s3_data("INPUT_TARBALLS", "tacotron2-minimal.tar.gz", decompress=True)
9 changes: 1 addition & 8 deletions torchbenchmark/models/timm_efficientdet/install.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
import sys
import patch
import subprocess
from utils import s3_utils
from utils.python_utils import pip_install_requirements


def patch_effdet():
Expand All @@ -29,12 +28,6 @@ def patch_pycocotools():
exit(1)


def pip_install_requirements():
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-q", "-r", "requirements.txt"]
)


if __name__ == "__main__":
s3_utils.checkout_s3_data(
"INPUT_TARBALLS", "coco2017-minimal.tar.gz", decompress=True
Expand Down
Loading

0 comments on commit e6ee538

Please sign in to comment.