26
15

More than 3 years have passed since last update.

Colab Proを日本から登録する

Last updated at Posted at 2020-06-06

Colab Proを使う

普段、google coraboratoryを使っていますが、ソースデーターが大きすぎたり、レイヤーが重なりすぎて処理が思いと動かないことがあります。そんなときは、proバージョンを使うという選択肢があるようです。

登録の方法

現在、米国限定のサービスのようですが、日本からでも登録ができました。
このページにアクセスし、自分のgoogleアカウントでログインして、クレジットカード(日本の住所登録のもの)と米国の郵便番号(仮にロスアンゼルス90001を入れてみた)を入れたところ、無事登録できました。

登録が完了すると、自分のgoogleアカウントのgoogle colaboratoryが、自動的にPRO版に変わります。

Colab Proのメリットとデメリット

Colab Proのメリットとデメリットについては、こちらに整理した記事がありました。
https://qiita.com/kurilab/items/c58226bcb6150d50b618

  • 24時間以上続けて走らせることができ、タイムアウトしにくい。
  • 大量のメモリを使用できる。
  • 高性能GPUをずっと割り当ててもらえる。

などです。

CPUのスペック確認

!cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 63
model name  : Intel(R) Xeon(R) CPU @ 2.30GHz
stepping    : 0
microcode   : 0x1
cpu MHz     : 2300.000
cache size  : 46080 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear arch_capabilities
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips    : 4600.00
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 63
model name  : Intel(R) Xeon(R) CPU @ 2.30GHz
stepping    : 0
microcode   : 0x1
cpu MHz     : 2300.000
cache size  : 46080 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear arch_capabilities
bugs        : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
bogomips    : 4600.00
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

GPUのスペック確認

Tesla-P100、メモリーが16G、割当されていました。

!nvidia-smi 
Sat Jun  6 10:46:51 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.82       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| 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 P100-PCIE...  Off  | 00000000:00:04.0 Off |                    0 |
| N/A   33C    P0    25W / 250W |      0MiB / 16280MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

パフォーマンス比較

ローカルのマシン(Macbook-Pro 16inch)とパフォーマンスを比べてみました。
当方のマシンのスペックは、

CPU Core i9 8-Core 2.3GHz
AMD Radion Pro 5500M
GPU Memory 4Gb

下記のKerasのmnistのサンプルを走らせてみました。一応、PlaidMLを入れていたので、PlaidMLのパフォーマンスの比較もしました。

# PlaidMLを使用する場合は、下記二行のコメントをはずしてください。
# import plaidml.keras
# plaidml.keras.install_backend()

from keras.datasets import mnist
from keras.utils import to_categorical
from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
from keras import models
import time

model = models.Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(Flatten())
model.add(Dense(64, activation='relu'))
model.add(Dense(10, activation='softmax'))
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
train_images = train_images.reshape((60000, 28, 28, 1))
train_images = train_images.astype('float32') / 255
test_images = test_images.reshape((10000, 28, 28, 1))
test_images = test_images.astype('float32') / 255
train_labels = to_categorical(train_labels)
test_labels = to_categorical(test_labels)
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
start = time.time()

model.fit(train_images, train_labels, epochs=10, batch_size=64)
elapsed_time = time.time() - start
test_loss, test_acc = model.evaluate(test_images, test_labels)

print(elapsed_time)

結果

やはりColab Pro(GPU)が最も早かったです。普通にローカルのCPUで走らせた場合と比べて約5倍のパフォーマンスが出ていました。PlaidMLを経由してMacでGPU(AMD Radion Pro 5500M)を走らせた場合の3倍くらいのパフォーマンスが出ていることになります。これで月10ドルなら安い?

1 Google Colab Pro(GPU) = 41s
2 Google Colaboratory(GPU) = 46s
3 PlaidML AMD-OpenCL = 150s

4 CPU(default) = 186s
5 Google Colaboratory(CPU) = 470s
6 PlaidML lvml-CPU = 1520s

以上。

26
15
1

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
26
15