Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get CUDA_HOME environment path PYTORCH

I have cuda installed via anaconda on my system which has 2 GPUs which is getting recognized by my python.

import torch
torch.cuda.is_available()
true

However when I try to run a model via its C API, I m getting following error:

~/anaconda3/lib/python3.6/site-packages/torch/utils/cpp_extension.py in _join_cuda_home(*paths)
722     '''
723     if CUDA_HOME is None:
--> 724         raise EnvironmentError('CUDA_HOME environment variable is not set. '
725                                'Please set it to your CUDA install root.')
726     return os.path.join(CUDA_HOME, *paths)

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

https://lfd.readthedocs.io/en/latest/install_gpu.html page gives instruction to set up CUDA_HOME path if cuda is installed via their method. Since I have installed cuda via anaconda I don't know which path to set.

I tried find method but it is returning me too many paths for cuda. Can somebody help me with the path for CUDA. Thanks in advance.

like image 778
bambi Avatar asked Oct 10 '18 02:10

bambi


1 Answers

Solution to above issue!

As cuda installed through anaconda is not the entire package. Please install cuda drivers manually from Nvidia Website[ https://developer.nvidia.com/cuda-downloads ]

After installation of drivers, pytorch would be able to access the cuda path. You can test the cuda path using below sample code. Problem resolved!!!

CHECK INSTALLATION:

import os
print(os.environ.get('CUDA_PATH'))

OUTPUT:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
like image 179
anil kumar Avatar answered Oct 04 '22 20:10

anil kumar