fix: replace tensor.is_cuda with a cuda-build guard in the cache update
The torchcuda hook flags .is_cuda; on_accelerator() has different
semantics on the CPU accelerator (CPU tensors are 'on accelerator'),
which un-guarded the capture check on CPU-only builds. Gate on
torch.version.cuda instead.
Signed-off-by: Guokai Ma <guokai.ma@intel.com>