# 1) install anaconda (https://docs.anaconda.com/free/anaconda/install/linux/)
# 2) install docker-ce (https://docs.docker.com/engine/install/ubuntu/)
# 3) install nvidia-container-toolkit (https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
# 4) restart docker by `sudo systemctl restart docker` (docker service name can be found by `sudo systemctl list-units --type=service | grep -i docker`)
# preparations
cd third-party
git clone git@github.com:kywind/PyFleX.git
conda install pybind11 -c conda-forge # or pip install "pybind11[global]"
sudo docker pull xingyu/softgym
# compile pyflex in docker image
# re-compile if source code changed
# make sure ${PWD}/PyFleX is the pyflex root path when re-compiling
sudo docker run \
-v ${PWD}/PyFleX:/workspace/PyFleX \
-v ${CONDA_PREFIX}:/workspace/anaconda \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--gpus all \
-e DISPLAY=$DISPLAY \
-e QT_X11_NO_MITSHM=1 \
-it xingyu/softgym:latest bash \
-c "export PATH=/workspace/anaconda/bin:$PATH; cd /workspace/PyFleX; export PYFLEXROOT=/workspace/PyFleX; export PYTHONPATH=/workspace/PyFleX/bindings/build:$PYTHONPATH; export LD_LIBRARY_PATH=$PYFLEXROOT/external/SDL2-2.0.4/lib/x64:$LD_LIBRARY_PATH; cd bindings; mkdir build; cd build; /usr/bin/cmake ..; make -j"
# run these if you do not have these paths yet in ~/.bashrc
echo '# PyFleX' >> ~/.bashrc
echo "export PYFLEXROOT=${PWD}/PyFleX" >> ~/.bashrc
echo 'export PYTHONPATH=${PYFLEXROOT}/bindings/build:$PYTHONPATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=${PYFLEXROOT}/external/SDL2-2.0.4/lib/x64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo '' >> ~/.bashrc
# finally, restart the terminal
click on /PyFleX/precompiled_demo/linux64/NvFlexDemoReleaseCUDA_x64 or run ./precompiled_demo/linux64/NvFlexDemoReleaseCUDA_x64 inside /PyFleX.
python examples/test_BoxBath.py
NOTE: Not all scenes are supported yet. (I'm working on this now.) Check example python files under examples/ for supported scenes!
# Example usage
scene_idx = your_scene_idx
scene_params = np.array([your_scene_params])
pyflex.set_scene(scene_idx, scene_params, 0)
| scene_idx | Source |
|---|---|
| 0 | bindings/scenes/yz_bunnybath.h |
| 1 | bindings/scenes/yz_boxbath.h |
| 2 | bindings/scenes/yz_boxbathext.h |
| 3 | bindings/scenes/yz_dambreak.h |
| 4 | bindings/scenes/yz_rigidfall.h |
| 5 | bindings/scenes/yz_ricefall.h |
| 6 | bindings/scenes/yz_softbody.h |
| 7 | bindings/scenes/yz_fluidshake.h |
| 8 | bindings/scenes/yz_fluidiceshake.h |
| 9 | bindings/scenes/yz_massrope.h |
| 10 | bindings/scenes/yz_flag.h |
| 11 | bindings/scenes/yz_softrod.h |
| 12 | bindings/scenes/yz_clothrigid.h |
| 13 | bindings/scenes/yz_granular.h |
| 14 | bindings/scenes/yz_bunnygrip.h |
| 15 | bindings/scenes/yz_clothmanip.h |
| 16 | bindings/scenes/yz_softfall.h |
| 17 | bindings/scenes/yz_fluidpour.h |
| 18 | bindings/scenes/yz_granularmanip.h |
| 19 | bindings/scenes/yz_fluid_and_box.h |
| 20 | bindings/scenes/yx_coffee.h |
| 21 | bindings/scenes/yx_capsule.h |
| 22 | bindings/scenes/yx_carrots.h |
| 23 | bindings/scenes/yx_coffee_capsule.h |
| 24 | bindings/scenes/by_apple.h |
| 25 | bindings/scenes/by_singleycb.h |
| 26 | bindings/scenes/by_softrope.h |
| 27 | bindings/scenes/by_cloth.h |
| 28 | bindings/scenes/by_multiycb.h |
| 29 | bindings/scenes/by_softgym_cloth.h |
| 30 | bindings/scenes/softgym_cloth_2.h |
| 31 | bindings/scenes/by_roperigid.h |
| 32 | bindings/scenes/by_rigidgranular.h |
| 33 | bindings/scenes/by_rigidcloth.h |
| 34 | bindings/scenes/by_ropecloth.h |
| 35 | bindings/scenes/by_granular.h |
| 36 | bindings/scenes/by_bowlfluid.h |
| 37 | bindings/scenes/by_softbody.h |
| 38 | bindings/scenes/by_ropegranular.h |
| 39 | bindings/scenes/by_rigidrope.h |