I've started the script at 12h19, where the warnings and error occur. Immediately after this, I just run the same script again (12h21) and it then runs without problems... (it seems like a cold start problem?)
The log file:
2019-06-26 12:19:18 Agisoft Metashape Professional Version: 1.5.3 build 8407 (64 bit)
2019-06-26 12:19:18 Platform: Windows
2019-06-26 12:19:18 CPU: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (desktop)
2019-06-26 12:19:18 CPU family: 6 model: 158 signature: 906E9h
2019-06-26 12:19:18 RAM: 64.0 GB
2019-06-26 12:19:18 OpenGL Vendor: NVIDIA Corporation
2019-06-26 12:19:18 OpenGL Renderer: GeForce GTX 1080 Ti/PCIe/SSE2
2019-06-26 12:19:18 OpenGL Version: 4.6.0 NVIDIA 398.75
2019-06-26 12:19:18 Maximum Texture Size: 32768
2019-06-26 12:19:18 Quad Buffered Stereo: not enabled
2019-06-26 12:19:18 ARB_vertex_buffer_object: supported
2019-06-26 12:19:18 ARB_texture_non_power_of_two: supported
2019-06-26 12:19:31 SaveProject: path = .../master.psx
2019-06-26 12:19:31 Saving project...
2019-06-26 12:19:31 saved project in 0.043 sec
2019-06-26 12:19:31 Finished processing in 0.043 sec (exit code 1)
2019-06-26 12:19:31 LoadProject: path = .../master.psx
2019-06-26 12:19:31 loaded project in 0.002 sec
2019-06-26 12:19:31 Finished processing in 0.002 sec (exit code 1)
2019-06-26 12:19:31 AddPhotos
2019-06-26 12:19:31 Loading photos...
2019-06-26 12:19:31 Finished processing in 0.055 sec (exit code 1)
2019-06-26 12:19:31 AddPhotos
2019-06-26 12:19:31 Loading photos...
2019-06-26 12:19:31 Finished processing in 0.057 sec (exit code 1)
2019-06-26 12:19:31 ImportMasks
2019-06-26 12:19:31 Warning! Duplicate element keys not allowedWarning!
2019-06-26 12:19:31 Duplicate element keys not allowed
2019-06-26 12:19:31 Generating masks...
2019-06-26 12:19:32 Finished processing in 1.301 sec (exit code 0)
2019-06-26 12:19:32 Traceback (most recent call last):
2019-06-26 12:19:32 File ".../tmp_metashape_stitching.py", line 48, in <module>
2019-06-26 12:19:32 chunk.importMasks(source=Metashape.MaskSourceAlpha,operation=Metashape.MaskOperationReplacement)
2019-06-26 12:19:32 RuntimeError: Duplicate element keys not allowed
2019-06-26 12:19:32 Error: Duplicate element keys not allowed
2019-06-26 12:21:08 SaveProject: path = .../master.psx
2019-06-26 12:21:08 Saving project...
2019-06-26 12:21:08 saved project in 0.076 sec
2019-06-26 12:21:08 Finished processing in 0.076 sec (exit code 1)
2019-06-26 12:21:08 AddPhotos
2019-06-26 12:21:08 Loading photos...
2019-06-26 12:21:08 Finished processing in 0.054 sec (exit code 1)
2019-06-26 12:21:08 AddPhotos
2019-06-26 12:21:08 Loading photos...
2019-06-26 12:21:08 Finished processing in 0.056 sec (exit code 1)
2019-06-26 12:21:08 ImportMasks
2019-06-26 12:21:08 Generating masks...
2019-06-26 12:21:09 Finished processing in 1.275 sec (exit code 1)
2019-06-26 12:21:09 ImportReference: columns = nxyz, delimiter = ;, path = ...\gps.txt
2019-06-26 12:21:09 Finished processing in 0.013 sec (exit code 1)
2019-06-26 12:21:09 MatchPhotos: accuracy = Highest, preselection = generic, keypoint limit = 0, tiepoint limit = 0, apply masks = 0, filter tie points = 0
2019-06-26 12:21:09 Matching photos...
2019-06-26 12:21:09 Detecting points...
2019-06-26 12:21:10 Using device: GeForce GTX 1080 Ti, 28 compute units, free memory: 9254/11264 MB, compute capability 6.1
2019-06-26 12:21:10 driver/runtime CUDA: 9020/5050
2019-06-26 12:21:10 max work group size 1024
2019-06-26 12:21:10 max work item sizes [1024, 1024, 64]
2019-06-26 12:21:10 [CPU] photo 0: 1644 points
2019-06-26 12:21:10 [CPU] photo 2: 1759 points
2019-06-26 12:21:10 [CPU] photo 3: 2011 points
2019-06-26 12:21:10 [CPU] photo 4: 1761 points
2019-06-26 12:21:10 [CPU] photo 5: 1824 points
2019-06-26 12:21:10 [GPU] photo 1: 1602 points
2019-06-26 12:21:10 [GPU] photo 7: 1801 points
2019-06-26 12:21:10 [GPU] photo 8: 1908 points
2019-06-26 12:21:10 [CPU] photo 6: 1703 points
2019-06-26 12:21:10 [GPU] photo 9: 1916 points