modal-labs / modal-client

Python client library for Modal
https://modal.com/docs
Apache License 2.0
281 stars 38 forks source link

[bug] run_function in image build does not recognize installed libraries. #1282

Closed risto-trajanov closed 9 months ago

risto-trajanov commented 9 months ago

Installing collected packages: pytz, mpmath, xxhash, urllib3, tzdata, tqdm, sympy, safetensors, regex, pyyaml, python-dateutil, pyarrow-hotfix, pyarrow, nvidia-nvtx-cu12, nvidia-nvjitlink-cu12, nvidia-nccl-cu12, nvidia-curand-cu12, nvidia-cufft-cu12, nvidia-cuda-runtime-cu12, nvidia-cuda-nvrtc-cu12, nvidia-cuda-cupti-cu12, nvidia-cublas-cu12, networkx, MarkupSafe, fsspec, filelock, dill, triton, requests, pandas, nvidia-cusparse-cu12, nvidia-cudnn-cu12, multiprocess, jinja2, nvidia-cusolver-cu12, huggingface-hub, torch, tokenizers, datasets, transformers Successfully installed MarkupSafe-2.1.5 datasets-2.16.1 dill-0.3.7 filelock-3.13.1 fsspec-2023.10.0 huggingface-hub-0.20.3 jinja2-3.1.3 mpmath-1.3.0 multiprocess-0.70.15 networkx-3.2.1 nvidia-cublas-cu12-12.1.3.1 nvidia-cuda-cupti-cu12-12.1.105 nvidia-cuda-nvrtc-cu12-12.1.105 nvidia-cuda-runtime-cu12-12.1.105 nvidia-cudnn-cu12-8.9.2.26 nvidia-cufft-cu12-11.0.2.54 nvidia-curand-cu12-10.3.2.106 nvidia-cusolver-cu12-11.4.5.107 nvidia-cusparse-cu12-12.1.0.106 nvidia-nccl-cu12-2.19.3 nvidia-nvjitlink-cu12-12.3.101 nvidia-nvtx-cu12-12.1.105 pandas-2.2.0 pyarrow-15.0.0 pyarrow-hotfix-0.6 python-dateutil-2.8.2 pytz-2024.1 pyyaml-6.0.1 regex-2023.12.25 requests-2.31.0 safetensors-0.4.2 sympy-1.12 tokenizers-0.15.1 torch-2.2.0 tqdm-4.66.1 transformers-4.37.2 triton-2.2.0 tzdata-2023.4 urllib3-2.2.0 xxhash-3.4.1 Creating image snapshot... Finished snapshot; took 3.81s

Built image im-MeTE9VNGYc3zv0jVDE2gfu in 123.36s Building image im-uzlYYTpnBZgZgSKxtdLNk7

=> Step 0: running function 'download_model_to_folder' Traceback (most recent call last): File "/pkg/modal/_container_entrypoint.py", line 372, in handle_input_exception yield File "/pkg/modal/_container_entrypoint.py", line 530, in run_inputs res = imp_fun.fun(*args, **kwargs) File "/root/summary.py", line 12, in download_model_to_folder from transfromers import pipeline ModuleNotFoundError: No module named 'transfromers' Creating image snapshot... Finished snapshot; took 1.12s Finished image build for im-uzlYYTpnBZgZgSKxtdLNk7 Stopping app - uncaught exception raised locally: RemoteError('Image build for im-uzlYYTpnBZgZgSKxtdLNk7 failed with the exception:\nModuleNotFoundError("No module named \'transfromers\'")').

my code:

import os
import time

from modal import Image, Stub, gpu, method, Volume

MODEL_DIR = "/model"
BASE_MODEL = "knkarthick/MEETING_SUMMARY"
TASK = 'summarization'
GPU_CONFIG = gpu.L4()

def download_model_to_folder():
    from transfromers import pipeline

    # Download the model to the model directory
    nlp = pipeline(TASK, model=BASE_MODEL)

    nlp.save_pretrained(MODEL_DIR)
    print(f"Model saved to {MODEL_DIR}")

summary_image = (
    Image.from_registry(
        "nvidia/cuda:12.1.0-base-ubuntu22.04", add_python="3.10"
    )
    .pip_install("torch", "transformers", "datasets", "tqdm")
    .run_function(download_model_to_folder, timeout=60 * 20)
)

...
mwaskom commented 9 months ago

Hi: looks like a simple typo, “transfromers”