7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CUDAデバイスの選択方法

Last updated at Posted at 2022-11-25

CUDA_VISIBLE_DEVICESとは

複数のGPUを持った計算機の中で,使用したいGPUを指定したい場合に使用します.

方法1

コマンドプロンプト内でCUDA_VISIBLE_DEVICESを指定します.

CUDA_VISIBLE_DEVICES=0 python_name.py

方法2

プログラムファイル内(例:python)でCUDA_VISIBLE_DEVICESを指定します.

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

# 以下処理を記入

備考

GPUを複数使用したい場合はカンマ(,)を使用します.
方法1,方法2の両方で使用可能です.

方法1

CUDA_VISIBLE_DEVICES=0,1 python_name.py

方法2

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'

# 以下処理を記入
7
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?