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

问题描述 投票:-1回答:2

此命令在运行之前为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

是否可以在Windows上执行此操作而不更改python脚本?

python tensorflow
2个回答
2
投票

对于只需在Windows上运行的一个班轮:

set CUDA_VISIBLE_DEVICES=2,3 & python my_script.py

0
投票

对于Windows来说,这也适用于我,感谢Adonis。你有两个选择

  1. 在命令行上,您可以使用以下命令 设置TF_CUDNN_USE_AUTOTUNE = 0 CUDA_VISIBLE_DEVICES = 1&python demo \ singleperson.py
  2. 在主python文件中,放下以下行,下面导入东西 import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"]="1"

然后在命令行上运行python文件

python demo\singleperson.py
© www.soinside.com 2019 - 2024. All rights reserved.