此命令在运行之前为python脚本设置环境变量(" CUDA_VISIBLE_DEVICES")。
$ CUDA_VISIBLE_DEVICES=2,3 python my_script.py # Uses GPUs 2 and 3.
它在Linux机器上工作正常,但在Windows上,它说
'CUDA_VISIBLE_DEVICES' is not recognized as an internal or external command
是否可以在不改变python脚本的情况下在Windows上执行此操作?
答案 0 :(得分:1)
只需在Windows上运行一个班轮:
set CUDA_VISIBLE_DEVICES=2,3 & python my_script.py
答案 1 :(得分:0)
For windows, this worked for me too, thanks to Adonis. you have two options
on the command line you can use the following command
set TF_CUDNN_USE_AUTOTUNE=0 CUDA_VISIBLE_DEVICES=1 & python demo\singleperson.py
on the main python file, put the following lines, below import things
import os
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="1"
then run the python file on the command line
python demo\singleperson.py