[Bugfix] Check file exists before removing it (#3178)
authorhlu1 <14827759+hlu1@users.noreply.github.com>
Sat, 11 May 2019 05:55:11 +0000 (22:55 -0700)
committerTianqi Chen <tqchen@users.noreply.github.com>
Sat, 11 May 2019 05:55:11 +0000 (22:55 -0700)
python/tvm/contrib/download.py

index 46a9a6d..bc6d324 100644 (file)
@@ -111,7 +111,8 @@ def download(url, path, overwrite=False, size_compare=False, verbose=1, retries=
         except Exception as err:
             retries -= 1
             if retries == 0:
-                os.remove(tempfile)
+                if os.path.exists(tempfile):
+                    os.remove(tempfile)
                 raise err
             else:
                 print("download failed due to {}, retrying, {} attempt{} left"