Fix a bug in the performance test script (#168)

* fix: pytorch tensors do not have .sync() method

* feat: check if the docker image is already built
This commit is contained in:
Zheng-Ning Liu 2021-02-11 19:12:51 +08:00 committed by GitHub
parent 80135d4ef5
commit 81db43e669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -55,7 +55,11 @@ RUN pip3 install torch torchvision
with open("/tmp/perf_dockerfile", 'w') as f: with open("/tmp/perf_dockerfile", 'w') as f:
f.write(dockerfile_src) f.write(dockerfile_src)
assert os.system("sudo nvidia-smi -lgc 1500") == 0 assert os.system("sudo nvidia-smi -lgc 1500") == 0
assert os.system(f"sudo docker build --tag jittor/jittor-perf{suffix} -f /tmp/perf_dockerfile .") == 0
# if the docker image is not built
if os.system(f"sudo docker image inspect jittor/jittor-perf{suffix}"):
assert os.system(f"sudo docker build --tag jittor/jittor-perf{suffix} -f /tmp/perf_dockerfile .") == 0
# run once for compile source # run once for compile source
jt_fps = test_main("jittor", "resnet50", 1) jt_fps = test_main("jittor", "resnet50", 1)
@ -180,7 +184,8 @@ def test(name, model_name, bs):
loss.backward() loss.backward()
opt.step() opt.step()
else: else:
x.sync() if name == "jittor":
x.sync()
sync() sync()
for i in time_iter(): for i in time_iter():
iter() iter()