cudaExternamMemoryGetMappedBuffer failed when creating camera IsaacGym

I am trying to create a camera with GPUs enabled with IsaacGym. However, it is giving me an error. I am not sure why. It occurs on the line camera_handle = self.gym.create_camera_sensor(env_handle, camprops) and only happens when camprops.enable_tensors is True. I have tried this post but it seg faults other parts of the code. Can someone help explain what is going on and how I can fix it? Thanks!

The error is:

[Error] [carb.gym.plugin] cudaExternamMemoryGetMappedBuffer failed on rgbImage buffer with error 101
[Error] [carb.gym.plugin] cudaExternamMemoryGetMappedBuffer failed on depthImage buffer with error 101
[Error] [carb.gym.plugin] cudaExternamMemoryGetMappedBuffer failed on segmentationImage buffer with error 101
[Error] [carb.gym.plugin] cudaExternamMemoryGetMappedBuffer failed on optical flow buffer with error 101

and the code that produces it is:


from isaacgym import gymapi

class Config:
    def __init__(self):
        self.num_threads = 0
        self.physics_engine = gymapi.SimType.SIM_PHYSX
        self.pipeline = 'gpu'
        self.proj_name = 'g1_motion_flat_test'
        self.sim_device = 'cuda:0'
        self.sim_device_type = 'cuda'
        self.subscenes = 0
        self.task = 'g1motion'
        self.use_gpu = True

class GymViewer:
    def __init__(self):
        args = Config()
        
        sim_params = gymapi.SimParams()

        sim_params.use_gpu_pipeline = False
        
        # Initialize gym
        camprops = gymapi.CameraProperties()
        camprops.enable_tensors = True
        self.gym = gymapi.acquire_gym()
        self.sim = self.gym.create_sim(0, 0, gymapi.SIM_PHYSX, sim_params)
        # Create a viewer        
        plane_params = gymapi.PlaneParams()
        self.gym.add_ground(self.sim, plane_params)
        
        ## camera
        env_lower = gymapi.Vec3(0., 0., 0.)
        env_upper = gymapi.Vec3(0., 0., 0.)
        env_handle = self.gym.create_env(self.sim, env_lower, env_upper, 1)
        camera_handle = self.gym.create_camera_sensor(env_handle, camprops)

if __name__ == "__main__":
    viewer = GymViewer()

When I try to add the lines:

os.environ['MESA_VK_DEVICE_SELECT'] = '10de:2204'
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

I get the error

Traceback (most recent call last):
  File "train.py", line 120, in <module>
    train(args)
  File "train.py", line 59, in train
    env, env_cfg = task_registry.make_env(name=args.task, args=args)
  File "/home/kmcclenn/g1-parkour/g1-parkour/extreme-parkour/legged_gym/legged_gym/utils/task_registry.py", line 105, in make_env
    env = task_class(
  File "/home/kmcclenn/g1-parkour/g1-parkour/extreme-parkour/legged_gym/legged_gym/envs/g1/g1_motion_env.py", line 40, in __init__
    self.init_motions(cfg)
  File "/home/kmcclenn/g1-parkour/g1-parkour/extreme-parkour/legged_gym/legged_gym/envs/g1/g1_motion_env.py", line 104, in init_motions
    self._key_body_ids = torch.tensor([3, 6, 9, 12], device=self.device)  # 4 left and right angle link, left and right elbow link
RuntimeError: CUDA error: invalid device ordinal
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

And just adding the line os.environ['MESA_VK_DEVICE_SELECT'] = '10de:2204' doesn’t help.