在Windows cmd上,这个Linux命令的等价物是什么?

时间:2018-04-09 14:44:38

标签: python tensorflow

此命令在运行之前为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上执行此操作?

2 个答案:

答案 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

  1. on the command line you can use the following command

    set TF_CUDNN_USE_AUTOTUNE=0 CUDA_VISIBLE_DEVICES=1 & python demo\singleperson.py

  2. 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