mirror of
https://github.com/deepseek-ai/DeepSeek-VL2.git
synced 2026-11-05 01:07:23 +00:00
[GH-ISSUE #132] Running Inference on Multiple GPU #111
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-VL2#111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Mukil07 on GitHub (Apr 24, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-VL2/issues/132
Im trying to run the Deepseek-vl2 on 2 A6000 GPUs (48GB). When I modify the model loading from,
to,
Its throwing error that tensors should be in the same device;
Please let me know if there is a way to run the multigpu inference. I have already tried the method split_model function in an earlier issue, but still didnt work.
@deadpipe commented on GitHub (May 15, 2025):
try:
@1215thebqtic commented on GitHub (Jun 3, 2025):
Hi, I'm using V100 to do the inference. And I use the code you provided, it reports error below, how can I solve this? thanks!
code
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3,4'
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"
vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(
model_path,
trust_remote_code=True,
torch_dtype=torch.float32,
device_map="auto",
offload_state_dict=True,
max_memory={0: "28GIB", 1: "28GIB", 2: "28GIB", 3: "28GIB", 4: "28GIB", "cpu": "40GIB"},
)
#vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
vl_gpt = vl_gpt.to(torch.float32).cuda().eval()
error
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:27<00:00, 6.81s/it]
huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...
To disable this warning, you can either:
- Avoid using
tokenizersbefore the fork if possible- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)
You shouldn't move a model that is dispatched using accelerate hooks.
Traceback (most recent call last):
File "run_infer.py", line 31, in
vl_gpt = vl_gpt.to(torch.float32).cuda().eval()
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/accelerate/big_modeling.py", line 457, in wrapper
return fn(*args, **kwargs)
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/transformers/modeling_utils.py", line 2528, in cuda
return super().cuda(*args, **kwargs)
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 905, in cuda
return self._apply(lambda t: t.cuda(device))
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 797, in _apply
module._apply(fn)
[Previous line repeated 5 more times]
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 820, in _apply
param_applied = fn(param)
File "/mnt/software/miniconda/miniconda3.8/envs/deepseekvl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 905, in
return self._apply(lambda t: t.cuda(device))
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 12.00 MiB (GPU 0; 31.73 GiB total capacity; 31.30 GiB already allocated; 2.44 MiB free; 31.37 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
@deadpipe commented on GitHub (Jun 3, 2025):
@1215thebqtic
Remove .cuda() as you have already dispatched the model using accelerate hooks
Use
vl_gpt = vl_gpt.eval()if the issue still persists, pass
device_map="sequential"