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

Build problem about gtsam #7

Open
JIANG-CX opened this issue Dec 28, 2022 · 28 comments
Open

Build problem about gtsam #7

JIANG-CX opened this issue Dec 28, 2022 · 28 comments

Comments

@JIANG-CX
Copy link

When I run the command "cmake --build build_gtsam --config RelWithDebInfo -j", it gave an error as follows. Could you please help me to fix it? Thanks.

Traceback (most recent call last): File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/scripts/pybind_wrap.py", line 94, in <module> main() File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/scripts/pybind_wrap.py", line 90, in main wrapper.wrap(sources, args.out) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/pybind_wrapper.py", line 723, in wrap submodules=submodules) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/pybind_wrapper.py", line 624, in wrap_file module = parser.Module.parseString(content) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/interface_parser/module.py", line 56, in parseString return Module.rule.parseString(s)[0] File "/opt/ros/noetic/lib/python3/dist-packages/pyparsing/core.py", line 1141, in parse_string raise exc.with_traceback(None) pyparsing.exceptions.ParseException: Expected string_end, found 'namespace' (at char 1249), (line:46, col:1) make[2]: *** [python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/build.make:76: python/gtsam_unstable.cpp] Error 1 make[1]: *** [CMakeFiles/Makefile2:32620: python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

@pgaston
Copy link

pgaston commented Dec 28, 2022

Same issue here. New Ubuntu 20.04 install.

@hjxwhy
Copy link

hjxwhy commented Dec 29, 2022

@phamquandung I have done as you said, but I still have the problem. Which version pyparsing you used?

@JIANG-CX
Copy link
Author

@JIANG-CX, @pgaston I found the solution. Please go to the folder thirdparty and delete gtsam then git clone the updated (https://github.com/ToniRV/gtsam-1/tree/feature/nerf_slam). Then build again.

@ToniRV . I think you should update the gtsam in thirdparty to avoid this issue.

After downloading the new gtsam, I find this error still exists.

@phamquandung
Copy link

@JIANG-CX @pgaston @hjxwhy you can fork https://github.com/borglab/gtsam this one and build python wrapper like this https://github.com/borglab/gtsam/tree/develop/python. I tried, and it works.

@pgaston
Copy link

pgaston commented Dec 29, 2022

@phamquandung
Okay, still hung up here. I moved the gtsam you specified above and built it per instructions. However... when I run I get:

File "/home/pg/repos/NeRF-SLAM/./examples/../slam/vio_slam.py", line 65, in initial_state
naive_pose = gtsam.Pose3.identity()
AttributeError: type object 'gtsam.gtsam.Pose3' has no attribute 'identity'

Thoughts?

@richard7714
Copy link

richard7714 commented Dec 30, 2022

@phamquandung
Okay, still hung up here. I moved the gtsam you specified above and built it per instructions. However... when I run I get:

File "/home/pg/repos/NeRF-SLAM/./examples/../slam/vio_slam.py", line 65, in initial_state
naive_pose = gtsam.Pose3.identity()
AttributeError: type object 'gtsam.gtsam.Pose3' has no attribute 'identity'

Thoughts?

I think it's a problem of gtsam version. According to borglab/gtsam#1298, identity() was replaced to Identity() (UpperCase)

@phamquandung
Copy link

Then, another error:

File "/home/user/research/NeRF-SLAM/./examples/../slam/visual_frontends/visual_frontend.py", line 48, in gtsam_pose_to_torch
q = pose.rotation().quaternion()
AttributeError: 'gtsam.gtsam.Rot3' object has no attribute 'quaternion'

@richard7714
Copy link

richard7714 commented Dec 30, 2022

@phamquandung
Then, another error:

File "/home/user/research/NeRF-SLAM/./examples/../slam/visual_frontends/visual_frontend.py", line 48, in gtsam_pose_to_torch q = pose.rotation().quaternion() AttributeError: 'gtsam.gtsam.Rot3' object has no attribute 'quaternion'

That line and the following return statement should be replaced like this

    q = pose.rotation().toQuaternion()
    return torch.tensor([t[0], t[1], t[2], q.x(), q.y(), q.z(), q.w()], device=device, dtype=dtype)

@JIANG-CX
Copy link
Author

@JIANG-CX @pgaston @hjxwhy you can fork https://github.com/borglab/gtsam this one and build python wrapper like this https://github.com/borglab/gtsam/tree/develop/python. I tried, and it works.

Thanks for your kindly help. I can pass the build step now. But when I run the "./examples/slam_demo.py”, I find there is an error about the gtsam. I wonder have you met such error? How did you solve it? Thanks a lot.
File "./examples/slam_demo.py", line 200, in <module> run(args) File "./examples/slam_demo.py", line 143, in run slam_module.spin() # visualizer should be the main spin, but pytorch has a memory bug/leak if threaded... File "./examples/../pipeline/pipeline_module.py", line 88, in spin self.initialize_module() File "./examples/../slam/slam_module.py", line 18, in initialize_module from slam.vio_slam import VioSLAM File "./examples/../slam/vio_slam.py", line 9, in <module> from factor_graph.factor_graph import TorchFactorGraph File "./examples/../factor_graph/factor_graph.py", line 14, in <module> from gtsam import NonlinearFactorGraph as FactorGraph ModuleNotFoundError: No module named 'gtsam'

@phamquandung
Copy link

@JIANG-CX @pgaston @hjxwhy you can fork https://github.com/borglab/gtsam this one and build python wrapper like this https://github.com/borglab/gtsam/tree/develop/python. I tried, and it works.

Thanks for your kindly help. I can pass the build step now. But when I run the "./examples/slam_demo.py”, I find there is an error about the gtsam. I wonder have you met such error? How did you solve it? Thanks a lot. File "./examples/slam_demo.py", line 200, in <module> run(args) File "./examples/slam_demo.py", line 143, in run slam_module.spin() # visualizer should be the main spin, but pytorch has a memory bug/leak if threaded... File "./examples/../pipeline/pipeline_module.py", line 88, in spin self.initialize_module() File "./examples/../slam/slam_module.py", line 18, in initialize_module from slam.vio_slam import VioSLAM File "./examples/../slam/vio_slam.py", line 9, in <module> from factor_graph.factor_graph import TorchFactorGraph File "./examples/../factor_graph/factor_graph.py", line 14, in <module> from gtsam import NonlinearFactorGraph as FactorGraph ModuleNotFoundError: No module named 'gtsam'

In the build folder you should run make python-install and make python-test, then it should be OK.

@JIANG-CX
Copy link
Author

Yes, I have run make python-install and make python-test, and got the feedback "[100%] Built target python-test" and "Successfully installed gtsam-4.2a8". But the error still exits.

@jrpowers
Copy link
Contributor

jrpowers commented Jan 1, 2023

Maybe you installed gtsam to another python environment?

Also, I made a bunch the changes to adopt to new gtsam in this PR, in case it helps: #12

@sxyu
Copy link

sxyu commented Jan 1, 2023

Using the branch feature/nerf_slam https://github.com/ToniRV/gtsam-1/tree/feature/nerf_slam
I found that there is a syntax error in gtsam_unstable/gtsam_unstable.i
causing a parsing error:
virtual class LinearizedHessianFactor : gtsam::LinearizedGaussianFactor {
Needs to be closed 2 lines below (line 818) with };.

EDIT: the author has fixed it and the feature/nerf_slam branch of gtsam should be ok now.

@yzslab
Copy link

yzslab commented Jan 2, 2023

Maybe you installed gtsam to another python environment?

Also, I made a bunch the changes to adopt to new gtsam in this PR, in case it helps: #12

It works well! Nice job!

@pgaston
Copy link

pgaston commented Jan 2, 2023

@jrpowers Using your latest PR I got everything to build - whew. The cube sample scene runs fine! Unfortunately, the first example dies a horrible death... (perhaps I'll wait for the dust to settle on all these changes...) Thanks again to all!

(nerf) pg@pg-MS-7A59:~/repos/NeRF-SLAM$ python ./examples/slam_demo.py --dataset_dir=./datasets/Replica/office0 --dataset_name=nerf --buffer=100 --slam --img_stride=2 --fusion='nerf' --multi_gpu --gui
Running with GPUs: 0
Running pipeline in sequential mode.
Loading 1000 images.
  0%|                                                  | 0/1000 [00:00<?, ?it/s]/home/pg/miniconda3/envs/nerf/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
Segmentation fault (core dumped)

The "GPUs: 0" looks fishy. However, nvidia-smi; nvcc --version; and nvitop -- all seem to be showing the usual results.

@sxyu
Copy link

sxyu commented Jan 2, 2023

works fully for me with the fixed GTSAM from the author & (only) python changes in this repo made by jrpowers

@pengwangucla
Copy link

pengwangucla commented Jan 5, 2023

what is you gcc version or other environment setup ? , after switch the branch. met this error

/usr/include/c++/8/bits/alloc_traits.h:392:27: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using pointer = _Tp*;
                           ^
/usr/include/c++/8/bits/alloc_traits.h:395:39: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using const_pointer = const _Tp*;

Solved by checking:
image

works fully for me with the fixed GTSAM from the author & (only) python changes in this repo made by jrpowers

@JIANG-CX
Copy link
Author

JIANG-CX commented Jan 6, 2023

what is you gcc version or other environment setup ? , after switch the branch. met this error

/usr/include/c++/8/bits/alloc_traits.h:392:27: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using pointer = _Tp*;
                           ^
/usr/include/c++/8/bits/alloc_traits.h:395:39: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using const_pointer = const _Tp*;

Solved by checking: image

works fully for me with the fixed GTSAM from the author & (only) python changes in this repo made by jrpowers

I do not understand this comment. Could you tell me how to fix the linear.cpp? What's the "inner const X& ..." stands for?

@OceanYing
Copy link

what is you gcc version or other environment setup ? , after switch the branch. met this error

/usr/include/c++/8/bits/alloc_traits.h:392:27: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using pointer = _Tp*;
                           ^
/usr/include/c++/8/bits/alloc_traits.h:395:39: error: forming pointer to reference type ‘const Eigen::Matrix<double, -1, -1>&’
       using const_pointer = const _Tp*;

Solved by checking: image

works fully for me with the fixed GTSAM from the author & (only) python changes in this repo made by jrpowers

I do not understand this comment. Could you tell me how to fix the linear.cpp? What's the "inner const X& ..." stands for?

It seems that the solution comes from README installation-issues: 3. But i'm also not clear about the "inner const X& ..." and still stuck with this problem now. If you have figured it out, please let me know. @JIANG-CX @pengwangucla

@pengwangucla
Copy link

You may change const std::vector<const gtsam::Matrix&>& to const std::vector<gtsam::Matrix>& use & as pointer is not proper define of std::vector

@OceanYing
Copy link

You may change const std::vector<const gtsam::Matrix&>& to const std::vector<gtsam::Matrix>& use & as pointer is not proper define of std::vector

Thanks a lot! That's the solution and it works now!

@yusuf-wadi
Copy link

@JIANG-CX, @pgaston I found the solution. Please go to the folder thirdparty and delete gtsam then git clone the updated (https://github.com/ToniRV/gtsam-1/tree/feature/nerf_slam). Then build again.
@ToniRV . I think you should update the gtsam in thirdparty to avoid this issue.

After downloading the new gtsam, I find this error still exists.

this worked for me

@KnightOfTheMoonlight
Copy link

@phamquandung
Then, another error:
File "/home/user/research/NeRF-SLAM/./examples/../slam/visual_frontends/visual_frontend.py", line 48, in gtsam_pose_to_torch q = pose.rotation().quaternion() AttributeError: 'gtsam.gtsam.Rot3' object has no attribute 'quaternion'

That line and the following return statement should be replaced like this

    q = pose.rotation().toQuaternion()
    return torch.tensor([t[0], t[1], t[2], q.x(), q.y(), q.z(), q.w()], device=device, dtype=dtype)

Thanks for your reply! It saved my day! I have run into an error because of wrong modification of this.

My wrong version is pose.rotation().toQuaternion().coeffs();
This modification leads q to all nan

@Tonny24Wang
Copy link

When I run the command "cmake --build build_gtsam --config RelWithDebInfo -j", it gave an error as follows. Could you please help me to fix it? Thanks.

Traceback (most recent call last): File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/scripts/pybind_wrap.py", line 94, in <module> main() File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/scripts/pybind_wrap.py", line 90, in main wrapper.wrap(sources, args.out) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/pybind_wrapper.py", line 723, in wrap submodules=submodules) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/pybind_wrapper.py", line 624, in wrap_file module = parser.Module.parseString(content) File "/home/jiangcx/Documents/Nerf_related/NeRF-SLAM/thirdparty/gtsam/wrap/gtwrap/interface_parser/module.py", line 56, in parseString return Module.rule.parseString(s)[0] File "/opt/ros/noetic/lib/python3/dist-packages/pyparsing/core.py", line 1141, in parse_string raise exc.with_traceback(None) pyparsing.exceptions.ParseException: Expected string_end, found 'namespace' (at char 1249), (line:46, col:1) make[2]: *** [python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/build.make:76: python/gtsam_unstable.cpp] Error 1 make[1]: *** [CMakeFiles/Makefile2:32620: python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

thirdparty/gtsam/gtsam_unstable/gtsam_unstable.i
815,1: virtual class LinearizedHessianFactor : gtsam::LinearizedGaussianFactor {
这个类结尾 少了两个字符 }; ,加上即可

@SimonsRoad
Copy link

try "git clone https://github.com/ToniRV/gtsam-1"
then cmake it!

@lllray
Copy link

lllray commented Sep 24, 2023

try "git clone https://github.com/ToniRV/gtsam-1" then cmake it!

this worked for me.

@wbjsamuel
Copy link

@jrpowers Using your latest PR I got everything to build - whew. The cube sample scene runs fine! Unfortunately, the first example dies a horrible death... (perhaps I'll wait for the dust to settle on all these changes...) Thanks again to all!

(nerf) pg@pg-MS-7A59:~/repos/NeRF-SLAM$ python ./examples/slam_demo.py --dataset_dir=./datasets/Replica/office0 --dataset_name=nerf --buffer=100 --slam --img_stride=2 --fusion='nerf' --multi_gpu --gui
Running with GPUs: 0
Running pipeline in sequential mode.
Loading 1000 images.
  0%|                                                  | 0/1000 [00:00<?, ?it/s]/home/pg/miniconda3/envs/nerf/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '
Segmentation fault (core dumped)

The "GPUs: 0" looks fishy. However, nvidia-smi; nvcc --version; and nvitop -- all seem to be showing the usual results.

Hi I also met this segmentation fault error. Could you please tell me how did you solve this issue? Thx a lot!

@Zhangxr02
Copy link

@JIANG-CX @pgaston @hjxwhy you can fork https://github.com/borglab/gtsam this one and build python wrapper like this https://github.com/borglab/gtsam/tree/develop/python. I tried, and it works.

Thanks for your kindly help. I can pass the build step now. But when I run the "./examples/slam_demo.py”, I find there is an error about the gtsam. I wonder have you met such error? How did you solve it? Thanks a lot. File "./examples/slam_demo.py", line 200, in <module> run(args) File "./examples/slam_demo.py", line 143, in run slam_module.spin() # visualizer should be the main spin, but pytorch has a memory bug/leak if threaded... File "./examples/../pipeline/pipeline_module.py", line 88, in spin self.initialize_module() File "./examples/../slam/slam_module.py", line 18, in initialize_module from slam.vio_slam import VioSLAM File "./examples/../slam/vio_slam.py", line 9, in <module> from factor_graph.factor_graph import TorchFactorGraph File "./examples/../factor_graph/factor_graph.py", line 14, in <module> from gtsam import NonlinearFactorGraph as FactorGraph ModuleNotFoundError: No module named 'gtsam'

Hello, I have the same problem when I run the demo. Although I have update gtsam and torch118, it didn't work. So how did you solve the problem(No module named 'gtsam')?

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