Sysops Notepad

[Linux,linux] Centos Multi GPU 환경에서 특정 GPU만 사용하기 본문

업무/dev

[Linux,linux] Centos Multi GPU 환경에서 특정 GPU만 사용하기

sysops 2019. 2. 20. 11:23


1. Terminal에서 python code를 실행하는 방법


$ CUDA_VISIBLE_DEVICES=0 python test1.py  # Uses GPU 0.

$ CUDA_VISIBLE_DEVICES=1 python test2.py  # Uses GPU 1.

$ CUDA_VISIBLE_DEVICES=2,3 python test3.py  # Uses GPUs 2 and 3.


or 


2. python code 추가하는 방법

import os

os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"   

os.environ["CUDA_VISIBLE_DEVICES"]="0"



참고:

https://stackoverflow.com/questions/34775522/tensorflow-multiple-sessions-with-multiple-gpus

https://stackoverflow.com/questions/37893755/tensorflow-set-cuda-visible-devices-within-jupyter

Comments