Forum

Author Topic: GPU is recognized, but not used for computation  (Read 4689 times)

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
GPU is recognized, but not used for computation
« on: March 28, 2019, 04:39:56 PM »
Hello,

I'm using Metashape pro(trial mode) and trying GPU acceleration.
nvidia-driver and cuda looks successfully installed and Metashape recognizes GPU.
However, console logs show that GPU is not used for computation.

Code: [Select]
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
$ nvidia-smi
Thu Mar 28 13:16:02 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.40.04    Driver Version: 418.40.04    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           On   | 00000000:00:1E.0 Off |                    0 |
| N/A   31C    P8    24W / 149W |     11MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
$ lspci | grep -i nvidia
00:1e.0 3D controller: NVIDIA Corporation GK210GL [Tesla K80] (rev a1)
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Metashape
>>> from glob import glob
>>> app = Metashape.app
>>> print(app.activated)
True
>>> print(app.cpu_enable)
False
>>> print(app.enumGPUDevices())
[{'name': 'Tesla K80', 'vendor': '', 'version': '', 'compute_units': 13, 'mem_size': 11996954624, 'clock': 823, 'pci_bus_id': 0, 'pci_device_id': 30}]
>>> print(app.document)
None
>>> chunk = Metashape.Document().addChunk()
>>> chunk.addPhotos(glob('/home/ubuntu/images/*.JPG'))
AddPhotos
>>> chunk.matchPhotos(accuracy=Metashape.HighAccuracy, generic_preselection=True, reference_preselection=False)
MatchPhotos: accuracy = High, preselection = generic, keypoint limit = 40000, tiepoint limit = 4000, apply masks = 0, filter tie points = 0
[CPU] photo 0: 40000 points
[CPU] photo 1: 40000 points
[CPU] photo 2: 40000 points
[CPU] photo 3: 40000 points
[CPU] photo 4: 40000 points
[CPU] photo 5: 40000 points
[CPU] photo 6: 40000 points
[CPU] photo 7: 40000 points
[CPU] photo 8: 40000 points
[CPU] photo 9: 40000 points
points detected in 16.3362 sec
8464 matches found in 2.15852 sec
matches combined in 0.001021 sec
filtered 565 out of 5121 matches (11.033%) in 0.010804 sec
45 pairs selected in 1.2e-05 sec
setting point indices... 1632 done in 0.000264 sec
setting point indices... 1760 done in 0.000292 sec
setting point indices... 1754 done in 0.000301 sec
setting point indices... 1759 done in 0.000282 sec
29 skeletal pairs selected in 0.001752 sec
37272 matches found in 24.5823 sec
matches combined in 0.004737 sec
filtered 1800 out of 22770 matches (7.90514%) in 0.050163 sec
finished matching in 43.1466 sec
setting point indices... 14399 done in 0.002991 sec
generated 14399 tie points, 2.36662 average projections
removed 74 multiple indices
removed 7 tracks
selected 13738 tracks out of 14392 in 0.001161 sec
>>> chunk.alignCameras()
AlignCameras: adaptive fitting = 0
processing matches... done in 0.002644 sec
selecting camera groups... done in 0.000167 sec
processing block: 10 photos
pair 3 and 4: 2754 robust from 3045
adding photos 3 and 4 (2754 robust)
adding 3045 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxx 0.501094 -> 0.426675
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.077249 seconds
adding camera 2 (3 of 10), 810 of 827 used
adding camera 1 (4 of 10), 504 of 567 used
adding 3435 points, 18 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxx 0.939181 -> 0.407846
adding 18 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxx 0.417938 -> 0.417659
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.329659 seconds
adding camera 0 (5 of 10), 1130 of 1146 used
adding 1748 points, 6 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxx 0.46897 -> 0.39034
adding 5 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxx- 0.393588 -> 0.393544
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.359436 seconds
adding camera 5 (6 of 10), 352 of 403 used
adding 425 points, 15 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxx 0.509356 -> 0.404971
adding 14 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxx 0.424025 -> 0.422606
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.415614 seconds
adding camera 6 (7 of 10), 217 of 233 used
adding 913 points, 6 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxx 0.463106 -> 0.43043
adding 5 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxx 0.432917 -> 0.432899
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.36593 seconds
adding camera 7 (8 of 10), 279 of 297 used
adding camera 8 (9 of 10), 192 of 208 used
adding 2715 points, 8 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxx 0.526935 -> 0.452374
adding 8 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxx- 0.457398 -> 0.457251
adding 1 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxx 0.461273 -> 0.461001
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.754189 seconds
adding camera 9 (10 of 10), 614 of 641 used
adding 1425 points, 13 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxx 0.562741 -> 0.504114
adding 18 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxx 0.532952 -> 0.528803
adding 4 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxx 0.541485 -> 0.540656
adding 0 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 0.961424 seconds
3 sigma filtering...
adjusting: xxxxxxxxxxxxxxxxxxxx 0.540713 -> 0.517997
point variance: 0.444362 threshold: 1.33309
adding 0 points, 273 far (1.33309 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxxxx 0.377631 -> 0.326831
point variance: 0.279026 threshold: 0.837077
adding 36 points, 344 far (0.837077 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxxxx 0.276296 -> 0.267695
point variance: 0.227315 threshold: 0.681944
adding 2 points, 280 far (0.681944 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxx- 0.240279 -> 0.237732
point variance: 0.200783 threshold: 0.60235
adding 1 points, 203 far (0.60235 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxx 0.224382 -> 0.223851
point variance: 0.188153 threshold: 0.564458
adding 2 points, 124 far (0.564458 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 11.4174 seconds
f 3305.42, cx 11.7488, cy 1.92097, k1 0.0181888, k2 -0.128515, k3 0.177712
finished sfm in 14.9392 seconds
loaded projections in 4e-06 sec
tracks initialized in 0.003351 sec
adding 13698 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
1 blocks: 10
calculating match counts... done in 2.3e-05 sec
overlapping groups selected in 2e-06 sec
1 blocks: 10
final block size: 10
adding 13698 points, 0 far (7.056 threshold), 0 inaccurate, 0 invisible, 0 weak
3 sigma filtering...
adjusting: xxxxxxxxxxxxxxxxxxxx 0.56243 -> 0.486996
point variance: 0.417775 threshold: 1.25333
adding 0 points, 263 far (1.25333 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxxxx 0.35271 -> 0.321258
point variance: 0.274236 threshold: 0.822708
adding 18 points, 343 far (0.822708 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxxxxx 0.273322 -> 0.264858
point variance: 0.224883 threshold: 0.67465
adding 3 points, 277 far (0.67465 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxxxx 0.238415 -> 0.236211
point variance: 0.199409 threshold: 0.598227
adding 2 points, 191 far (0.598227 threshold), 0 inaccurate, 0 invisible, 0 weak
adjusting: xxxxxxxxxxxxxxx 0.223951 -> 0.223556
point variance: 0.187885 threshold: 0.563655
adding 1 points, 117 far (0.563655 threshold), 0 inaccurate, 0 invisible, 0 weak
optimized in 10.752 seconds
coordinates applied in 0 sec
>>> chunk.buildDepthMaps(quality=Metashape.MediumQuality, filter=Metashape.AggressiveFiltering)
BuildDepthMaps: quality = Medium, depth filtering = Aggressive, reuse depth maps
sorting point cloud... done in 0.000145 sec
processing matches... done in 0.002121 sec
initializing...
selected 10 cameras from 10 in 0.071193 sec
loaded photos in 0.664424 seconds
[CPU] estimating 722x922x128 disparity using 722x922x8u tiles
timings: rectify: 0.09905 disparity: 2.27298 borders: 0.086345 filter: 0.089302 fill: 1e-06
[CPU] estimating 730x962x160 disparity using 730x962x8u tiles
timings: rectify: 0.104356 disparity: 2.49192 borders: 0.069019 filter: 0.0737 fill: 3e-06
[CPU] estimating 764x798x128 disparity using 764x798x8u tiles
timings: rectify: 0.08933 disparity: 2.10999 borders: 0.057944 filter: 0.064444 fill: 0
[CPU] estimating 761x779x160 disparity using 761x779x8u tiles
timings: rectify: 0.088414 disparity: 2.0863 borders: 0.049731 filter: 0.059432 fill: 3e-06
[CPU] estimating 764x798x128 disparity using 764x798x8u tiles
timings: rectify: 0.091295 disparity: 2.09426 borders: 0.058651 filter: 0.064256 fill: 1e-06
[CPU] estimating 756x791x128 disparity using 756x791x8u tiles
timings: rectify: 0.088436 disparity: 2.05294 borders: 0.058272 filter: 0.063434 fill: 1e-06
[CPU] estimating 834x1412x96 disparity using 834x1412x8u tiles
timings: rectify: 0.173333 disparity: 3.88662 borders: 0.121873 filter: 0.127906 fill: 2e-06
[CPU] estimating 751x954x96 disparity using 751x954x8u tiles
timings: rectify: 0.103894 disparity: 2.30994 borders: 0.078245 filter: 0.083853 fill: 1e-06
[CPU] estimating 730x962x160 disparity using 730x962x8u tiles
timings: rectify: 0.104105 disparity: 2.44989 borders: 0.07728 filter: 0.081361 fill: 1e-06
[CPU] estimating 715x1054x128 disparity using 715x1054x8u tiles
timings: rectify: 0.11121 disparity: 2.56873 borders: 0.092414 filter: 0.095186 fill: 0
[CPU] estimating 834x1412x96 disparity using 834x1412x8u tiles
timings: rectify: 0.174806 disparity: 3.97186 borders: 0.122027 filter: 0.128461 fill: 2e-06
[CPU] estimating 817x1109x128 disparity using 817x1109x8u tiles
timings: rectify: 0.132742 disparity: 3.1369 borders: 0.078658 filter: 0.08608 fill: 2e-06
[CPU] estimating 722x922x128 disparity using 722x922x8u tiles
timings: rectify: 0.099858 disparity: 2.22933 borders: 0.085556 filter: 0.088087 fill: 0
[CPU] estimating 715x1054x128 disparity using 715x1054x8u tiles
timings: rectify: 0.111225 disparity: 2.60386 borders: 0.092611 filter: 0.095737 fill: 1e-06
[CPU] estimating 756x791x128 disparity using 756x791x8u tiles
timings: rectify: 0.087268 disparity: 2.05475 borders: 0.065156 filter: 0.069457 fill: 1e-06
[CPU] estimating 770x783x128 disparity using 770x783x8u tiles
timings: rectify: 0.08759 disparity: 2.10721 borders: 0.057979 filter: 0.062992 fill: 1e-06
[CPU] estimating 685x569x192 disparity using 685x569x8u tiles
timings: rectify: 0.05822 disparity: 1.36695 borders: 0.027094 filter: 0.033829 fill: 1e-06
[CPU] estimating 693x612x160 disparity using 693x612x8u tiles
timings: rectify: 0.064522 disparity: 1.49832 borders: 0.035022 filter: 0.040941 fill: 1e-06
[CPU] estimating 686x816x160 disparity using 686x816x8u tiles
timings: rectify: 0.083026 disparity: 1.98471 borders: 0.044152 filter: 0.050145 fill: 1e-06
[CPU] estimating 690x903x160 disparity using 690x903x8u tiles
timings: rectify: 0.093601 disparity: 2.21271 borders: 0.048712 filter: 0.055036 fill: 0
[CPU] estimating 683x910x160 disparity using 683x910x8u tiles
timings: rectify: 0.092818 disparity: 2.19315 borders: 0.051369 filter: 0.057003 fill: 1e-06
[CPU] estimating 787x897x128 disparity using 787x897x8u tiles
timings: rectify: 0.103347 disparity: 2.40656 borders: 0.067949 filter: 0.071702 fill: 0
[CPU] estimating 725x752x160 disparity using 725x752x8u tiles
timings: rectify: 0.07993 disparity: 1.85393 borders: 0.051447 filter: 0.056054 fill: 0
[CPU] estimating 698x753x160 disparity using 698x753x8u tiles
timings: rectify: 0.076466 disparity: 1.82075 borders: 0.046665 filter: 0.051096 fill: 1e-06
[CPU] estimating 762x779x160 disparity using 762x779x8u tiles
timings: rectify: 0.089792 disparity: 2.03182 borders: 0.046233 filter: 0.053356 fill: 1e-06
[CPU] estimating 770x783x128 disparity using 770x783x8u tiles
timings: rectify: 0.088999 disparity: 2.07068 borders: 0.053223 filter: 0.058585 fill: 1e-06
[CPU] estimating 818x1109x128 disparity using 818x1109x8u tiles
timings: rectify: 0.132312 disparity: 3.04826 borders: 0.077317 filter: 0.086092 fill: 1e-06
[CPU] estimating 751x954x96 disparity using 751x954x8u tiles
timings: rectify: 0.105255 disparity: 2.30889 borders: 0.087121 filter: 0.090969 fill: 0
[CPU] estimating 682x910x160 disparity using 682x910x8u tiles
timings: rectify: 0.093826 disparity: 2.19117 borders: 0.051896 filter: 0.057245 fill: 1e-06
[CPU] estimating 713x716x160 disparity using 713x716x8u tiles
timings: rectify: 0.075973 disparity: 1.8616 borders: 0.043468 filter: 0.049295 fill: 3e-06
[CPU] estimating 787x897x128 disparity using 787x897x8u tiles
timings: rectify: 0.103096 disparity: 2.37235 borders: 0.075299 filter: 0.080032 fill: 0
[CPU] estimating 730x922x128 disparity using 730x922x8u tiles
timings: rectify: 0.097996 disparity: 2.22938 borders: 0.072798 filter: 0.079778 fill: 1e-06
[CPU] estimating 735x953x160 disparity using 735x953x8u tiles
timings: rectify: 0.101413 disparity: 2.36388 borders: 0.069506 filter: 0.073967 fill: 0
[CPU] estimating 700x894x160 disparity using 700x894x8u tiles
timings: rectify: 0.0931 disparity: 2.15467 borders: 0.058254 filter: 0.063525 fill: 0
[CPU] estimating 726x752x160 disparity using 726x752x8u tiles
timings: rectify: 0.08176 disparity: 1.83914 borders: 0.044956 filter: 0.050194 fill: 2e-06
[CPU] estimating 730x922x128 disparity using 730x922x8u tiles
timings: rectify: 0.099374 disparity: 2.23343 borders: 0.076625 filter: 0.081027 fill: 0
[CPU] estimating 792x1145x128 disparity using 792x1145x8u tiles
timings: rectify: 0.132924 disparity: 3.037 borders: 0.106715 filter: 0.109799 fill: 1e-06
[CPU] estimating 749x1120x128 disparity using 749x1120x8u tiles
timings: rectify: 0.123673 disparity: 2.83131 borders: 0.093842 filter: 0.097428 fill: 2e-06
[CPU] estimating 701x894x160 disparity using 701x894x8u tiles
timings: rectify: 0.093229 disparity: 2.16211 borders: 0.049242 filter: 0.059221 fill: 1e-06
[CPU] estimating 749x1120x128 disparity using 749x1120x8u tiles
timings: rectify: 0.125167 disparity: 2.8781 borders: 0.090737 filter: 0.095708 fill: 2e-06
[CPU] estimating 742x1193x128 disparity using 742x1193x8u tiles
timings: rectify: 0.13196 disparity: 2.92279 borders: 0.103698 filter: 0.107726 fill: 1e-06
[CPU] estimating 699x753x160 disparity using 699x753x8u tiles
timings: rectify: 0.077672 disparity: 1.80912 borders: 0.045842 filter: 0.050818 fill: 2e-06
[CPU] estimating 735x953x160 disparity using 735x953x8u tiles
timings: rectify: 0.103416 disparity: 2.3859 borders: 0.066919 filter: 0.071199 fill: 1e-06
[CPU] estimating 792x1145x128 disparity using 792x1145x8u tiles
timings: rectify: 0.134466 disparity: 3.03424 borders: 0.099231 filter: 0.103082 fill: 0
[CPU] estimating 743x1193x128 disparity using 743x1193x8u tiles
timings: rectify: 0.131829 disparity: 2.87018 borders: 0.097419 filter: 0.100467 fill: 1e-06

Depth reconstruction devices performance:
 - 100% done by CPU
Total time: 128.229 seconds

>>> chunk.buildDenseCloud()
BuildDenseCloud: point colors = 1
selected 10 cameras in 0.131688 sec
working volume: 1265x1109x498
tiles: 1x1x1
selected 10 cameras in 3.5e-05 sec
preloading data... done in 0.368999 sec
filtering depth maps... done in 11.8143 sec
preloading data... done in 0.53306 sec
working volume: 1265x1109x498
tiles: 1x1x1
1907032 points extracted

Best regards,
kaz

Mak11

  • Sr. Member
  • ****
  • Posts: 374
    • View Profile
Re: GPU is recognized, but not used for computation
« Reply #1 on: March 28, 2019, 04:51:26 PM »
You did enable GPU acceleration in the Metashape Settings, right?

Mak

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: GPU is recognized, but not used for computation
« Reply #2 on: March 28, 2019, 04:53:20 PM »
Hello kaz,

You need to set up gpu_mask to enable the processing on GPU.

The following line (in the beginning of the script) would initialize and enable all supported GPU devices for the processing:
Code: [Select]
Metashape.app.gpu_mask = 2 ** (len(Metashape.app.enumGPUDevices())) - 1
« Last Edit: March 28, 2019, 05:16:10 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

kaz

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: GPU is recognized, but not used for computation
« Reply #3 on: March 28, 2019, 05:03:34 PM »
Hello Alexey,

Thank you for so quick response.

There is typo but the program works when it's fixed.
It becomes much faster!

Code: [Select]
NG: Metashape.app.gpu_mask = 2 ** (len(Metashape.app.enumGPUDevices()) - 1
OK: Metashape.app.gpu_mask = 2 ** (len(Metashape.app.enumGPUDevices())) - 1

Best regards,
kaz

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: GPU is recognized, but not used for computation
« Reply #4 on: March 28, 2019, 05:16:29 PM »
Thanks. Corrected the typo in the original post.
Best regards,
Alexey Pasumansky,
Agisoft LLC