Ubuntu 命令行中用 GPU 运行 Python 程序

转载:https://blog.csdn.net/yueyinlizun/article/details/80402503

在终端执行 Python 程序时可以使用下面的命令:

CUDA_VISIBLE_DEVICES=1 python your_file.py

这样在跑你的网络之前,告诉程序只能看到1号GPU,其他的GPU它不可见

可用的形式如下:

CUDA_VISIBLE_DEVICES=1          # Only device 1 will be seen 
CUDA_VISIBLE_DEVICES=0,1       # Devices 0 and 1 will be visible 
CUDA_VISIBLE_DEVICES=”0,1”     # Same as above, quotation marks are optional 
CUDA_VISIBLE_DEVICES=0,2,3     # Devices 0, 2, 3 will be visible; device 1 is masked 
CUDA_VISIBLE_DEVICES=”“           # No GPU will be visible

参考文献:ubuntu 16.04上运行tensor flow 指定gpu

猜你喜欢

转载自blog.csdn.net/m0_37870649/article/details/81589526