Skip to content

Commit

Permalink
Don't set CUDA_HOME when not compiled with CUDA support (pytorch#106310)
Browse files Browse the repository at this point in the history
It doesn't make sense to set this (on import!) as CUDA cannot be used with PyTorch in this case but leads to messages like
> No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
when CUDA happens to be installed which is at least confusing.

Pull Request resolved: pytorch#106310
Approved by: https://github.com/ezyang
  • Loading branch information
Flamefire authored and xuhancn committed Nov 8, 2023
1 parent b7116c1 commit d9dcb46
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torch/utils/cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _join_rocm_home(*paths) -> str:
if torch.version.hip is not None:
ROCM_VERSION = tuple(int(v) for v in torch.version.hip.split('.')[:2])

CUDA_HOME = _find_cuda_home()
CUDA_HOME = _find_cuda_home() if torch.cuda._is_compiled() else None
CUDNN_HOME = os.environ.get('CUDNN_HOME') or os.environ.get('CUDNN_PATH')
# PyTorch releases have the version pattern major.minor.patch, whereas when
# PyTorch is built from source, we append the git commit hash, which gives
Expand Down

0 comments on commit d9dcb46

Please sign in to comment.