GithubHelp home page GithubHelp logo

mobimaliangsdk's Introduction


目录

  1. 安装步骤
  2. 模型下载
  3. 快速上手
  4. 线上摩笔马良

1. 安装步骤

1.1. 克隆项目

安装好 Ubuntu20.04 之后,在桌面点击鼠标右键,选择 New Folder 新建文件夹,命名为 mtai_workspace,双击文件夹进入

再次点击右键,选择 Open in Terminal 打开命令行,可以看到此时命令行前缀为:~/Desktop/mtai_workspace$ (如果系统语言为中文,则为 ~/桌面/mtai_workspace$,下同)

输入以下命令并回车,将会克隆项目并进入项目文件夹,此时命令行前缀变为:~/Desktop/mtai_workspace/MobiMaliangSDK$

git clone https://github.com/MooreThreads/MobiMaliangSDK;cd MobiMaliangSDK

1.2. 安装驱动

输入以下命令,将会安装驱动 musa_2.1.1-Ubuntu-dev_amd64.deb

sudo bash install_driver.sh

如果sudo要求输入用户密码则请输入;如果出现 Configuring lightdm 的UI,请将 Default display manager 选成 lightdm

如果看到类似以下的驱动信息,则说明驱动安装成功;如果显示器分辨率没有变得更大,最好重启以确保驱动生效

Package: musa
Status: install ok installed
Priority: optional
Section: graphics
Installed-Size: 258062
Maintainer: Moore Threads
Architecture: amd64
Version: 2.1.1-Ubuntu-dev
Replaces: mtsnd, mtgpu, musa-wine, musa_all-in-one, linux-firmware
Depends: libdrm2 (>= 2.4.99), lightdm, dkms
Conflicts: mtsnd, mtgpu, musa-wine, musa_all-in-one
Description: Moore Threads MUSA driver
Homepage: https://developer.mthreads.com/

1.3. 其他安装

如果重启了,请打开 MobiMaliangSDK 文件夹,点击右键,选择 Open in Terminal,以重新进入命令行,前缀为:~/Desktop/mtai_workspace/MobiMaliangSDK$

输入以下命令,以完成后续安装

sudo bash install.sh
以上安装文件将依次完成以下内容
sudo dpkg -i mtml_1.5.0.deb sgpu-dkms_1.1.1.deb mt-container-toolkit_1.5.0.deb
(cd /usr/bin/musa && sudo ./docker setup $PWD)

具体参考 摩尔线程容器运行时套件

  • 拉取 docker 镜像 registry.mthreads.com/mcconline/musa-pytorch-release-public:latest
sudo docker pull registry.mthreads.com/mcconline/musa-pytorch-release-public:latest

运行以下命令,创建容器 mtai_workspace

sudo docker run -id --name mtai_workspace --privileged -e MTHREADS_VISIBLE_DEVICES=all -p 1001:1001 -p 1002:1002 -p 1003:1003 -p 1004:1004 -p 1005:1005 -v ~/Desktop/mtai_workspace:/mtai_workspace:rw --shm-size 16G registry.mthreads.com/mcconline/musa-pytorch-release-public:latest

如果系统语言为中文,则运行以下命令

sudo docker run -id --name mtai_workspace --privileged -e MTHREADS_VISIBLE_DEVICES=all -p 1001:1001 -p 1002:1002 -p 1003:1003 -p 1004:1004 -p 1005:1005 -v ~/桌面/mtai_workspace:/mtai_workspace:rw --shm-size 16G registry.mthreads.com/mcconline/musa-pytorch-release-public:latest

输入以下命令,进入容器 mtai_workspace

sudo docker exec -it mtai_workspace /bin/bash

此时命令行前缀变成类似 (py38) root@xxxx,说明已经进入容器了,运行以下两行命令完成安装,其中第一行进入到项目目录,第二行完成容器内安装任务

cd /mtai_workspace/MobiMaliangSDK/
bash install_inside_docker.sh

1.4. 启动 WebUI

如果在容器外面,输入以下命令以进入容器

sudo docker exec -it mtai_workspace /bin/bash

如果已经在容器里了,输入以下命令,其中第一行进入到项目目录,第二行启动 WebUI 服务

cd /mtai_workspace/MobiMaliangSDK/
streamlit run frontend/main.py --server.port 1001

在浏览器地址中输入,localhost:1001 即可访问 WebUI,也可右键点击命令行中的 Network URL 并选择 Open Link

如果要停止 WebUI 服务,按 Ctrl + C 即可;停止服务后,如果要退出容器,输入 exit 即可

1.5. 常用 docker 命令

需要在容器外使用

  • sudo docker images -a:查看全部已下载的镜像
  • sudo docker ps -a:查看全部容器
  • sudo docker start container_name:启动名为 container_name 的容器
  • sudo docker stop container_name:停止名为 container_name 的容器

2. 模型下载

请您在使用推荐的模型前,仔细阅读并理解以下事宜:

  1. 推荐的模型为第三方软件或代码库,客户在下载使用推荐的模型时,需要了解并遵守该模型的用户协议或开源协议要求
  2. 如果您计划使用推荐的模型,请确保您的使用符合相应的用户协议或开源协议要求。某些开源协议可能对商业化使用有特定的限制或要求您公开源代码等。您需要自行承担了解和遵守这些规定的责任
  3. 公司不对推荐的模型作任何明示或暗示的保证或承诺。在使用这些模型时,您应自行承担风险和责任。公司不承担因使用这些模型而导致的任何直接或间接损失或损害

3. 快速上手

文生图
# python examples/example_txt2img.py --checkpoint_path <your model path> --prompt <your prompt> --output_path <result saved path>
python examples/example_txt2img.py --checkpoint_path models/Stable-diffusion/v1-5-pruned-emaonly.ckpt --prompt "A photo of an astronaut riding a horse on mars." --output_path outputs
图生图
# python examples/example_img2img.py --checkpoint_path <your model path> --image_path <your initial image path> --prompt <your prompt> --output_path <result saved path>
python examples/example_img2img.py --checkpoint_path models/Stable-diffusion/v1-5-pruned-emaonly.ckpt --image_path data/person.jpg --prompt "a pretty girl" --output_path outputs
边缘控制
# python examples/controlnets/example_canny2img.py --checkpoint_path <your model path> --canny_controlnet_path <your canny controlnet model path> --image_path <your image path> --prompt <your prompt> --output_path <result saved path>
python examples/controlnets/example_canny2img.py --checkpoint_path models/Stable-diffusion/v1-5-pruned-emaonly.ckpt --canny_controlnet_path models/controlnet/canny_v11 --image_path data/person.jpg --prompt "a pretty girl" --output_path outputs

更多的 controlnets 请移步 examples/controlnets 文件夹

LoRA 生图
# python examples/example_lora2img.py --checkpoint_path <your model path> --lora_path <your lora model path> --prompt <your prompt> --output_path <result saved path>
python examples/example_lora2img.py --checkpoint_path models/Stable-diffusion/v1-5-pruned-emaonly.ckpt --lora_path models/lora/moore_threads_lora.safetensors --prompt "a pretty girl" --output_path outputs
Text Inversion 生图
# python examples/example_textinversion2img.py --checkpoint_path <your model path> --text_inversion_path <your text inversion model path> --prompt <your prompt> --negative_prompt <your negative text inversion trigger word> --output_path <result saved path>
python examples/example_textinversion2img.py --checkpoint_path models/Stable-diffusion/v1-5-pruned-emaonly.ckpt --text_inversion_path models/text_embeddings/negative/moore_threads_easy_negative.safetensors --prompt "a pretty girl" --negative_prompt "moore_threads_easy_negative" --output_path outputs
图生文反推词
# python examples/example_tagger.py --checkpoint_path <your model path> --image_path <your image path>
python examples/example_tagger.py --checkpoint_path models/tools/deepbooru/model-resnet_custom_v3.pt --image_path data/person.jpg
超分
# python examples/example_super_resolution.py --checkpoint_path <your model path> --image_path <your image path> --output_path <result saved path>
python examples/example_super_resolution.py --checkpoint_path models/tools/realesrgan/RealESRGAN_x4plus.pth --image_path data/person.jpg --output_path outputs
中英翻译
# python examples/example_translator.py --checkpoint_path <your model path> --chinese_text <your Chinese text>
python examples/example_translator.py --checkpoint_path models/tools/zh2en --chinese_text "一个漂亮的小姑娘"

4. 线上摩笔马良

点击 链接,体验摩笔马良线上网站

或 扫描下方二维码,体验摩笔马良线上小程序

5. FAQ

如果您有任何问题,可以通过邮箱地址 [email protected] 与我们取得联系,我们将尽力解答您的问题

mobimaliangsdk's People

Contributors

honglunzhang-mt avatar yangshiyu-mt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mobimaliangsdk's Issues

关机后再打开时,需要重启容器

关机后再打开时,需要重启容器“mtai_workspace”(终端执行sudo docker start mtai_workspace)之后再按照README中1.4启动 WebUI步骤执行才能好用。

急需解决重启无法进入ubuntu

我安装的是ubunt20.04.6官方版(使用visualbox虚拟机) 在安装完回驱动后(按提示选择ligthdm显示管理器),按教程指导我重启后一直黑屏,屏幕左上角有光标闪烁。一开始以为是ligthdm有问题,后来但先安装ligthdm重启可以正常使用,再按照你们的教程还是在装完驱动(显示驱动是安装成功的)后重启还是进不去,屏幕黑屏左上角光标闪烁。苦于网上没有解决办法,希望能帮忙解决下。

"Connection refused" and "name 'ml' is not defined"

Ubuntu20.04.6 LTS
按照readme安装好,并且下载好模型参数放到正确位置之后,在docker内部启动时,报类似错误

(py38) root@a6eb6770f824:/mtai_workspace/MobiMaliangSDK# streamlit run frontend/main.py --server.port 1001

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:1001
  External URL: http://114.86.67.1:1001

The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.
0it [00:00, ?it/s]
We cannot import torch_musa
2024-03-31 21:38:05.595 Uncaught app exception
Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 263, in _get_or_create_cached_value
    cached_result = cache.read_result(value_key)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, in read_result
    raise CacheKeyNotFoundError()
streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 311, in _handle_cache_miss
    cached_result = cache.read_result(value_key)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, in read_result
    raise CacheKeyNotFoundError()
streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mtai_workspace/MobiMaliangSDK/modules/shared.py", line 71, in load_models
    pipe = StableDiffusionPipeline.from_single_file(
  File "/mtai_workspace/MobiMaliangSDK/modules/hijack/load_from_single_file.py", line 192, in from_single_file
    pipe = download_from_original_stable_diffusion_ckpt(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1236, in download_from_original_stable_diffusion_ckpt
    original_config = OmegaConf.load(original_config_file)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 189, in load
    with io.open(os.path.abspath(file_), "r", encoding="utf-8") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/mtai_workspace/MobiMaliangSDK/models/Stable-diffusion/v1-inference.yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 200, in _new_conn
    sock = connection.create_connection(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
    conn.connect()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 604, in connect
    self.sock = sock = self._new_conn()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 215, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 476, in <module>
    ml = load_ckpt()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 211, in wrapper
    return cached_func(*args, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 240, in __call__
    return self._get_or_create_cached_value(args, kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 266, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 320, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 86, in load_ckpt
    ml.load_models(path, diffusers_format=os.path.isdir(path))
  File "/mtai_workspace/MobiMaliangSDK/modules/shared.py", line 78, in load_models
    pipe = StableDiffusionPipeline.from_single_file(
  File "/mtai_workspace/MobiMaliangSDK/modules/hijack/load_from_single_file.py", line 192, in from_single_file
    pipe = download_from_original_stable_diffusion_ckpt(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1234, in download_from_original_stable_diffusion_ckpt
    original_config_file = BytesIO(requests.get(config_url).content)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused'))

此时在网页端更换模型的话,会报如下错误

2024-03-31 21:38:23.568 Uncaught app exception
Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 548, in _run_script
    self._session_state.on_script_will_rerun(rerun_data.widget_states)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/safe_session_state.py", line 68, in on_script_will_rerun
    self._state.on_script_will_rerun(latest_widget_states)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 484, in on_script_will_rerun
    self._call_callbacks()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 497, in _call_callbacks
    self._new_widget_state.call_callback(wid)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 249, in call_callback
    callback(*args, **kwargs)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 109, in switch_ckpt
    ml.offload_models()
NameError: name 'ml' is not defined

应该是因为网络不好导致对raw.githubusercontent.com的DNS解析失败。
关掉服务,在docker内部编辑/etc/host,在最下边加入一行

185.199.111.133 raw.githubusercontent.com

再重新启动服务就正常了。
但是我这还有另外的问题。成功启动服务之后会报无法import torch_musa

(py38) root@a6eb6770f824:/mtai_workspace/MobiMaliangSDK# streamlit run frontend/main.py --server.port 1001

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:1001
  External URL: http://114.86.67.1:1001

We cannot import torch_musa

求解决。驱动用的是SDK中自带的。

ComfyUI-Musa 作者已停更,能否请官方出手做个适配?

事情是这样的,依照官方教程可以顺利在Ubuntu 20.04运行,只是有几个问题:
1、 全新安装后,Ubuntu会自动升级内核到5.15-113版本,安装驱动后是无法自动进入桌面的。需要在恢复模式中进入系统,原因不明。但是好在能进入;
2、 启动mtai_workspace容器并且进入容器后运行容器内的安装脚本安装完成环境,可以顺利使用ComfyUI-Musa,但是有很多局限,比如torch-musa的版本滞后了一些,很多插件无法使用;
3、 最主要的是ComfyUI-Musa本身已经停更,联系作者回复不会再更新;( 能否请摩尔线程的技术大佬出面做个官方版本的产品?据作者说他当初一晚上就做好可以运行……或者出个文档也可以,有一样需求的用户可以自行修改。谢谢啊!

补充一点,在摩笔马良中选择任何SDXL模型都会报错:

Traceback (most recent call last):
File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 548, in _run_script
self._session_state.on_script_will_rerun(rerun_data.widget_states)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/safe_session_state.py", line 68, in on_script_will_rerun
self._state.on_script_will_rerun(latest_widget_states)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 484, in on_script_will_rerun
self._call_callbacks()
File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 497, in _call_callbacks
self._new_widget_state.call_callback(wid)
File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 249, in call_callback
callback(*args, **kwargs)
File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 112, in switch_ckpt
ml.load_models(path, diffusers_format=os.path.isdir(path))
File "/mtai_workspace/MobiMaliangSDK/modules/shared.py", line 128, in load_models
self.feature_extractor = pipe.feature_extractor
File "/opt/conda/envs/py38/lib/python3.8/site-packages/diffusers/configuration_utils.py", line 137, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'StableDiffusionXLPipeline' object has no attribute 'feature_extractor'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.