方法1: import os os.environ["CUDA_VISIBLE_DEVICES"] = "1" #使用1号 方法2:手动敲入 CUDA_VISIBLE_DEVICES=0 python your_script.py