個人のパブリックアカウント
マシンのGPU使用状況を表示する
定期的な更新では、マシンのGPUの状態が表示され、#10秒に1回更新されます
nvidia-smi -l 10
ビデオメモリに動的に適用する
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
GPUの使用を制限する
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4 #占用40%显存
session = tf.Session(config=config)
使用する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
Pythonで設定する
os.environ['CUDA_VISIBLE_DEVICES'] = '0' #使用 GPU 0
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' # 使用 GPU 0,1