|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import argparse |
|
|
import importlib |
|
|
import os |
|
|
import sys |
|
|
|
|
|
|
|
|
def parse_args(): |
|
|
parser = argparse.ArgumentParser() |
|
|
parser.add_argument( |
|
|
"--training", |
|
|
action="store_true", |
|
|
help="Whether to check training-specific dependencies", |
|
|
) |
|
|
return parser.parse_args() |
|
|
|
|
|
|
|
|
def check_packages(package_list): |
|
|
global all_success |
|
|
for package in package_list: |
|
|
try: |
|
|
_ = importlib.import_module(package) |
|
|
except Exception: |
|
|
print(f"\033[91m[ERROR]\033[0m Package not successfully imported: \033[93m{package}\033[0m") |
|
|
all_success = False |
|
|
else: |
|
|
print(f"\033[92m[SUCCESS]\033[0m {package} found") |
|
|
|
|
|
|
|
|
def main(): |
|
|
args = parse_args() |
|
|
|
|
|
if not (sys.version_info.major == 3 and sys.version_info.minor >= 10): |
|
|
detected = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}" |
|
|
print(f"\033[91m[ERROR]\033[0m Python 3.10+ is required. You have: \033[93m{detected}\033[0m") |
|
|
sys.exit(1) |
|
|
|
|
|
if "CONDA_PREFIX" not in os.environ: |
|
|
print( |
|
|
"\033[93m[WARNING]\033[0m CONDA_PREFIX is not set. When manually installed, Cosmos should run under the cosmos-transfer1 conda environment (see INSTALL.md). This warning can be ignored when running in the container." |
|
|
) |
|
|
|
|
|
print("Attempting to import critical packages...") |
|
|
|
|
|
packages = ["torch", "torchvision", "transformers", "megatron.core", "transformer_engine", "vllm", "pandas"] |
|
|
packages_training = [ |
|
|
"apex.multi_tensor_apply", |
|
|
] |
|
|
all_success = True |
|
|
|
|
|
check_packages(packages) |
|
|
if args.training: |
|
|
check_packages(packages_training) |
|
|
|
|
|
if all_success: |
|
|
print("-----------------------------------------------------------") |
|
|
print("\033[92m[SUCCESS]\033[0m Cosmos environment setup is successful!") |
|
|
|