question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

See original GitHub issue
$ pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html
pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Collecting torch==1.12.1+cu113
  Using cached https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp38-cp38-linux_x86_64.whl (1837.7 MB)
Collecting torchvision==0.13.1+cu113
  Using cached https://download.pytorch.org/whl/cu113/torchvision-0.13.1%2Bcu113-cp38-cp38-linux_x86_64.whl (23.4 MB)
Collecting typing-extensions
  Using cached typing_extensions-4.4.0-py3-none-any.whl (26 kB)
Collecting requests
  Using cached requests-2.28.1-py3-none-any.whl (62 kB)
Collecting pillow!=8.3.*,>=5.3.0
  Using cached Pillow-9.2.0-cp38-cp38-manylinux_2_28_x86_64.whl (3.2 MB)
Collecting numpy
  Using cached numpy-1.23.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting charset-normalizer<3,>=2
  Using cached charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/envs/nerfstudio/lib/python3.8/site-packages (from requests->torchvision==0.13.1+cu113) (2022.9.24)
Installing collected packages: urllib3, typing-extensions, pillow, numpy, idna, charset-normalizer, torch, requests, torchvision
Successfully installed charset-normalizer-2.1.1 idna-3.4 numpy-1.23.3 pillow-9.2.0 requests-2.28.1 torch-1.12.1+cu113 torchvision-0.13.1+cu113 typing-extensions-4.4.0 urllib3-1.26.12
Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
  Cloning https://github.com/NVlabs/tiny-cuda-nn/ to /tmp/pip-req-build-p95k6ytq
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ /tmp/pip-req-build-p95k6ytq
  Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit 563b626c298a88b5a0c6fb47944c693e9fbd8507
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-req-build-p95k6ytq/bindings/torch/setup.py", line 111, in <module>
          ext = CUDAExtension(
        File "/home/kosuke/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 983, in CUDAExtension
          library_dirs += library_paths(cuda=True)
        File "/home/kosuke/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1098, in library_paths
          if (not os.path.exists(_join_cuda_home(lib_dir)) and
        File "/home/kosuke/anaconda3/envs/nerfstudio/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 2125, in _join_cuda_home
          raise EnvironmentError('CUDA_HOME environment variable is not set. '
      OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
      Building PyTorch extension for tiny-cuda-nn version 1.6
      Obtained compute capability 80 from PyTorch
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
stevekmcommented, Oct 18, 2022

I think it would be a good idea to at least note in the README that CUDA needs to be installed, and possibly provide some links or docs on various ways to install it. As it stands currently, I was under the impression that the README install guide included everything necessary to run nerfstudio out of the box, including CUDA installation, especially because (confusingly) some of the Python libraries included in the installation have “cuda” in the name.

1reaction
stevekmcommented, Oct 18, 2022

Ok, it seems that I was able resolve it with this; https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#conda-installation

$ conda install -c nvidia cuda

which installed CUDA version 11.8.0 into my conda env, and let me install this sucessfully;

$ pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

which let me run

$ ns-train nerfacto

Maybe we can get cuda put in the conda env installation instructions for nerfstudio?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CUDA_HOME environment variable is not set. Please set it to ...
The downside is you'll need to set CUDA_HOME every time. The error in this issue is from torch. So you can do: conda...
Read more >
python - Get CUDA_HOME environment path PYTORCH
726 return os.path.join(CUDA_HOME, *paths) OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
Read more >
cuda_home environment variable is not set ... - Code Grepper
Solution to above issue! As cuda installed through anaconda is not the entire package. Please install cuda drivers manually from Nvidia Website[ ...
Read more >
CUDA_HOME environment variable is not set. Please set it to ...
Please set it to your CUDA install root. OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root....
Read more >
Loading styleGAN2 for inference without GPU - PyTorch Forums
' OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root. ptrblck ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found