본문 바로가기
TIL

CUDA_HOME environment variable is not set. Please set it to your CUDA install root for pytorch cpp extensions

by cocacola0 2022. 4. 24.

1. Probelm Description

- Mostly, this error comes from not setting path for nvcc  
- so first check the nvcc using `nvcc --version` 
- nvidia-smi is not related 
# nvidia-smi command works fine
$ nvidia-smi

# nvcc command not found 
$ nvcc --version 

2. Solution

- setting correct path in ~/.bashrc or ~/.zshrc depending on shell you are using 
$ vi ~/.zshrc

# adding below at the end of script 
# export PATH="/usr/local/{installed cuda-version}/bin:$PATH"
# export LD_LIBRARY_PATH="/usr/local/{installed cuda-version}/lib64:$LD_LIBRARY_PATH"
export PATH="/usr/local/cuda-11.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH"

$ source ~/.zshrc

1. 문제 상황

- nvcc 경로를 설정하지 않으면 발생 
- `nvcc --version` 를 사용해서 설정 check (설정이 안되어 있으면 command를 못찾음) 
- nvidia-smi 같은 경우 작동함 
# nvidia-smi command works fine
$ nvidia-smi

# nvcc command not found 
$ nvcc --version 

2. Solution

- 사용하는 shell 에 따라 ~./bashrc 또는 ~./zshrc 에서 경로 지정 
$ vi ~/.zshrc

# adding below at the end of script 
# export PATH="/usr/local/{installed cuda-version}/bin:$PATH"
# export LD_LIBRARY_PATH="/usr/local/{installed cuda-version}/lib64:$LD_LIBRARY_PATH"
export PATH="/usr/local/cuda-11.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH"

$ source ~/.zshrc

ref

'TIL' 카테고리의 다른 글

Google Colab Setting - conda & terminal  (0) 2022.04.26
Git multiple accounts / 깃 다중 계정  (0) 2022.04.13

댓글