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

MPC examples do not work #344

Open
FenglongSong opened this issue May 24, 2024 · 0 comments
Open

MPC examples do not work #344

FenglongSong opened this issue May 24, 2024 · 0 comments

Comments

@FenglongSong
Copy link

🐛 Describe the bug

Hi,

Thanks for developing this great repo. I'm interested in using the MPC modules of pypose. When I tried to run both examples in examples/mpc/ folder, I got some errors.

  1. This is what I got when running examples/module/mpc/cartpole.py:
(leggedrobot) ➜  pypose git:(main) ✗ python3 examples/module/mpc/cartpole.py
Namespace(device='cpu', save='./examples/module/mpc/save/', show=False)
Traceback (most recent call last):
  File "/Users/fenglongsong/Documents/GitHub/pypose/examples/module/mpc/cartpole.py", line 104, in <module>
    traj_loss.backward()
  File "/Users/fenglongsong/miniconda3/envs/leggedrobot/lib/python3.10/site-packages/torch/_tensor.py", line 522, in backward
    torch.autograd.backward(
  File "/Users/fenglongsong/miniconda3/envs/leggedrobot/lib/python3.10/site-packages/torch/autograd/__init__.py", line 266, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: Output 3 of UnbindBackward0 is a view and its base or another view of its base has been modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.
  1. This is what I got when running examples/module/mpc/linear.py:
(leggedrobot) ➜  pypose git:(main) ✗ python3 examples/module/mpc/linear.py
Namespace(device='cpu', save='./examples/module/mpc/save/', show=False)
Traceback (most recent call last):
  File "/Users/fenglongsong/Documents/GitHub/pypose/examples/module/mpc/linear.py", line 81, in <module>
    traj_loss.backward()
  File "/Users/fenglongsong/miniconda3/envs/leggedrobot/lib/python3.10/site-packages/torch/_tensor.py", line 522, in backward
    torch.autograd.backward(
  File "/Users/fenglongsong/miniconda3/envs/leggedrobot/lib/python3.10/site-packages/torch/autograd/__init__.py", line 266, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [5, 3]], which is output 0 of AsStridedBackward0, is at version 4; expected version 3 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

I'm not sure if this is a common issue. Can anyone provide any idea to fix it? Thanks a lot.

Best,
Fenglong

Versions

I'm running the example on MacOS with M2-chip, under conda environment.

(leggedrobot) ➜  pypose git:(main) ✗ python collect_env.py
Collecting environment information...
PyTorch version: 2.2.2
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 14.5 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.3.9.4)
CMake version: version 3.29.2
Libc version: N/A

Python version: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:41:52) [Clang 15.0.7 ] (64-bit runtime)
Python platform: macOS-14.5-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.2.2
[pip3] torchkin==0.1.1
[pip3] torchlie==0.1.0
[pip3] torchvision==0.17.2
[conda] numpy                     1.26.4          py310h3b2db8e_0
[conda] numpy-base                1.26.4          py310ha9811e2_0
[conda] torch                     2.2.2                    pypi_0    pypi
[conda] torchkin                  0.1.1                    pypi_0    pypi
[conda] torchlie                  0.1.0                    pypi_0    pypi
[conda] torchvision               0.17.2                   pypi_0    pypi
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

1 participant