第23章付録:深層学習のための道具
23.3.1. Creating and Running an EC2 Instance23.3.1 EC2のインスタンスを作って実行する
After logging into your AWS account, click “EC2” (Fig. 23.3.1) to go to the EC2 panel.
英語のヒント
AWSのアカウントにログインしたら、「EC2」をクリックして(図23.3.1)EC2のパネルに行く。

Fig. 23.3.1図23.3.1
Open the EC2 console.
英語のヒント
EC2のコンソールを開く。

Fig. 23.3.2図23.3.2
The EC2 panel.
英語のヒント
EC2のパネル。
23.3.1.1. Presetting Location23.3.1.1 場所をあらかじめ設定する
Select a nearby data center to reduce latency, e.g., “Oregon” (marked by the red box in the top-right of Fig. 23.3.2). If you are located in China, you can select a nearby Asia Pacific region, such as Seoul or Tokyo. Please note that some data centers may not have GPU instances.
英語のヒント
遅延を減らすため、近くのデータセンター、たとえば「Oregon」(図23.3.2の右上の赤い枠で示した)を選ぶ。中国にいるなら、ソウルや東京のような近くのアジアパシフィックのリージョンを選べる。データセンターによってはGPUのインスタンスがないかもしれないことに注意しよう。
23.3.1.2. Increasing Limits23.3.1.2 上限を引き上げる
Before choosing an instance, check if there are quantity restrictions by clicking the “Limits” label in the bar on the left as shown in Fig. 23.3.2. Fig. 23.3.3 shows an example of such a limitation. The account currently cannot open “p2.xlarge” instances according to the region. If you need to open one or more instances, click on the “Request limit increase” link to apply for a higher instance quota. Generally, it takes one business day to process an application.
英語のヒント

Fig. 23.3.3図23.3.3
Instance quantity restrictions.
英語のヒント
インスタンスの数量の制限。
23.3.1.3. Launching an Instance23.3.1.3 インスタンスを起動する
Next, click the “Launch Instance” button marked by the red box in Fig. 23.3.2 to launch your instance.
英語のヒント
次に、図23.3.2の赤い枠で示した「Launch Instance」ボタンをクリックして、インスタンスを起動する。
We begin by selecting a suitable Amazon Machine Image (AMI). Select an Ubuntu instance (Fig. 23.3.4).
英語のヒント
まず、適したAmazon Machine Image(AMI)を選ぶ。Ubuntuのインスタンスを選ぶ(図23.3.4)。

Fig. 23.3.4図23.3.4
Choose an AMI.
英語のヒント
AMIを選ぶ。
EC2 provides many different instance configurations to choose from. This can sometimes feel overwhelming to a beginner.
tab_ec2 lists different suitable machines.英語のヒント
EC2では、選べるさまざまなインスタンスの構成が用意されている。初心者には圧倒されるように感じられることもある。
tab_ec2に、適したさまざまなマシンを挙げる。:Different EC2 instance types
英語のヒント
:さまざまなEC2インスタンスの種類
| Name名前 | GPUGPU | Notes備考 |
|---|---|---|
| g2g2 | Grid K520Grid K520 | ancientとても古い |
| p2p2 | Kepler K80Kepler K80 | old but often cheap as spot古いが、スポットインスタンスならたいてい安い |
| g3g3 | Maxwell M60Maxwell M60 | good trade-offバランスがよい |
| p3p3 | Volta V100Volta V100 | high performance for FP16FP16で高性能 |
| p4p4 | Ampere A100Ampere A100 | high performance for large-scale training大規模な訓練で高性能 |
| g4g4 | Turing T4Turing T4 | inference optimized FP16/INT8推論向けに最適化(FP16/INT8) |
All these servers come in multiple flavors indicating the number of GPUs used. For example, a p2.xlarge has 1 GPU and a p2.16xlarge has 16 GPUs and more memory. For more details, see the AWS EC2 documentation or a summary page. For the purpose of illustration, a p2.xlarge will suffice (marked in the red box of Fig. 23.3.5).
英語のヒント
これらのサーバにはどれも、使われるGPUの数を表す複数の種類がある。たとえば、p2.xlargeはGPUを1基もち、p2.16xlargeはGPUを16基ともっと多くのメモリをもつ。詳しくは、AWS EC2のドキュメントやまとめのページを参照されたい。説明のためには、p2.xlargeで十分である(図23.3.5の赤い枠で示した)。

Fig. 23.3.5図23.3.5
Choose an instance.
英語のヒント
インスタンスを選ぶ。
Note that you should use a GPU-enabled instance with suitable drivers and a GPU-enabled deep learning framework. Otherwise you will not see any benefit from using GPUs.
英語のヒント
適切なドライバを備えたGPU対応のインスタンスと、GPU対応の深層学習のフレームワークを使うべきであることに注意しよう。そうでなければ、GPUを使う利点はまったく得られない。
We go on to select the key pair used to access the instance. If you do not have a key pair, click “Create new key pair” in Fig. 23.3.6 to generate a key pair. Subsequently, you can select the previously generated key pair. Make sure that you download the key pair and store it in a safe location if you generated a new one. This is your only way to SSH into the server.
英語のヒント
次に、インスタンスにアクセスするのに使う鍵ペアを選ぶ。鍵ペアがなければ、図23.3.6の「Create new key pair」をクリックして鍵ペアを生成する。その後、前に生成した鍵ペアを選べる。新しい鍵ペアを生成したなら、それを必ずダウンロードして安全な場所に保存すること。これがサーバにSSHで入る唯一の方法である。

Fig. 23.3.6図23.3.6
Select a key pair.
英語のヒント
鍵ペアを選ぶ。
In this example, we will keep the default configurations for “Network settings” (click the “Edit” button to configure items such as the subnet and security groups). We just increase the default hard disk size to 64 GB (Fig. 23.3.7). Note that CUDA by itself already takes up 4 GB.
英語のヒント
この例では、「Network settings」は既定の構成のままにする(サブネットやセキュリティグループなどの項目を構成するには「Edit」ボタンをクリックする)。既定のハードディスクの大きさを64 GBに増やすだけにする(図23.3.7)。CUDAだけで4 GBを使うことに注意しよう。

Fig. 23.3.7図23.3.7
Modify the hard disk size.
英語のヒント
ハードディスクの大きさを変更する。
Click “Launch Instance” to launch the created instance. Click the instance ID shown in Fig. 23.3.8 to view the status of this instance.
英語のヒント
「Launch Instance」をクリックして、作ったインスタンスを起動する。図23.3.8に示したインスタンスIDをクリックすると、このインスタンスの状態が見られる。

Fig. 23.3.8図23.3.8
Click the instance ID.
英語のヒント
インスタンスIDをクリックする。
23.3.1.4. Connecting to the Instance23.3.1.4 インスタンスに接続する
As shown in Fig. 23.3.9, after the instance state turns green, right-click the instance and select
Connect to view the instance access method.英語のヒント
図23.3.9に示すように、インスタンスの状態が緑になったら、インスタンスを右クリックして
Connectを選び、インスタンスへのアクセス方法を見る。
Fig. 23.3.9図23.3.9
View the instance access method.
英語のヒント
インスタンスへのアクセス方法を見る。
If this is a new key, it must not be publicly viewable for SSH to work. Go to the folder where you store
D2L_key.pem and execute the following command to make the key not publicly viewable:英語のヒント
新しい鍵なら、SSHが動くためには、公開で見られる状態であってはならない。
D2L_key.pemを保存しているフォルダに行き、次のコマンドを実行して、鍵を公開で見られないようにする。chmod 400 D2L_key.pem
Fig. 23.3.10図23.3.10
View instance access and startup method.
英語のヒント
インスタンスへのアクセスと起動の方法を見る。
Now, copy the SSH command in the lower red box of Fig. 23.3.10 and paste onto the command line:
英語のヒント
では、図23.3.10の下の赤い枠の中のSSHコマンドをコピーして、コマンドラインに貼り付けよう。
ssh -i "D2L_key.pem" ubuntu@ec2-xx-xxx-xxx-xxx.y.compute.amazonaws.comWhen the command line prompts “Are you sure you want to continue connecting (yes/no)”, enter “yes” and press Enter to log into the instance.
英語のヒント
コマンドラインが「Are you sure you want to continue connecting (yes/no)」と尋ねてきたら、「yes」と入力してEnterを押し、インスタンスにログインする。
Your server is ready now.
英語のヒント
これでサーバの準備ができた。