0
0

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 5 years have passed since last update.

GCP TerraformからGCEインスタンスをGPUありで立ち上げる

Last updated at Posted at 2018-04-17

検索しても、見つけにくかったのでメモ

tfファイルのに以下のように記述するとOKでした
今回は台湾リージョン[asia-east1]を選択
リージョンによりサポートされるtypeは異なるのかもしれません

下記schedulingも必須です、TERMINATEにしないとエラーが出ました
(ライブマイグレーションではないから?)

  guest_accelerator {
    type = "nvidia-tesla-k80"
    count = 1
  }
  scheduling {
    on_host_maintenance = "TERMINATE"
  }

tfファイル全体例(インスタンスに関する部分のみ)

resource "google_compute_instance" "gpu11" {
  name         = "gpu11"
  machine_type = "n1-standard-4"
  # zone         = "asia-east1-a"
  zone         = "${var.region_zone}"
  tags         = ["testserver", "backend"]

  guest_accelerator {
    type = "nvidia-tesla-k80"
    count = 1
  }
  scheduling {
    on_host_maintenance = "TERMINATE"
  }

  boot_disk {
    initialize_params {
      size  = 500
      type = "pd-standard"
      image = "ubuntu-1604-lts"
    }
  }

  # proisionerを使っているので未使用
  #metadata_startup_script = "${file("shells/startup.sh")}"

  network_interface {
    network = "default"
    # address    = "192.168.10.2"
    # subnetwork = "${google_compute_subnetwork.subnet1.name}"
    access_config {
      # static external ip
      nat_ip   = "${google_compute_address.gpu11.address}"
    }
  }

  metadata {
    "block-project-ssh-keys" = "true"
    "sshKeys" = "${var.ssh_keys}"
  }
}
  • gcpでのgpuドライバとツールのインストールについて

  • gpuの状態を表示してくれるコマンド
$ nvidia-smi
Tue Apr 17 01:04:02 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48                 Driver Version: 390.48                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00000000:00:04.0 Off |                    0 |
| N/A   29C    P8    29W / 149W |     16MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1769      G   /usr/lib/xorg/Xorg                            15MiB |
+-----------------------------------------------------------------------------+
  • topのように更新しながら表示するには
watch -n 0.5 nvidia-smi
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?