I keep getting an srun error when trying to access a GPU

I am using the recommended srun command to access GPU node. However, I keep getting the error “srun: error: Unable to create step for job 12702868: Invalid generic resource (gres) specification”. Do you know how I can avoid this error?

This might due to requesting srun job from within a compute node. Please make sure you are running your srun command from a login node.