I’m getting the following errors with my code. It is an adapted version of the PyTorch DQN example.
/pytorch/aten/src/THC/THCTensorScatterGather.cu:97: void THCudaTensor_gatherKernel(TensorInfo<Real, IndexType>, TensorInfo<Real, IndexType>, TensorInfo<long, IndexType>, int, IndexType) [with IndexType = unsigned int, Real = float, Dims = 2]: block: [0,0,0], thread: [62,0,0] Assertion `indexValue >= 0 && indexValue < src.sizes[dim]` failed.
Traceback (most recent call last):
  File "/project/ros-kinetic-alphapilot/catkin_ws/src/alphapilot_openai_ros/ardrone_race_track/src/ardrone_v1_ddqn.py", line 548, in <module>
    optimize_model()
  File "/project/ros-kinetic-alphapilot/catkin_ws/src/alphapilot_openai_ros/ardrone_race_track/src/ardrone_v1_ddqn.py", line 451, in optimize_model
    next_state_values[non_final_mask] = target_net(non_final_next_states).max(1)[0].detach()
RuntimeError: copy_if failed to synchronize: device-side assert triggered


  
      github.com
  
  
    edowson/alphapilot_openai_ros/blob/master/ardrone_race_track/src/ardrone_v1_ddqn.py#L451 1

# columns of actions taken. These are the actions which would've been taken
# for each batch state according to policy_net
state_action_values = policy_net(state_batch).gather(1, action_batch)


# Compute V(s_{t+1}) for all next states.
# Expected values of actions for non_final_next_states are computed based
# on the "older" target_net; selecting their best reward with max(1)[0].
# This is merged based on the mask, such that we'll have either the expected
# state value or 0 in case the state was final.
next_state_values = torch.zeros(BATCH_SIZE, device=device)
next_state_values[non_final_mask] = target_net(non_final_next_states).max(1)[0].detach()
# Compute the expected Q values
expected_state_action_values = (next_state_values * GAMMA) + reward_batch.float()


# Compute Huber loss
loss = F.smooth_l1_loss(state_action_values, expected_state_action_values.unsqueeze(1))


# Optimize the model
optimizer.zero_grad()
loss.backward()
for param in policy_net.parameters():



  
  
    
    
  
  


The hyperparameters are as follows:

  
      github.com
  
  
    edowson/alphapilot_openai_ros/blob/master/ardrone_race_track/config/ardrone_v1_race_track_ddqn_params.yaml#L14-L29

# screen parameters
screen_height: 180
screen_width: 320


show_image: False


# ddqn parameters
gamma: 0.999


epsilon_start: 0.9
epsilon_end: 0.01
epsilon_decay: 500


batch_size: 128
replay_memory_size: 1024
target_network_update_interval: 10