Files
modelscope/docker/Dockerfile.ubuntu

99 lines
5.0 KiB
Docker
Raw Permalink Normal View History

2024-10-21 18:26:23 +08:00
FROM {base_image}
2024-10-21 18:26:23 +08:00
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
ENV arch=x86_64
COPY docker/scripts/modelscope_env_init.sh /usr/local/bin/ms_env_init.sh
2024-10-21 18:26:23 +08:00
RUN apt-get update && \
2026-01-15 20:33:27 +08:00
apt-get install -y libsox-dev unzip libaio-dev zip iputils-ping telnet sudo git net-tools zstd libzstd-dev && \
2024-10-21 18:26:23 +08:00
apt-get clean && \
rm -rf /var/lib/apt/lists/*
2024-10-21 18:26:23 +08:00
{extra_content}
2024-10-21 18:26:23 +08:00
COPY {meta_file} /tmp/install.sh
ARG INSTALL_MS_DEPS={install_ms_deps}
ARG IMAGE_TYPE={image_type}
2025-04-23 13:40:54 +08:00
# install dependencies
COPY requirements /var/modelscope
RUN pip uninstall ms-swift modelscope -y && pip --no-cache-dir install pip==23.* -U && \
2024-11-08 10:56:39 +08:00
if [ "$INSTALL_MS_DEPS" = "True" ]; then \
pip --no-cache-dir install omegaconf==2.0.6 && \
2025-04-07 13:32:09 +08:00
pip install 'editdistance==0.8.1' && \
pip install --no-cache-dir 'cython>=3.0' versioneer 'numpy>=2.0' && \
2026-03-09 14:21:38 +08:00
pip install --no-cache-dir -r /var/modelscope/framework.txt && \
pip install --no-cache-dir -r /var/modelscope/audio.txt -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html && \
2026-03-09 14:21:38 +08:00
pip install --no-cache-dir -r /var/modelscope/tests.txt && \
pip install --no-cache-dir -r /var/modelscope/server.txt && \
2024-11-06 20:40:58 +08:00
pip install --no-cache-dir https://modelscope.oss-cn-beijing.aliyuncs.com/packages/imageio_ffmpeg-0.4.9-py3-none-any.whl --no-dependencies --force && \
pip install --no-cache-dir 'scipy' && \
2024-11-08 10:56:39 +08:00
pip install --no-cache-dir funtextprocessing typeguard==2.13.3 scikit-learn -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html && \
pip install --no-cache-dir 'decord>=0.6.0' mpi4py paint_ldm ipykernel fasttext -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html && \
pip install --no-cache-dir ipywidgets && \
2025-04-07 13:32:09 +08:00
pip install --no-cache-dir 'blobfile>=1.0.5' && \
pip uninstall MinDAEC -y && \
pip install https://modelscope.oss-cn-beijing.aliyuncs.com/releases/dependencies/MinDAEC-0.0.2-py3-none-any.whl && \
pip cache purge; \
else \
2026-03-09 14:21:38 +08:00
pip install --no-cache-dir -r /var/modelscope/framework.txt && \
2024-11-08 10:56:39 +08:00
pip cache purge; \
fi
2025-02-17 10:30:24 +08:00
ARG CUR_TIME={cur_time}
RUN echo $CUR_TIME
RUN bash /tmp/install.sh {version_args} && \
2024-11-08 18:09:05 +08:00
pip install --no-cache-dir -U funasr scikit-learn && \
pip install --no-cache-dir -U qwen_vl_utils qwen_omni_utils librosa timm transformers accelerate peft trl safetensors && \
2024-11-07 13:58:08 +08:00
cd /tmp && GIT_LFS_SKIP_SMUDGE=1 git clone -b {swift_branch} --single-branch https://github.com/modelscope/ms-swift.git && \
cd ms-swift && pip install .[llm] && \
pip install .[eval] && pip install evalscope -U --no-dependencies && \
pip install --no-cache-dir "numpy>=2.0" --force-reinstall --no-deps && \
pip install ms-agent -U --no-dependencies && \
2024-11-08 10:56:39 +08:00
cd / && rm -fr /tmp/ms-swift && pip cache purge; \
2025-08-18 13:51:00 +08:00
cd /tmp && GIT_LFS_SKIP_SMUDGE=1 git clone -b {modelscope_branch} --single-branch https://github.com/modelscope/modelscope.git && \
cd modelscope && pip install . -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html && \
cd / && rm -fr /tmp/modelscope && pip cache purge; \
2024-11-07 13:58:08 +08:00
pip install --no-cache-dir torch=={torch_version} torchvision=={torchvision_version} torchaudio=={torchaudio_version} {index_url} && \
pip install --no-cache-dir transformers diffusers 'timm>=0.9.0' && pip cache purge; \
2025-04-23 13:40:54 +08:00
pip install --no-cache-dir omegaconf==2.3.0 && pip cache purge; \
2024-11-07 13:58:08 +08:00
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple && \
[Feat & Refactor] Refactor hub and CLI modules (#1732) * refactor(hub): shim layer delegating to modelscope-hub - Replace hub/api.py (4674→250 lines) with shim inheriting LegacyHubApi - Replace hub/snapshot_download.py, callback.py with thin shims - Partial shim hub/file_download.py (retain http_get_file) - Shim hub/constants.py and errors.py with legacy aliases - Shim hub/git.py, repository.py, cache_manager.py, upload_*.py - Migrate CLI entry to modelscope_hub.cli.main:run_cmd - Adapt 6 CLI commands as modelscope_hub.cli_plugins - Delete redundant CLI files (download/upload/login/create/etc) - Add modelscope-hub>=0.2.0 dependency, Python>=3.10 - Add __getattr__ proxy for forward-compatible method access - Propagate timeout/max_retries to internal LegacyClient - Bridge MODELSCOPE_CREDENTIALS_PATH env var to HubConfig * fix lint: isort/yapf formatting + exclude hub/api.py from hooks * set modelscope-hub>=0.0.5 * remove unused code * refactor(hub): standardize token naming — git_token vs token Disambiguate git token and SDK/API token naming across the hub layer: - ModelScopeConfig: get_token/save_token → get_git_token/save_git_token (old names kept as deprecated aliases with DeprecationWarning) - GitCommandWrapper: rename token params to git_token in clone/push/config - Repository/DatasetRepository: auth_token → git_token (deprecated compat kept) - data_loader.py: update caller to use get_git_token() SDK token references (HubApi(token=...), get_cookies(access_token=...), commit_scheduler.token) remain unchanged as they correctly use `token` naming. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * remove(msdatasets): remove all Virgo-related implementation Remove the entire Virgo dataset subsystem which is no longer needed: - Remove VirgoDataset class and VirgoDownloader - Remove VirgoAuthConfig and VirgoDatasetConfig - Remove Hubs.virgo enum value - Remove fetch_virgo_meta from DataMetaManager - Remove download_virgo_files from DatasetContextConfig - Remove test_virgo_dataset.py test file - Clean up unused imports (pandas, MaxComputeUtil, valid_url, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(hub): add OSS dataset operations and meta-file download to HubApi Add methods that msdatasets depends on but don't belong in modelscope_hub: - _legacy_request: internal helper combining legacy HTTP transport with application-level envelope validation (Code/Data/Message) - list_oss_dataset_objects: list OSS storage objects for a dataset - delete_oss_dataset_object / delete_oss_dataset_dir: delete OSS objects - fetch_meta_files_from_url: download and cache meta CSV/JSONL files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix imports issue * fix: address PR review feedback - cli/plugins.py: change --yes and --all flags to action='store_true' - hub/git.py: replace os.linesep with .splitlines() for cross-platform safety - hub/__init__.py: use is_file() with fallback for robust credentials path detection * fix lint * update ms hub version * fix(ci): add PyPI official as fallback index for pip Aliyun mirror may lag behind PyPI for newly published packages, causing dependency resolution failures (e.g. modelscope-hub>=0.0.6). Add pypi.org/simple as extra-index-url so new versions are immediately available while keeping the Aliyun mirror as the primary source. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix UTs * remove unused UTs * fix ut * update modelscope-hub installation for source code * fix UT * fix uts * fix ut --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-09 20:00:20 +08:00
pip config set global.extra-index-url https://pypi.org/simple && \
pip config set install.trusted-host mirrors.aliyun.com && \
cp /tmp/resources/ubuntu2204.aliyun /etc/apt/sources.list
2025-04-23 13:40:54 +08:00
2026-03-09 14:21:38 +08:00
RUN if [ "$IMAGE_TYPE" = "gpu" ]; then \
2026-05-10 18:00:21 +08:00
pip install --no-cache-dir math_verify "gradio<5.33" "deepspeed<0.19" ray -U && \
pip install --no-cache-dir mcore-bridge -i https://pypi.org/simple/ -U && \
pip install --no-cache-dir liger_kernel wandb swanlab nvitop pre-commit "transformers<5.9" "trl<1.0" "peft<0.20" huggingface-hub -U && \
2026-03-09 14:21:38 +08:00
pip install --no-cache-dir --no-build-isolation transformer_engine[pytorch]; \
2025-04-23 13:40:54 +08:00
cd /tmp && GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/NVIDIA/apex && \
2026-03-09 14:21:38 +08:00
cd apex && pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" ./ && \
2025-04-23 13:40:54 +08:00
cd / && rm -fr /tmp/apex && pip cache purge; \
2026-05-10 18:00:21 +08:00
pip install --no-cache-dir "megatron-core==0.16.*" -U; \
2026-03-09 14:21:38 +08:00
elif [ "$IMAGE_TYPE" = "cpu" ]; then \
2026-05-21 16:27:12 +08:00
pip install --no-cache-dir huggingface-hub "transformers<5.9" peft diffusers -U; \
else \
2026-03-09 14:21:38 +08:00
pip install "transformers<5.0" "tokenizers<0.22" "trl<0.23" "diffusers<0.35" --no-dependencies; \
2025-04-23 13:40:54 +08:00
fi
2025-02-19 18:11:23 +08:00
# install nvm and set node version to 18
ENV NVM_DIR=/root/.nvm
2025-08-04 17:08:48 +08:00
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \
. $NVM_DIR/nvm.sh && \
nvm install 22 && \
nvm use 22
RUN rm -f /etc/apt/sources.list.d/cuda-*.list && apt-get update
ENV VLLM_USE_MODELSCOPE=True
ENV LMDEPLOY_USE_MODELSCOPE=True
2025-02-07 17:31:32 +08:00
ENV MODELSCOPE_CACHE=/mnt/workspace/.cache/modelscope/hub
SHELL ["/bin/bash", "-c"]