pytorch / extension-cpp

C++ extensions in PyTorch
1.02k stars 214 forks source link

CUDA_HOME environment variable is not set #26

Closed zzd1992 closed 4 years ago

zzd1992 commented 5 years ago

I work on ubuntu16.04, cuda9.0 and Pytorch1.0. When I run your example code cuda/setup.py:

Traceback (most recent call last):
  File "setup.py", line 9, in <module>
    'lltm_cuda_kernel.cu',
  File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 476, in CUDAExtension
    library_dirs += library_paths(cuda=True)
  File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 549, in library_paths
    paths.append(_join_cuda_home(lib_dir))
  File "/usr/local/lib/python2.7/dist-packages/torch/utils/cpp_extension.py", line 1121, in _join_cuda_home
    raise EnvironmentError('CUDA_HOME environment variable is not set. '
EnvironmentError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

However, I am sure cuda9.0 in my computer is installed correctly. How to fix this problem?

goldsborough commented 5 years ago

That's odd. Maybe you have an unusual install location for CUDA. Either way, just setting CUDA_HOME to your cuda install path before running python setup.py should work: CUDA_HOME=/path/to/your/cuda/home python setup.py install

zzd1992 commented 5 years ago

Thanks. My problem is solved.

DaLei001 commented 5 years ago

@zzd1992 Could you tell how to solve the problem about "the CUDA_HOME environment variable is not set"?

zzd1992 commented 5 years ago

@DaLei001

CUDA_HOME=/path/to/your/cuda/home python setup.py install

This is worked in my situation.

mmahdavian commented 4 years ago

I am getting this error in a conda env on a server and I have cudatoolkit installed on the conda env. What should the CUDA_HOME be in my case.

parasdegregore commented 4 years ago

@mmahdavian cudatoolkit probably won't work for you, it doesn't provide access to low level c++ apis. You'd need to install CUDA using the official method.

ShoufaChen commented 3 years ago

I got a similar error when using pycharm, with unusual cuda install location.

I just add the CUDA_HOME env and solve this problem.

fengyuan1993012 commented 2 years ago

The problem could be solved by installing the whole cuda through the nvida website. and when installing it, you may come across some problem. then https://askubuntu.com/questions/1280205/problem-while-installing-cuda-toolkit-in-ubuntu-18-04/1315116#1315116?newreg=ec85792ef03b446297a665e21fff5735 the answer may be to help you. GOOD LUCK