erwincoumans / tiny-differentiable-simulator

Tiny Differentiable Simulator is a header-only C++ and CUDA physics library for reinforcement learning and robotics with zero dependencies.
Apache License 2.0
1.2k stars 129 forks source link

Problem with running ARS CUDA training demos #118

Closed Shah-Rajab closed 3 years ago

Shah-Rajab commented 3 years ago

Hi,

I used the following commands:

git clone --recurse-submodules -j12 git@github.com:google-research/tiny-differentiable-simulator.git
cd tiny-differentiable-simulator
mkdir build
cd build
cmake ..
make -j

And when I run ars_train_policy_cuda it complains about not finding the correct file(s):

X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Created GL 3.3 context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=NVIDIA Corporation
GL_RENDERER=GeForce GTX 1050 Ti/PCIe/SSE2
GL_VERSION=3.3.0 NVIDIA 460.80
GL_SHADING_LANGUAGE_VERSION=3.30 NVIDIA via Cg compiler
pthread_getconcurrency()=0
Version = 3.3.0 NVIDIA 460.80
Vendor = NVIDIA Corporation
Renderer = GeForce GTX 1050 Ti/PCIe/SSE2
Loading URDF "/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/data/plane_implicit.urdf".
Could not find file "laikago/laikago_toes_zup_xyz_xyzrot.urdf".
Loading URDF "../../tds/data/laikago/laikago_toes_zup_xyz_xyzrot.urdf".
Error, cannot open file_name: ../../tds/data/laikago/laikago_toes_zup_xyz_xyzrot.urdf

I added USE_ANT flag in ars_train_policy_cuda.cpp and I seem to miss another file:

X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Created GL 3.3 context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=NVIDIA Corporation
GL_RENDERER=GeForce GTX 1050 Ti/PCIe/SSE2
GL_VERSION=3.3.0 NVIDIA 460.80
GL_SHADING_LANGUAGE_VERSION=3.30 NVIDIA via Cg compiler
pthread_getconcurrency()=0
Version = 3.3.0 NVIDIA 460.80
Vendor = NVIDIA Corporation
Renderer = GeForce GTX 1050 Ti/PCIe/SSE2
Loading URDF "/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/data/plane_implicit.urdf".
Loading URDF "/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/data/gym/ant_org_xyz_xyzrot.urdf".
Could not find file "cuda_model_ant.so".
terminate called after throwing an instance of 'std::runtime_error'
  what():  Failed to dynamically load library 'cuda_model_ant': ../../tds/data/cuda_model_ant.so: cannot open shared object file: No such file or directory
Aborted (core dumped)

I tried adding the -D USE_CPPAD=ON with cmake command and I am getting compilation errors:

In file included from /home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/cuda_laikago_codegen.cpp:21:
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h: In instantiation of ‘std::vector<typename Algebra::Scalar> ContactSimulation<Algebra>::operator()(const std::vector<typename Algebra::Scalar>&) [with Algebra = tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > >; typename Algebra::Scalar = CppAD::AD<CppAD::cg::CG<double> >]’:
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/cuda_laikago_codegen.cpp:58:21:   required from here
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h:111:29: error: conversion from ‘double’ to non-scalar type ‘ContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  111 |                 Scalar kp = 100.;
      |                             ^~~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h:112:29: error: conversion from ‘double’ to non-scalar type ‘ContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  112 |                 Scalar kd = 2.;
      |                             ^~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h:113:36: error: conversion from ‘double’ to non-scalar type ‘ContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  113 |                 Scalar max_force = 50.;
      |                                    ^~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h:130:51: error: conversion from ‘double’ to non-scalar type ‘ContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  130 |                             Scalar ACTION_LIMIT = 0.4;
      |                                                   ^~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/laikago_environment.h:140:55: error: conversion from ‘int’ to non-scalar type ‘ContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  140 |                             Scalar desired_velocity = 0;
      |                                                       ^
In file included from /home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/cuda_ant_codegen.cpp:26:
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h: In instantiation of ‘AntContactSimulation<Algebra>::AntContactSimulation() [with Algebra = tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > >]’:
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/cuda_ant_codegen.cpp:51:37:   required from here
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:79:43: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
   79 |         Scalar combinedContactStiffness = 1.;
      |                                           ^~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:80:41: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
   80 |         Scalar combinedContactDamping = .1;
      |                                         ^~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h: In instantiation of ‘std::vector<typename Algebra::Scalar> AntContactSimulation<Algebra>::operator()(const std::vector<typename Algebra::Scalar>&) [with Algebra = tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > >; typename Algebra::Scalar = CppAD::AD<CppAD::cg::CG<double> >]’:
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/cuda_ant_codegen.cpp:65:21:   required from here
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:149:33: error: conversion from ‘int’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  149 |                     Scalar kp = 15;
      |                                 ^~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:150:33: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  150 |                     Scalar kd = 0.3;
      |                                 ^~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:151:40: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  151 |                     Scalar max_force = 3.;
      |                                        ^~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:166:40: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  166 |                                 Scalar ACTION_LIMIT_LOW = (i%2==0)? -0.5 : -1.1+0.5;
      |                                        ^~~~~~~~~~~~~~~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:167:40: error: conversion from ‘double’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  167 |                                 Scalar ACTION_LIMIT_HIGH = (i%2==0)? 0.5 : 0;
      |                                        ^~~~~~~~~~~~~~~~~
/home/shahryar/hdd/test-diff/tiny-differentiable-simulator/examples/environments/ant_environment.h:177:59: error: conversion from ‘int’ to non-scalar type ‘AntContactSimulation<tds::EigenAlgebraT<CppAD::AD<CppAD::cg::CG<double> > > >::Scalar’ {aka ‘CppAD::AD<CppAD::cg::CG<double> >’} requested
  177 |                                 Scalar desired_velocity = 0;
      | 

I was wondering if the way I tried to build the source for these demos are the right way.

erwincoumans commented 3 years ago

You can try running the build_libs_windows.bat or build_libs_unix.sh script, those perform the required preparation. Then, before running the ARS CUDA training, you need to run another example that compiles the missing CUDA library (so) file. It may require more time/effort to get familiar with the setup, it is early work-in-progress.