Skip to content

Commit

Permalink
Append extra args to pip_install_requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhao9 committed Jun 19, 2024
1 parent d13f44f commit ec9fcc6
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 136 deletions.
7 changes: 4 additions & 3 deletions torchbenchmark/canary_models/DALLE2_pytorch/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import patch
import subprocess
import sys
from utils.python_utils import pip_install_requirements

def patch_dalle2():
import dalle2_pytorch
Expand All @@ -12,8 +13,8 @@ def patch_dalle2():
print("Failed to patch dalle2_pytorch/dalle2_pytorch.py. Exit.")
exit(1)

def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-q', '-r', 'requirements.txt'])
def pip_install_requirements_dalle2():
pip_install_requirements()
# DALLE2_pytorch requires embedding-reader
# https://github.com/lucidrains/DALLE2-pytorch/blob/00e07b7d61e21447d55e6d06d5c928cf8b67601d/setup.py#L34
# embedding-reader requires an old version of pandas and pyarrow
Expand All @@ -22,5 +23,5 @@ def pip_install_requirements():
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-U', 'pandas', 'pyarrow'])

if __name__ == '__main__':
pip_install_requirements()
pip_install_requirements_dalle2()
patch_dalle2()
2 changes: 0 additions & 2 deletions torchbenchmark/canary_models/codellama/install.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

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

Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/canary_models/fambench_dlrm/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import subprocess
from torchbenchmark import REPO_PATH
from utils.python_utils import pip_install_requirements


def update_fambench_submodule():
Expand All @@ -17,12 +18,6 @@ def update_fambench_submodule():
subprocess.check_call(update_command, cwd=REPO_PATH)


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


if __name__ == "__main__":
update_fambench_submodule()
pip_install_requirements()
6 changes: 2 additions & 4 deletions torchbenchmark/canary_models/fambench_xlmr/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import subprocess
from torchbenchmark import REPO_PATH

from utils.python_utils import pip_install_requirements

def update_fambench_submodule():
"Update FAMBench submodule of the benchmark repo"
Expand All @@ -19,9 +19,7 @@ def update_fambench_submodule():

def pip_install_requirements():
try:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-q", "-r", "requirements.txt"]
)
pip_install_requirements()
# pin fairseq version
# ignore deps specified in requirements.txt
subprocess.check_call(
Expand Down
11 changes: 2 additions & 9 deletions torchbenchmark/canary_models/gat/install.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@

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', '-f', 'https://data.pyg.org/whl/torch-2.1.0+cpu.html'])

from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "Reddit_minimal.tar.gz", decompress=True)
pip_install_requirements()
pip_install_requirements(extra_args=["-f", "https://data.pyg.org/whl/torch-2.1.0+cpu.html"])
6 changes: 1 addition & 5 deletions torchbenchmark/canary_models/hf_MPT_7b_instruct/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +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
4 changes: 1 addition & 3 deletions torchbenchmark/canary_models/hf_Yi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
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
5 changes: 1 addition & 4 deletions torchbenchmark/canary_models/hf_mixtral/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model
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__':
pip_install_requirements()
Expand Down
4 changes: 1 addition & 3 deletions torchbenchmark/canary_models/phi_1_5/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
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
6 changes: 1 addition & 5 deletions torchbenchmark/canary_models/phi_2/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +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: 1 addition & 8 deletions torchbenchmark/canary_models/sage/install.py
Original file line number Diff line number Diff line change
@@ -1,12 +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', '-f', 'https://data.pyg.org/whl/torch-2.1.0+cpu.html'])

from utils.python_utils import pip_install_requirements

if __name__ == '__main__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "Reddit_minimal.tar.gz", decompress=True)
Expand Down
10 changes: 1 addition & 9 deletions torchbenchmark/canary_models/torchrec_dlrm/install.py
Original file line number Diff line number Diff line change
@@ -1,12 +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/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
5 changes: 1 addition & 4 deletions torchbenchmark/models/moondream/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import subprocess
import sys
import os
from torchbenchmark.util.framework.huggingface.patch_hf import patch_transformers, cache_model
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__':
pip_install_requirements()
Expand Down
5 changes: 1 addition & 4 deletions torchbenchmark/models/nvidia_deeprecommender/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
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()
Expand Down
6 changes: 1 addition & 5 deletions torchbenchmark/models/opacus_cifar10/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()
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__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "pytorch_CycleGAN_and_pix2pix_inputs.tar.gz", decompress=True)
Expand Down
6 changes: 1 addition & 5 deletions torchbenchmark/models/pytorch_stargan/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__':
s3_utils.checkout_s3_data("INPUT_TARBALLS", "pytorch_stargan_inputs.tar.gz", decompress=True)
Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/pytorch_unet/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', 'pytorch_unet/requirements.txt'])
from utils.python_utils import pip_install_requirements

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

def download(uri):
directory = '.data'
Expand All @@ -16,10 +17,6 @@ def download(uri):
else:
print(f'Failed to download file with status code {response.status_code}')


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

def download_checkpoint():
download('https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth')

Expand Down
7 changes: 1 addition & 6 deletions torchbenchmark/models/sam_fast/install.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import subprocess
import sys
import requests
from utils.python_utils import pip_install_requirements

def download(uri):
directory = '.data'
Expand All @@ -16,10 +15,6 @@ def download(uri):
else:
print(f'Failed to download file with status code {response.status_code}')


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

def download_checkpoint():
download('https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth')

Expand Down
10 changes: 1 addition & 9 deletions torchbenchmark/models/soft_actor_critic/install.py
Original file line number Diff line number Diff line change
@@ -1,12 +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()
6 changes: 1 addition & 5 deletions torchbenchmark/models/speech_transformer/install.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import sys
import subprocess
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", "speech_transformer_inputs.tar.gz", decompress=True)
Expand Down
15 changes: 1 addition & 14 deletions torchbenchmark/util/framework/lit_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path

from torchbenchmark import REPO_PATH
from utils.python_utils import pip_install_requirements

LIT_LLAMA_PATH = os.path.join(REPO_PATH, "submodules", "lit-llama")

Expand All @@ -21,20 +22,6 @@ def update_lit_llama_submodule():
subprocess.check_call(update_command, cwd=REPO_PATH)


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


def openllama_download():
if os.path.exists(
os.path.join(LIT_LLAMA_PATH, "checkpoints/lit-llama/7B/lit-llama.pth")
Expand Down
9 changes: 8 additions & 1 deletion utils/python_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
import subprocess

from typing import Optional, List

DEFAULT_PYTHON_VERSION = "3.11"

PYTHON_VERSION_MAP = {
Expand All @@ -23,7 +25,10 @@ def create_conda_env(pyver: str, name: str):
subprocess.check_call(command)


def pip_install_requirements(requirements_txt="requirements.txt", continue_on_fail=False, no_build_isolation=False):
def pip_install_requirements(requirements_txt="requirements.txt",
continue_on_fail=False,
no_build_isolation=False,
extra_args: Optional[List[str]]=None):
import sys
constraints_file = REPO_DIR.joinpath("build", "constraints.txt")
if not constraints_file.exists():
Expand All @@ -33,6 +38,8 @@ def pip_install_requirements(requirements_txt="requirements.txt", continue_on_fa
constraints_parameters = ["-c", str(constraints_file.resolve())]
if no_build_isolation:
constraints_parameters.append("--no-build-isolation")
if extra_args and isinstance(extra_args, list):
constraints_parameters.extend(extra_args)
if not continue_on_fail:
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "-r", requirements_txt] + constraints_parameters,
Expand Down

0 comments on commit ec9fcc6

Please sign in to comment.