"单卡内存不足,多卡的话,报错RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method。ModelScope中,修改了代码还是报错怎么解决? import os
import subprocess
import multiprocessing as mp
if name == 'main':
# 设置多处理的启动方法为'spawn'
mp.set_start_method('spawn')
# 设置环境变量
os.environ['CUDA_VISIBLE_DEVICES'] = '2,3,4,5'
os.environ['RAY_memory_monitor_refresh_ms'] = '0'
# 运行swift deploy命令
subprocess.run([
'swift', 'app-ui',
'--model_type', 'qwen2-7b',
'--infer_backend', 'vllm',
'--tensor_parallel_size', '4',
'--dtype', 'fp16'
]) 还是报错RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method"
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352