1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge"
aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --query "Reservations[].Instances[].InstanceId"
aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].PublicIpAddress"
aws ec2 run-instances --image-id ami-0c4f7023847b90238 --count 1 --instance-type g4dn.xlarge --key-name home --security-group-ids sg-09a16a5a8bd226113 --subnet-id subnet-03959d098b755dc22 --block-device-mappings "[{\"DeviceName\":\"/dev/sda1\",\"Ebs\":{\"VolumeSize\":15,\"DeleteOnTermination\":true}}]"
# 登录实例
aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --query "Reservations[].Instances[].PublicIpAddress" | cat
ssh ubuntu@`aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --query "Reservations[].Instances[].PublicIpAddress" | cat`
# 终止实例
aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].InstanceId" | cat
aws ec2 terminate-instances --instance-ids `aws ec2 describe-instances --filters "Name=instance-type,Values=g4dn.xlarge" --filters Name=instance-state-name,Values=running --query "Reservations[].Instances[].InstanceId" | cat`
{
"Reservations": [
{
"Groups": [],
"Instances": [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-0c4f7023847b90238",
"InstanceId": "i-01352dc5bee4ecedf",
"InstanceType": "g4dn.xlarge",
"KeyName": "home",
"LaunchTime": "2022-06-11T14:53:25+00:00",
"Monitoring": {
"State": "disabled"
},
"Placement": {
"AvailabilityZone": "us-east-1b",
"GroupName": "",
"Tenancy": "default"
},
"PrivateDnsName": "ip-172-31-90-186.ec2.internal",
"PrivateIpAddress": "172.31.90.186",
"ProductCodes": [],
"PublicDnsName": "ec2-35-174-4-130.compute-1.amazonaws.com",
"PublicIpAddress": "35.174.4.130",
"State": {
"Code": 16,
"Name": "running"
},
"StateTransitionReason": "",
"SubnetId": "subnet-03959d098b755dc22",
"VpcId": "vpc-050c0397c631696ec",
"Architecture": "x86_64",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"AttachTime": "2022-06-11T14:53:26+00:00",
"DeleteOnTermination": true,
"Status": "attached",
"VolumeId": "vol-01ddc78e57f54b01c"
}
}
],
"ClientToken": "",
"EbsOptimized": true,
"EnaSupport": true,
"Hypervisor": "xen",
"NetworkInterfaces": [
{
"Association": {
"IpOwnerId": "amazon",
"PublicDnsName": "ec2-35-174-4-130.compute-1.amazonaws.com",
"PublicIp": "35.174.4.130"
},
"Attachment": {
"AttachTime": "2022-06-11T14:53:25+00:00",
"AttachmentId": "eni-attach-0adc8abe048583a8a",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"Status": "attached",
"NetworkCardIndex": 0
},
"Description": "",
"Groups": [
{
"GroupName": "launch-wizard-24",
"GroupId": "sg-09a16a5a8bd226113"
}
],
"Ipv6Addresses": [],
"MacAddress": "12:bc:1a:b0:8d:0f",
"NetworkInterfaceId": "eni-0287bb80c55470c64",
"OwnerId": "348797107744",
"PrivateDnsName": "ip-172-31-90-186.ec2.internal",
"PrivateIpAddress": "172.31.90.186",
"PrivateIpAddresses": [
{
"Association": {
"IpOwnerId": "amazon",
"PublicDnsName": "ec2-35-174-4-130.compute-1.amazonaws.com",
"PublicIp": "35.174.4.130"
},
"Primary": true,
"PrivateDnsName": "ip-172-31-90-186.ec2.internal",
"PrivateIpAddress": "172.31.90.186"
}
],
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-03959d098b755dc22",
"VpcId": "vpc-050c0397c631696ec",
"InterfaceType": "interface"
}
],
"RootDeviceName": "/dev/sda1",
"RootDeviceType": "ebs",
"SecurityGroups": [
{
"GroupName": "launch-wizard-24",
"GroupId": "sg-09a16a5a8bd226113"
}
],
"SourceDestCheck": true,
"VirtualizationType": "hvm",
"CpuOptions": {
"CoreCount": 2,
"ThreadsPerCore": 2
},
"CapacityReservationSpecification": {
"CapacityReservationPreference": "open"
},
"HibernationOptions": {
"Configured": false
},
"MetadataOptions": {
"State": "applied",
"HttpTokens": "optional",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled",
"HttpProtocolIpv6": "disabled",
"InstanceMetadataTags": "disabled"
},
"EnclaveOptions": {
"Enabled": false
},
"PlatformDetails": "Linux/UNIX",
"UsageOperation": "RunInstances",
"UsageOperationUpdateTime": "2022-06-11T14:53:25+00:00",
"PrivateDnsNameOptions": {
"HostnameType": "ip-name",
"EnableResourceNameDnsARecord": true,
"EnableResourceNameDnsAAAARecord": false
},
"MaintenanceOptions": {
"AutoRecovery": "default"
}
}
],
"OwnerId": "348797107744",
"ReservationId": "r-02dd0920b21778829"
}
]
}
# 安装驱动的脚本处理
cat >> gpu.sh <<\EOF
set -x
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=470.129.06
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
sleep 3s
nvidia-docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
EOF
bash gpu.sh
# 410.104-4.4.0-1122-aws
set -x
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=410.104
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
# 418.226.00-5.4.0-1071-aws
cat >> gpu.sh <<\EOF
set -x
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=418.226.00
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
sleep 3s
# 好像有快一点点
# 2022-06-11 16:21:28.572681: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 305283878 microseconds.
# g4ad.8xlarge-ubuntu20.04-5.13.0-1022-aws测试
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=470.129.06
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
# g4dn-470.129.06-ubuntu20.04-5.13.0-1022-aws测试
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=470.129.06
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
docker ps |grep -i dp-query|awk '{print $1}' |xargs docker logs -f
docker ps|grep -iE "dp-query|serving" | awk '{print $1}' | xargs docker stop
# 2022-06-11 03:10:40.461147: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 352077906 microseconds.
# ubuntu20.04测试
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=515.48.07
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
# 2022-06-11 01:35:36.323103: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 357438670 microseconds.
# ubuntu18.04测试
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=440.118.02
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
docker run --rm --gpus all nvidia/cuda:10.2-base-ubuntu18.04 nvidia-smi
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
# 2022-06-11 01:52:07.674026: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 313128848 microseconds.
# g5.xlarge-ubuntu20.04-5.13.0-1022-aws-A10G-515.48.07
BASE_URL=https://us.download.nvidia.com/tesla
DRIVER_VERSION=515.48.07
curl -fSsl -O $BASE_URL/$DRIVER_VERSION/NVIDIA-Linux-x86_64-$DRIVER_VERSION.run
apt update
apt install -y gcc make
sh NVIDIA-Linux-x86_64-$DRIVER_VERSION.run -s
nvidia-smi
curl https://get.docker.com | sh && sudo systemctl --now enable docker
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
apt-get update
apt-get install -y nvidia-docker2 unzip zip
systemctl restart docker
nvidia-docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
docker ps |grep -i dp-query|awk '{print $1}' |xargs docker logs -f
docker ps|grep -iE "dp-query|serving" | awk '{print $1}' | xargs docker stop
# 2022-06-11 02:16:06.163269: I tensorflow/cc/saved_model/loader.cc:311] SavedModel load for tags { serve }; Status: success. Took 375215857 microseconds.
wget https://github.com/tensorflow/serving/archive/refs/tags/1.15.0.zip
unzip 1.15.0
VERSION=1.15.0
TESTDATA="$(pwd)/serving-$VERSION/tensorflow_serving/servables/tensorflow/testdata"
nvidia-docker run -t --rm -p 8501:8501 -v "$TESTDATA/saved_model_half_plus_two_gpu:/models/half_plus_two_gpu" -e MODEL_NAME=half_plus_two_gpu tensorflow/serving:"$VERSION"-gpu &
nvidia-docker run --rm -d -e TF_CPP_MIN_VLOG_LEVEL=1 runzhliu/dp-query:0.2.7 &
nvidia-docker run --rm -d runzhliu/dp-query:0.2.7 &
docker run -t -d --rm -p 8501:8501 -v "$TESTDATA/saved_model_half_plus_two_gpu:/models/half_plus_two_gpu" -e MODEL_NAME=half_plus_two_gpu -e TF_CPP_MIN_VLOG_LEVEL=1 harbor.fql.com/middleware/serving:"$VERSION"-gpu &
docker ps |grep -i dp-query|awk '{print $1}' |xargs docker logs -f
docker ps|grep -iE "dp-query|serving" | awk '{print $1}' | xargs docker stop
|