How does PyTorch detect the CUDA installation?

Hi, a question mainly out of curiosity: how does PyTorch detect the CUDA installation on the pc?
For instance, on my pc I have CUDA-10.1 installed in /usr/local/cuda-10.1 but I have not added it neither to PATH or to LD_LIBRARY_PATH. Nevertheless, PyTorch detects its seamlessly and everything works out fine. How is this done?

Thanks in advance for any hint!

The conda binaries and pip wheels ship with their own CUDA runtime and your local CUDA toolkit will not be used.
You would only need to provide a sufficiently new NVIDIA driver and it should work.
Your local CUDA toolkit would be used, if you are building PyTorch from source or are building custom CUDA extensions.

Thank you very much @ptrblck, that makes a lot of sense!
And also, it’s a great deploy strategy, a big thumbs up for PyTorch once again!