Inverse Kinematics has different results on the CPU and GPU [full MWE provided]

Update: never mind, I figured out the issue in this post, it’s explained here:

In this piece of text:

Below is a copy of the original post I made. Note that it still doesn’t resolve my first post about the simulation difference in CPU or GPU but it does resolve a confusion I had about use_gpu.




Following up on this, I have been doing more testing I noticed there is actually a third variant of “CPU vs GPU mode”. If we comment out this line in the MWE:

#args.use_gpu = args.use_gpu_pipeline

Then the strange part is, running the MWE will print:

(rlgpu) seita@takeshi:~/Downloads/MWE_UR5_IK$ python UR5_IK.py --pipeline=cpu
Importing module 'gym_37' (/home/seita/isaacgym/python/isaacgym/_bindings/linux-x86_64/gym_37.so)
Setting GYM_USD_PLUG_INFO_PATH to /home/seita/isaacgym/python/isaacgym/_bindings/linux-x86_64/usd/plugInfo.json
PyTorch version 1.12.1
Device count 2
/home/seita/isaacgym/python/isaacgym/_bindings/src/gymtorch
Using /home/seita/.cache/torch_extensions/py37_cu113 as PyTorch extensions root...
Emitting ninja build file /home/seita/.cache/torch_extensions/py37_cu113/gymtorch/build.ninja...
Building extension module gymtorch...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module gymtorch...
args: Namespace(compute_device_id=0, flex=False, graphics_device_id=0, num_envs=16, num_threads=0, physics_engine=SimType.SIM_PHYSX, physx=False, pipeline='cpu', seed=10, sim_device='cuda:0', sim_device_type='cuda', slices=0, subscenes=0, use_gpu=True, use_gpu_pipeline=False)
device: cpu
Not connected to PVD
+++ Using GPU PhysX
Physics Engine: PhysX
Physics Device: cuda:0
GPU Pipeline: disabled

The relevant part is the last few lines. It shows the GPU pipeline is “disabled” … but also that the physics device is cuda:0 and that it prints +++ Using GPU PhysX.

and the debugging test shows that this mode will result in the same strange behavior as python UR5_IK.py --pipeline=gpu. In other words, it produces the IK behavior which doesn’t get the EE tip to coincide with the target.

So, I’m also somewhat confused about what running in “CPU mode” vs “GPU mode” means, since there are 3 variants I’m observing.

  • The best-performing variant is “CPU mode via --pipeline=cpu but with physics device as cpu”.
  • The two other variants perform the same but don’t seem to be that well, they are “CPU mode via --pipeline=cpu but with physics device as cuda” and “GPU mode via --pipeline-gpu with physics device as cuda”.

I see where args.use_gpu is set in the Isaac Gym code (it’s in isaacgym/gymutil.py) though.