Latest cuda toolkit release 11.7. is it compatible with pytorch?

I assume you are trying to build PyTorch from source using CUDA 11.7 as the binaries are not released yet. If so, use the supported pip wheels or conda binaries with CUDA 11.3 or 11.6.