终端

CUDA_VISIBLE_DEVICES=1,2

python程序

import os
CUDA='1,2'
os.environ['CUDA_VISIBLE_DEVICES']=CUDA
print('user gpu:',CUDA)

deepspeed

deepspeed --include="localhost:1,2"

如果指定了gpu_id,但却没有生效,可能是原来的代码库有config文件,需要在config文件中修改gpu_id

更多推荐