Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solved] Support Linux #3

Open
abhinavshaw1993 opened this issue Sep 30, 2021 · 3 comments
Open

[solved] Support Linux #3

abhinavshaw1993 opened this issue Sep 30, 2021 · 3 comments
Assignees

Comments

@abhinavshaw1993
Copy link

Great library, I was wondering if you have plans of supporting Ubuntu as well. This could be a good open source project.

@shaojunjie0912
Copy link

@andrewssobral Hi~

Is the library really not supported by Linux?

Tests on my Arch Linux failed though.

@andrewssobral
Copy link
Owner

Hi @abhinavshaw1993 @shaojunjie0912 sorry for my deplayed reply.
Usually it should work with Linux, but I need to check it if there are any issue to fix.
I come back to you in the next days.

@andrewssobral
Copy link
Owner

Hello @abhinavshaw1993 @shaojunjie0912 i just tested on Linux Ubuntu 22.04 and it works fine for me:

andrews@DELL-M4700:~/Projects/dtt$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
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"
UBUNTU_CODENAME=jammy

andrews@DELL-M4700:~/Projects/dtt$ cmake -S . -B build -DCMAKE_PREFIX_PATH=$LIBTORCH_HOME
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Armadillo: /usr/include (found suitable version "12.8.3", minimum required is "9")
-- Found Torch: /home/andrews/Projects/libs/libtorch/lib/libtorch.so
-- Found OpenCV: /usr (found version "4.5.4")
-- OpenCV library status:
--     version: 4.5.4
--     libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_alphamat;opencv_aruco;opencv_barcode;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_datasets;opencv_dnn_objdetect;opencv_dnn_superres;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_intensity_transform;opencv_line_descriptor;opencv_mcc;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_quality;opencv_rapid;opencv_reg;opencv_rgbd;opencv_saliency;opencv_shape;opencv_stereo;opencv_structured_light;opencv_superres;opencv_surface_matching;opencv_text;opencv_tracking;opencv_videostab;opencv_viz;opencv_wechat_qrcode;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
--     include path: /usr/include/opencv4
-- Configuring done
-- Generating done
-- Build files have been written to: /home/andrews/Projects/dtt/build

andrews@DELL-M4700:~/Projects/dtt$ cmake --build build --config Release
[ 50%] Building CXX object CMakeFiles/dtt_test.dir/test/dtt_test.cpp.o
[100%] Linking CXX executable dtt_test
[100%] Built target dtt_test

andrews@DELL-M4700:~/Projects/dtt$ ./build/dtt_test
Eigen version: 340
Armadillo version: 12.8.3 (Cortisol Injector)
Using OpenCV version 4.5.4
--------------------------------------------------
Testing OpenCV
[-1.6030948e-09, 0.15813506, -0.70092797;
 -0.42859599, 1.2387421, -0.27800822;
 -0.64839876, 0.30516329, 0.51501459]
--------------------------------------------------
Testing Eigen
  3  -1
2.5 1.5
--------------------------------------------------
Testing Armadillo
A:
   0.7868   0.9467   0.2513
   0.2505   0.0193   0.0227
   0.7107   0.4049   0.5206

--------------------------------------------------
Testing ArrayFire
ArrayFire v3.9.0 (CPU, 64-bit Linux, build b59a1ae53)
[0] Intel: Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHzsum: 54.4886
--------------------------------------------------
Testing LibTorch
 0.1333  0.9929  0.9439
 0.2177  0.2816  0.7952
[ CPUFloatType{2,3} ]
--------------------------------------------------
Testing Eigen to OpenCV (copy 3x3 matrix):
EigenMat:
 0.680375   0.59688 -0.329554
-0.211234  0.823295  0.536459
 0.566198 -0.604897 -0.444451
cvMat:
[0.68037546, 0.59688008, -0.3295545;
 -0.21123415, 0.82329476, 0.53645921;
 0.56619847, -0.60489726, -0.44445056]
cvMat:
[0, 0.59688008, -0.3295545;
 -0.21123415, 0.82329476, 0.53645921;
 0.56619847, -0.60489726, -0.44445056]
EigenMat:
 0.680375   0.59688 -0.329554
-0.211234  0.823295  0.536459
 0.566198 -0.604897 -0.444451
--------------------------------------------------
Testing Eigen to Armadillo (copy 3x3 matrix):
EigenMat:
   0.10794  -0.270431    0.83239
-0.0452059  0.0268018   0.271423
  0.257742   0.904459   0.434594
ArmaMat:
   0.1079  -0.2704   0.8324
  -0.0452   0.0268   0.2714
   0.2577   0.9045   0.4346

ArmaMat:
        0  -0.2704   0.8324
  -0.0452   0.0268   0.2714
   0.2577   0.9045   0.4346

EigenMat:
   0.10794  -0.270431    0.83239
-0.0452059  0.0268018   0.271423
  0.257742   0.904459   0.434594
--------------------------------------------------
Testing Eigen to ArrayFire (copy 3x3 matrix):
EigenMat:
-0.716795 -0.514226 -0.686642
 0.213938 -0.725537 -0.198111
-0.967399  0.608353 -0.740419
AfMat:
A
[3 3 1 1]
   -0.7168    -0.5142    -0.6866
    0.2139    -0.7255    -0.1981
   -0.9674     0.6084    -0.7404

AfMat:
A
[3 3 1 1]
    0.0000    -0.5142    -0.6866
    0.2139    -0.7255    -0.1981
   -0.9674     0.6084    -0.7404

EigenMat:
-0.7168 -0.5142 -0.6866
 0.2139 -0.7255 -0.1981
-0.9674  0.6084 -0.7404
--------------------------------------------------
Testing Eigen(CM) to LibTorch (copy 3x3 matrix):
EigenMat:
-0.7824 0.02586 -0.4079
 0.9978  0.6782  0.2751
-0.5635  0.2253 0.04857
LibTorch:
-0.7824  0.0259 -0.4079
 0.9978  0.6782  0.2751
-0.5635  0.2253  0.0486
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000  0.0259 -0.4079
 0.9978  0.6782  0.2751
-0.5635  0.2253  0.0486
[ CPUFloatType{3,3} ]
EigenMat:
-0.7824 0.02586 -0.4079
 0.9978  0.6782  0.2751
-0.5635  0.2253 0.04857
--------------------------------------------------
Testing Eigen(RM) to LibTorch (copy 3x3 matrix):
EigenMat:
 1.01  2.02  3.03
 4.04 5.051 6.061
7.071 8.081 9.091
LibTorch:
 1.0101  2.0202  3.0303
 4.0404  5.0505  6.0606
 7.0707  8.0808  9.0909
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000  2.0202  3.0303
 4.0404  5.0505  6.0606
 7.0707  8.0808  9.0909
[ CPUFloatType{3,3} ]
EigenMat:
 1.01  2.02  3.03
 4.04 5.051 6.061
7.071 8.081 9.091
--------------------------------------------------
Testing Eigen(RM) to LibTorch (no-copy 3x3 matrix):
EigenMat:
 1.01  2.02  3.03
 4.04 5.051 6.061
7.071 8.081 9.091
LibTorch:
 1.0101  2.0202  3.0303
 4.0404  5.0505  6.0606
 7.0707  8.0808  9.0909
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000  2.0202  3.0303
 4.0404  5.0505  6.0606
 7.0707  8.0808  9.0909
[ CPUFloatType{3,3} ]
EigenMat:
    0  2.02  3.03
 4.04 5.051 6.061
7.071 8.081 9.091
--------------------------------------------------
Testing Armadillo to Eigen (copy 3x3 matrix):
ArmaMat:
   0.3447   0.1400   0.8571
   0.2742   0.5439   0.4998
   0.5610   0.5219   0.4194

EigenMat:
0.3447   0.14 0.8571
0.2742 0.5439 0.4998
 0.561 0.5219 0.4194
EigenMat:
     0   0.14 0.8571
0.2742 0.5439 0.4998
 0.561 0.5219 0.4194
ArmaMat:
   0.3447   0.1400   0.8571
   0.2742   0.5439   0.4998
   0.5610   0.5219   0.4194

--------------------------------------------------
Testing Armadillo to OpenCV (copy 3x3 matrix):
ArmaMat:
   0.7443   0.3201   0.2455
   0.2492   0.9105   0.1983
   0.2393   0.1648   0.7159

cvMat:
[0.74428052, 0.3200649, 0.24553275;
 0.24916813, 0.91050082, 0.19831969;
 0.23927662, 0.16483298, 0.71589273]
cvMat:
[0, 0.3200649, 0.24553275;
 0.24916813, 0.91050082, 0.19831969;
 0.23927662, 0.16483298, 0.71589273]
ArmaMat:
   0.7443   0.3201   0.2455
   0.2492   0.9105   0.1983
   0.2393   0.1648   0.7159

--------------------------------------------------
Testing Armadillo to ArrayFire (copy 3x3 matrix):
ArmaMat:
   0.9678   0.4599   0.5839
   0.7694   0.2573   0.9503
   0.0807   0.7770   0.4381

AfMat:
A
[3 3 1 1]
    0.9678     0.4599     0.5839
    0.7694     0.2573     0.9503
    0.0807     0.7770     0.4381

AfMat:
A
[3 3 1 1]
    0.9678     0.4599     0.5839
    0.7694     0.0000     0.9503
    0.0807     0.7770     0.4381

ArmaMat:
   0.9678   0.4599   0.5839
   0.7694   0.2573   0.9503
   0.0807   0.7770   0.4381

--------------------------------------------------
Testing Armadillo to LibTorch (copy 3x3 matrix):
ArmaMat:
   0.3223   0.0455   0.0912
   0.5324   0.5050   0.9071
   0.2564   0.6962   0.0309

LibTorch:
 0.3223  0.0455  0.0912
 0.5324  0.5050  0.9071
 0.2564  0.6962  0.0309
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000  0.0455  0.0912
 0.5324  0.5050  0.9071
 0.2564  0.6962  0.0309
[ CPUFloatType{3,3} ]
ArmaMat:
   0.3223   0.0455   0.0912
   0.5324   0.5050   0.9071
   0.2564   0.6962   0.0309

--------------------------------------------------
Testing OpenCV to Eigen (copy 3x3 matrix):
cvMat:
[-1.1450437, 0.76984555, -0.04643121;
 1.3059061, -1.9596839, -1.8992141;
 -0.53723824, -0.74828959, 1.8964931]
EigenMat:
  -1.145   0.7698 -0.04643
   1.306    -1.96   -1.899
 -0.5372  -0.7483    1.896
EigenMat:
       0   0.7698 -0.04643
   1.306    -1.96   -1.899
 -0.5372  -0.7483    1.896
cvMat:
[-1.1450437, 0.76984555, -0.04643121;
 1.3059061, -1.9596839, -1.8992141;
 -0.53723824, -0.74828959, 1.8964931]
--------------------------------------------------
Testing OpenCV to Armadillo (copy 3x3 matrix):
cvMat:
[0.27405041, -1.380205, 1.536549;
 -0.78635716, -2.4748602, -1.5479244;
 -1.3660194, -0.063247398, 1.35166]
ArmaMat:
   0.2741  -1.3802   1.5365
  -0.7864  -2.4749  -1.5479
  -1.3660  -0.0632   1.3517

ArmaMat:
        0  -1.3802   1.5365
  -0.7864  -2.4749  -1.5479
  -1.3660  -0.0632   1.3517

cvMat:
[0.27405041, -1.380205, 1.536549;
 -0.78635716, -2.4748602, -1.5479244;
 -1.3660194, -0.063247398, 1.35166]
--------------------------------------------------
Testing OpenCV to ArrayFire (copy 3x3 matrix):
cvMat:
[-0.20089114, -1.2629067, -1.5210054;
 0.83297932, -0.6334604, 0.29202414;
 -1.6415403, -1.8612988, 0.074599862]
AfMat:
A
[3 3 1 1]
   -0.2009    -1.2629    -1.5210
    0.8330    -0.6335     0.2920
   -1.6415    -1.8613     0.0746

AfMat:
A
[3 3 1 1]
    0.0000    -1.2629    -1.5210
    0.8330    -0.6335     0.2920
   -1.6415    -1.8613     0.0746

cvMat:
[-0.20089114, -1.2629067, -1.5210054;
 0.83297932, -0.6334604, 0.29202414;
 -1.6415403, -1.8612988, 0.074599862]
--------------------------------------------------
Testing OpenCV to LibTorch (copy 3x3 matrix):
cvMat:
[0.048177242, -0.27772549, -0.15443642;
 -0.3687655, 1.0495871, 0.47451678;
 -0.10983074, 1.0279955, -0.74734718]
LibTorch:
 0.0482 -0.2777 -0.1544
-0.3688  1.0496  0.4745
-0.1098  1.0280 -0.7473
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000 -0.2777 -0.1544
-0.3688  1.0496  0.4745
-0.1098  1.0280 -0.7473
[ CPUFloatType{3,3} ]
cvMat:
[0.048177242, -0.27772549, -0.15443642;
 -0.3687655, 1.0495871, 0.47451678;
 -0.10983074, 1.0279955, -0.74734718]
--------------------------------------------------
Testing OpenCV to LibTorch (no-copy 3x3 matrix):
cvMat:
[-0.60865867, -0.21269958, 1.1613728;
 -1.97154, 0.69793731, -0.21648638;
 0.098008506, 0.2626977, -0.83743554]
LibTorch:
-0.6087 -0.2127  1.1614
-1.9715  0.6979 -0.2165
 0.0980  0.2627 -0.8374
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000 -0.2127  1.1614
-1.9715  0.6979 -0.2165
 0.0980  0.2627 -0.8374
[ CPUFloatType{3,3} ]
cvMat:
[0, -0.21269958, 1.1613728;
 -1.97154, 0.69793731, -0.21648638;
 0.098008506, 0.2626977, -0.83743554]
--------------------------------------------------
Testing ArrayFire to Eigen (copy 3x3 matrix):
AfMat:
A
[3 3 1 1]
    0.4792     0.8523     0.9730
    0.6265     0.5827     0.2184
    0.7387     0.3657     0.6659

EigenMat:
0.4792 0.8523  0.973
0.6265 0.5827 0.2184
0.7387 0.3657 0.6659
EigenMat:
     0 0.8523  0.973
0.6265 0.5827 0.2184
0.7387 0.3657 0.6659
AfMat:
A
[3 3 1 1]
    0.4792     0.8523     0.9730
    0.6265     0.5827     0.2184
    0.7387     0.3657     0.6659

--------------------------------------------------
Testing ArrayFire to Armadillo (copy 3x3 matrix):
AfMat:
A
[3 3 1 1]
    0.3688     0.1266     0.4220
    0.2578     0.6511     0.2491
    0.3815     0.4507     0.4128

ArmaMat:
   0.3688   0.1266   0.4220
   0.2578   0.6511   0.2491
   0.3815   0.4507   0.4128

ArmaMat:
        0   0.1266   0.4220
   0.2578   0.6511   0.2491
   0.3815   0.4507   0.4128

AfMat:
A
[3 3 1 1]
    0.3688     0.1266     0.4220
    0.2578     0.6511     0.2491
    0.3815     0.4507     0.4128

--------------------------------------------------
Testing ArrayFire to OpenCV (copy 3x3 matrix):
AfMat:
A
[3 3 1 1]
    0.7664     0.6913     0.1673
    0.8045     0.7821     0.2990
    0.8104     0.3054     0.2802

cvMat:
[0.76638222, 0.69128126, 0.16725606;
 0.80446917, 0.78207785, 0.29895157;
 0.81041062, 0.30535847, 0.28018022]
cvMat:
[0, 0.69128126, 0.16725606;
 0.80446917, 0.78207785, 0.29895157;
 0.81041062, 0.30535847, 0.28018022]
AfMat:
A
[3 3 1 1]
    0.7664     0.6913     0.1673
    0.8045     0.7821     0.2990
    0.8104     0.3054     0.2802

--------------------------------------------------
Testing ArrayFire to LibTorch (copy 3x3 matrix):
AfMat:
A
[3 3 1 1]
    0.1480     0.3014     0.7176
    0.1330     0.6938     0.1181
    0.4696     0.3513     0.8403

LibTorch:
 0.1480  0.3014  0.7176
 0.1330  0.6938  0.1181
 0.4696  0.3513  0.8403
[ CPUFloatType{3,3} ]
LibTorch:
 0.0000  0.3014  0.7176
 0.1330  0.6938  0.1181
 0.4696  0.3513  0.8403
[ CPUFloatType{3,3} ]
AfMat:
A
[3 3 1 1]
    0.1480     0.3014     0.7176
    0.1330     0.6938     0.1181
    0.4696     0.3513     0.8403

--------------------------------------------------
Testing LibTorch to Eigen (copy 3x3 matrix):
LibTorch:
 0.1856  0.8719  0.0410
 0.6352  0.9736  0.4295
 0.5282  0.1334  0.7348
[ CPUFloatType{3,3} ]
EigenMat:
 0.1856  0.8719 0.04104
 0.6352  0.9736  0.4295
 0.5282  0.1334  0.7348
EigenMat:
      0  0.8719 0.04104
 0.6352  0.9736  0.4295
 0.5282  0.1334  0.7348
LibTorch:
 0.1856  0.8719  0.0410
 0.6352  0.9736  0.4295
 0.5282  0.1334  0.7348
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to Eigen (no-copy 3x3 matrix):
LibTorch:
 0.2439  0.8696  0.4492
 0.5461  0.0236  0.6716
 0.4140  0.4719  0.2793
[ CPUFloatType{3,3} ]
EigenMat:
 0.2439  0.8696  0.4492
 0.5461 0.02365  0.6716
  0.414  0.4719  0.2793
EigenMat:
      0  0.8696  0.4492
 0.5461 0.02365  0.6716
  0.414  0.4719  0.2793
LibTorch:
 0.0000  0.8696  0.4492
 0.5461  0.0236  0.6716
 0.4140  0.4719  0.2793
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to Armadillo (copy 3x3 matrix):
LibTorch:
 0.3161  0.4803  0.4965
 0.6568  0.0581  0.1410
 0.2431  0.0689  0.1165
[ CPUFloatType{3,3} ]
ArmaMat:
   0.3161   0.4803   0.4965
   0.6568   0.0581   0.1410
   0.2431   0.0689   0.1165

ArmaMat:
        0   0.4803   0.4965
   0.6568   0.0581   0.1410
   0.2431   0.0689   0.1165

LibTorch:
 0.3161  0.4803  0.4965
 0.6568  0.0581  0.1410
 0.2431  0.0689  0.1165
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to Armadillo (no-copy 3x3 matrix):
LibTorch:
 0.5359  0.8038  0.4289
 0.0483  0.7256  0.1893
 0.5858  0.9245  0.3381
[ CPUFloatType{3,3} ]
ArmaMat:
   0.5359   0.0483   0.5858
   0.8038   0.7256   0.9245
   0.4289   0.1893   0.3381

>>> Note that ArmaMat is transposed <<<
ArmaMat:
        0   0.0483   0.5858
   0.8038   0.7256   0.9245
   0.4289   0.1893   0.3381

LibTorch:
 0.0000  0.8038  0.4289
 0.0483  0.7256  0.1893
 0.5858  0.9245  0.3381
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to OpenCV (copy 3x3 matrix):
LibTorch:
 0.9345  0.2252  0.8824
 0.1589  0.5000  0.2445
 0.2817  0.9171  0.0985
[ CPUFloatType{3,3} ]
cvMat:
[0.93447006, 0.22521371, 0.88243121;
 0.15889102, 0.49998826, 0.24453849;
 0.28167206, 0.91707569, 0.098504484]
cvMat:
[0, 0.22521371, 0.88243121;
 0.15889102, 0.49998826, 0.24453849;
 0.28167206, 0.91707569, 0.098504484]
LibTorch:
 0.9345  0.2252  0.8824
 0.1589  0.5000  0.2445
 0.2817  0.9171  0.0985
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to OpenCV (no-copy 3x3 matrix):
LibTorch:
 0.8951  0.6749  0.5910
 0.4645  0.5869  0.8185
 0.3054  0.2436  0.1431
[ CPUFloatType{3,3} ]
cvMat:
[0.89513969, 0.67485064, 0.59103107;
 0.46452171, 0.58691603, 0.81848794;
 0.30539364, 0.24357843, 0.14314771]
cvMat:
[0, 0.67485064, 0.59103107;
 0.46452171, 0.58691603, 0.81848794;
 0.30539364, 0.24357843, 0.14314771]
LibTorch:
 0.0000  0.6749  0.5910
 0.4645  0.5869  0.8185
 0.3054  0.2436  0.1431
[ CPUFloatType{3,3} ]
--------------------------------------------------
Testing LibTorch to ArrayFire (copy 3x3 matrix):
LibTorch:
 0.3460  0.3067  0.5854
 0.4485  0.6905  0.1162
 0.0131  0.4890  0.0255
[ CPUFloatType{3,3} ]
AfMat:
A
[3 3 1 1]
    0.3460     0.3067     0.5854
    0.4485     0.6905     0.1162
    0.0131     0.4890     0.0255

AfMat:
A
[3 3 1 1]
    0.0000     0.3067     0.5854
    0.4485     0.6905     0.1162
    0.0131     0.4890     0.0255

LibTorch:
 0.3460  0.3067  0.5854
 0.4485  0.6905  0.1162
 0.0131  0.4890  0.0255
[ CPUFloatType{3,3} ]

@andrewssobral andrewssobral self-assigned this May 18, 2024
@andrewssobral andrewssobral changed the title Support Lunix [solved] Support Linux May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants