Change default GPU in TensorFlow

后端 未结 4 1891
情深已故
情深已故 2020-12-24 08:16

Based on the documentation, the default GPU is the one with the lowest id:

If you have more than one GPU in your system, the GPU with the lowest ID

4条回答
  •  孤独总比滥情好
    2020-12-24 08:57

    If you want to run your code on the second GPU,it assumes that your machine has two GPUs, You can do the following trick.

    1. open Terminal

    2. open tmux by typing tmux (you can install it by sudo apt-get install tmux)

    3. run this line of code in tmux: CUDA_VISIBLE_DEVICES=1 python YourScript.py

    Note: By default, tensorflow uses the first GPU, so with above trick, you can run your another code on the second GPU, separately.

    Hope it would be helpful!!

提交回复
热议问题