Git Product home page Git Product logo

pyflex's Introduction

PyFleX

NVIDIA FleX is an amazing particle-based simulator for simulating interactions between rigid bodies, fluids, clothing, etc. In this repo, we have developed Python bindings for setting up and interacting with a few enviroments that we can used to evaluate different simulation and control algorithms.

Citing

If you find this codebase useful in your research, please consider citing:

@article{li2018learning,
  title={Learning particle dynamics for manipulating rigid bodies, deformable objects, and fluids},
  author={Li, Yunzhu and Wu, Jiajun and Tedrake, Russ and Tenenbaum, Joshua B and Torralba, Antonio},
  journal={arXiv preprint arXiv:1810.01566},
  year={2018}
}

@article{macklin2014unified,
  title={Unified particle physics for real-time applications},
  author={Macklin, Miles and M{\"u}ller, Matthias and Chentanez, Nuttapong and Kim, Tae-Yong},
  journal={ACM Transactions on Graphics (TOG)},
  volume={33},
  number={4},
  pages={1--12},
  year={2014},
  publisher={ACM New York, NY, USA}
}

Using Docker

If you are using Ubuntu 16.04 LTS and CUDA 9.1, you can continue with the steps on this page for compilation. If you are using newer versions of Ubuntu or CUDA, we provide the pre-built Docker image and Dockerfile for compiling PyFleX. Please refer to our Docker page.

Prerequisite

This codebase is tested with Ubuntu 16.04 LTS and CUDA 9.1. Other versions might work but are not guaranteed. Following command will install some necessary dependencies.

sudo apt-get install build-essential libgl1-mesa-dev freeglut3-dev

Compile and play with the original demo provided by NVIDIA FleX

First compile the demo

cd demo/compiler/makelinux64/
make -j

Then go to the target folder and start the demo!

cd ../../../bin/linux64
./NvFlexDemoReleaseCUDA_x64

Compile PyFleX with CMake & Pybind11

Go to the root folder of PyFleX, and set up paths

export PYFLEXROOT=${PWD}
export PYTHONPATH=${PYFLEXROOT}/bindings/build:$PYTHONPATH
export LD_LIBRARY_PATH=${PYFLEXROOT}/external/SDL2-2.0.4/lib/x64:$LD_LIBRARY_PATH

Compile PyFleX

cd bindings/
mkdir build; cd build; cmake ..; make -j

Try with FluidFall example. A window will pop up showing the simulation results.

cd ${PYFLEXROOT}/bindings/examples
python test_FluidFall.py

Demo

Following we provided 6 environments for you to play with. Directly run the python scripts to see the simulation results. Screenshots will be stored in ${PYFLEXROOT}/bindings/examples/test_[env]/.

FluidFall - Two drops of high-viscosity fluids are falling down and merging with each other.

cd ${PYFLEXROOT}/bindings/examples
python test_FluidFall.py

BoxBath - A block of water is flushing a rigid cube.

cd ${PYFLEXROOT}/bindings/examples
python test_BoxBath.py

FluidShake - Shake a box of fluids. The following script will first simulate the scene, and then playback the motion of the particles with the frontal wall removed for visualization.

cd ${PYFLEXROOT}/bindings/examples
python test_FluidShake.py

RiceGrip - Grip an object that can deform both elastically and plastically (e.g., sticky rice).

cd ${PYFLEXROOT}/bindings/examples
python test_RiceGrip.py

RigidFall - A stack of rigid cubes falling down.

cd ${PYFLEXROOT}/bindings/examples
python test_RigidFall.py

FluidIceShake - Shake a box of fluids and a rigid cube. The following script will first simulate the scene, and then playback the motion of the particles with the frontal wall removed for visualization.

cd ${PYFLEXROOT}/bindings/examples
python test_FluidIceShake.py

APIs

Please see the example test scripts and the bottom of bindings/pyflex.cpp for available APIs.

References

pyflex's People

Contributors

yunzhuli avatar

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  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  avatar

pyflex's Issues

Could not initialize GL extensions

I follow the steps of "Compile PyFleX with CMake & Pybind11" to install pyflex. After the installation, i have problem to run the example "test_FluidFall.py". The message shows in the terminal is in the following.

Could not initialize GL extensions
Segmentation fault (core dumped)

Many thanks if anyone can help me solve the issue.

cmakelist for windows

Hello,

I'd like to use this for a project for one of my classes but I am not familiar with cmake. I am trying to hack something together but it would be awesome to have a cmakelist for building it out on windows.

  • Steve

** Stack Smashing Detected ** at pyflex.init(True, False)

Hi,

Following ReadME, I build the library successfully. I can also run ./NvFlexDemoReleaseCUDA_x64 just fine.

But when I try running python test_FluidFall.py, I get Stack Smashing Detected, Core Dumped. I could also reproduce this error with the following code:

import pyflex
pyflex.init(True, False)        # any combination of True/False outputs the same error

Any insight would be very helpful. Please let me know if I should provide some specific information about my machine. Thanks!

Error using outside docker environment

I have built PyFlex in the docker environment and the outputs are like
-- Configuring done -- Generating done -- Build files have been written to: /workspace/PyFleX/bindings/build
after cmake .. and
[100%] Built target pyflex
after make -j

However, when I moved out of the docker environment and try to use PyFleX, I first executed commands to export environment paths and I can import pyflex in python. When I try to run pyflex.init(), this error happens,
Reshaping Flex: Could not open CUDA driver, ensure you have the latest driver (nvcuda.dll) installed and an NVIDIA GPU present on the system - ./../../../src/cuda/util.cpp:124 Flex: Could not initialize CUDA driver - ../../../src/cuda/flex.cu:4624 Could not initialize Flex, exiting.

But I checked I have the CUDA driver installed by running cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 440.82 Wed Apr 1 20:04:33 UTC 2020 GCC version: gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)

I wonder if you had a similar experience before and I am looking forward to your help.

compile the headless mode

Hi Yunzhu,

I'm wondering if it is possible to disable the display and compile the NVidia Flex in a headless mode such that we could run the simulation faster without generating images. I really appreciate it if you could give me some suggestions on this.

Thanks a lot

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.