GithubHelp home page GithubHelp logo

williamljb / differentiablecloth Goto Github PK

View Code? Open in Web Editor NEW
74.0 4.0 16.0 31.78 MB

Makefile 0.10% HTML 6.54% C++ 52.49% C 4.02% Python 0.29% Batchfile 0.02% MATLAB 0.01% Shell 0.03% Mathematica 36.45% Haskell 0.04%

differentiablecloth's Introduction

Differentiable Cloth Simulation for Inverse Problems

Junbang Liang, Ming C. Lin, Vladlen Koltun. NeurIPS 2019.

Project Page

Requirements

  • Python 3.6.4
  • PyTorch tested on version 1.0.1
  • CUDA 9.2.148
  • cuDNN 7.0.5
  • Pybind11
  • BLAS
  • Boost
  • freeglut
  • gfortran
  • LAPACK
  • libpng

Build

  1. Build the dependencies:
cd ${root}/arcsim/dependencies; make
  1. Setup python libraries:
cd ${root}; make

To use the simulator:

import torch
import arcsim

For APIs of the simulator, please refer to pybind/bind.cpp.

Demo

As the first step, link the simulation-related directories to the demo path:

cd demo
ln -s ../arcsim/conf .
ln -s ../arcsim/meshes .
ln -s ../arcsim/materials .

Simple Optimization of Gravity Force

The goal is to optimize the gravity force so that the center of mass of the cloth has the largest z coordinate after 1 second. Execution command:

python demo_gravity.py

Collision Stress Test

This is the ablation study mentioned in the paper. To see the backward timing, first uncomment Line 17 of pysim/collision_py.py. Execution command:

python demo_collision.py ${log_dir}

Material Parameter Optimization

The goal is to optimize the density, stretching and bending parameters of the cloth so that the cloth behaves the same as observed. Execution command:

python demo_wind.py ${log_dir} ${observed_data_dir} ${gt_material_file}

Motion Control

The goal is to find appropriate control forces (expressed as additional velocity very step) of the four corners of the cloth so that the cloth can be lifted and dropped down to the given basket, while avoiding the obstacles on the way. Execution command:

python demo_throw.py ${log_dir}

There is another approach of this task which is to use a simple neural network to decide the forces:

python demo_embed.py ${log_dir}

Citation

If you use this code for your research, please consider citing:

@inProceedings{liang2019differentiable,
  title={Differentiable Cloth Simulation for Inverse Problems},
  author = {Junbang Liang and Ming C. Lin and Vladlen Koltun},
  booktitle={Conference on Neural Information Processing Systems (NeurIPS)},
  year={2019}
}

differentiablecloth's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

differentiablecloth's Issues

GPU/CPU parallelization

Hello,

Thanks for sharing this project and releasing the code. This is really cool work!

In demo_{}.py examples, I noticed that PyTorch threads are set for CPU parallelization using torch.set_num_threads(8). However, I fail to see any performance speed-up/degradation when the number of threads is varied (I tried with num_threads = 1, 2, 4, 8). I am running against a server with 64 physical (or 256 logical) CPUs available. Are the forward and backward pass both expected to benefit from multi-threading (say 8 cpu vs. 1 cpu)?

On another note, is CUDA used in the project or experimental? All the tensors seem to be loaded in CPU device, it's not clear to me if GPUs are actually leveraged in C++/PyTorch parts of the source code.

I am working with high resolution meshes, so looking for ways to train the experiments as faster as possible.

Compile Error

I encounter an error when I make in the {root} directory:
fatal error: torch/extension.h: No such file or directory #include <torch/extension.h>
I saw other issues reporting the same error, and I know that I should download the zip file from https://pytorch.org/cppdocs/installing.html. But after I unzip it, I don't know what I should do next to pass the compile. I try many things but failed.
Can you give me some insturctions?
Beg for your reply!
Thanks!

Possibilty of controling cloth by external force?

Hi Junbang, I have a question regarding the Motion Control demo.
I notice that you express control forces as additional velocity very step. I'm wondering is there any other ways to express force in this simulator like directly using force to control.
I briefly look through the bind.cpp API, and I find no such function that can enable me to do so.

Compile error

When I run demo_gravity, I encounter error below:

Traceback (most recent call last):
File "demo_gravity.py", line 2, in
import arcsim
ImportError: /home/siheng/miniconda3/envs/diffcloth/lib/python3.6/site-packages/arcsim-0.0.0-py3.6-linux-x86_64.egg/arcsim.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTIN3c1021AutogradMetaInterfaceE

My platform is Ubuntu20.04 and I my gcc/g++ version is both 8.4.0.

compile problem

when I do the second make in the root directory, the error occurs:

arcsim/src/util.hpp: At global scope:
arcsim/src/vectors.hpp:56:58: error: expected ‘)’ before ‘*’ token
 #define infinity (std::numeric_limits<double>::infinity()*ONE)
                                                          ^
arcsim/src/util.hpp:64:21: note: in expansion of macro ‘infinity’
 extern const Tensor infinity;
                     ^
arcsim/src/vectors.hpp:52:28: error: expected unqualified-id before ‘,’ token
 #define ONE (torch::ones({}, TNOPT))
                            ^
arcsim/src/vectors.hpp:56:59: note: in expansion of macro ‘ONE’
 #define infinity (std::numeric_limits<double>::infinity()*ONE)
                                                           ^
arcsim/src/util.hpp:64:21: note: in expansion of macro ‘infinity’
 extern const Tensor infinity;
                     ^
arcsim/src/vectors.hpp:52:35: error: expected constructor, destructor, or type conversion before ‘)’ token
 #define ONE (torch::ones({}, TNOPT))

Compilation failure

Hi,
First, thanks for sharing your project.
I run into a problem when trying to compile the project. When I try to build the dependencies, I get the following error while attempting to build TAUCS:

Screenshot from 2020-08-17 03-34-13

Am I missing a dependency? (did I have to install cilk?)

I just want to mention that I run Ubuntu 20.04 with GCC9.

Which Ubuntu/GCC do you use to build the project?

Thanks

/usr/bin/ld: final link failed: bad value

Hi, I have successfully dependencies file but when I "make" in main dir, I got the error like this:

building 'arcsim' extension
Emitting ninja build file /home/yizhouch/Downloads/DifferentiableCloth/build/temp.linux-x86_64-3.8/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 /home/yizhouch/Downloads/DifferentiableCloth/build/temp.linux-x86_64-3.8/pybind/bind.o -Lobjs -L./arcsim/dependencies/lib -L/home/yizhouch/.local/lib/python3.8/site-packages/torch/lib -lmake_pytorch -ljson -ltaucs -lalglib -lpng -lz -llapack -lblas -lboost_system -lboost_filesystem -lboost_thread -lgomp -lglut -lGLU -lGL -lGLdispatch -lc10 -ltorch -ltorch_cpu -ltorch_python -o build/lib.linux-x86_64-3.8/arcsim.cpython-38-x86_64-linux-gnu.so
/usr/bin/ld: ./arcsim/dependencies/lib/libjson.a(json_reader.o): relocation R_X86_64_PC32 against symbol `_ZN4Json5Value6minIntE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
make: *** [Makefile:65: all] Error 1

Possibility of supporting per-frame obstacle

Thanks for this awesome project and release of the code. I am new to simulation and I am wondering whether this simulator supports per-frame obstacles, a sequence of meshes generated from linear blend skinning. I briefly studied the configuration interface, and it seems to me that this is not easily achievable. I would appreciate it if the author can provide some insight.

compile failure

when I cd arcsim/dependencies and make,I got the error as follows:
make
cd jsoncpp && /scratch0/scons/bin/scons platform=linux-gcc
/bin/sh: 1: /scratch0/scons/bin/scons: not found
Makefile:12: recipe for target 'lib/libjson.a' failed
make: *** [lib/libjson.a] Error 127

Compile Problem

When I try to make the project, there is an error:

/usr/bin/ld: ./arcsim/dependencies/lib/libtaucs.a(taucs_linsolve.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
./arcsim/dependencies/lib/libtaucs.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

I try to change the Makefile in /dependencies/ like

cd taucs &&./configure --cc="gcc -m6 -fPIC" --enable-shared module=!METIS && $(MAKE)

but it not works.

What should I do to solve the problem?

Material estimation experiment

I have a question regarding the material estimation experiment. Did you obtain the observation from the original ArcSim simulator or this differentiable simulator?

In addition, I realize there is some difference between the implementation ArcSim and this one. For example, this simulator does not run relax_initial_state during the initialization. Is there a brief description of what has been changed, besides the apparent fact that this one is using torch::Tensor and has gradient computation?

Thanks.

compile failure

/home/zitman/anaconda3/envs/phi_sft/lib/python3.6/site-packages/torch/include/ATen/ParallelOpenMP.h:84: warning: ignoring #pragma omp parallel [-Wunknown-pragmas] 84 | #pragma omp parallel for if ((end - begin) >= grain_size) | /home/zitman/DifferentiableCloth-master/pybind/bind.cpp:4:10: fatal error: collision.hpp: no such file or directory 4 | #include "collision.hpp" | ^~~~~~~~~~~~~~~ compilation terminated. ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/zitman/anaconda3/envs/phi_sft/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1515, in _run_ninja_build env=env) File "/home/zitman/anaconda3/envs/phi_sft/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

I searched the source file collision.hpp to find this problem, but an error will be reported when compiling

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.