'pytools.prefork.ExecError: error invoking 'nvcc --version': [Errno 2] No such file or directory
I have install pycuda
and I am trying to test it with code below.
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
import numpy
a = numpy.random.randn(4,4)
a = a.astype(numpy.float32)
a_gpu = cuda.mem_alloc(a.nbytes)
cuda.memcpy_htod(a_gpu, a)
mod = SourceModule("""
__global__ void doublify(float *a)
{
int idx = threadIdx.x + threadIdx.y*4;
a[idx] *= 2;
}
""")
func = mod.get_function("doublify")
func(a_gpu, block=(4,4,1))
a_doubled = numpy.empty_like(a)
cuda.memcpy_dtoh(a_doubled, a_gpu)
print a_doubled
print a
I'm getting the following error:
pytools.prefork.ExecError: error invoking 'nvcc --version': [Errno 2] No such file or directory
Solution 1:[1]
It's working after adding the below lines in the .bashrc file
export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}$
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Steps
- find .bashrc file.
- Add above lines to it.
- source .bashrc
- To Test run command "nvcc --version"
link: https://askubuntu.com/questions/885610/nvcc-version-command-says-nvcc-is-not-installed helped
Solution 2:[2]
In case this error reported, open the compiler.py file and in the compile_plain()
function add the following line:
nvcc = '/usr/local/cuda/bin/' + nvcc
the compiler.py file is located in:
"/anaconda3/lib/python3.7/site-packages/pycuda-2020.1-py3.7-linux-x86_64.egg/pycuda/compiler.py"
So the final code will be something like this:
def compile_plain(source, options, keep, nvcc, cache_dir, target="cubin"):
from os.path import join
assert target in ["cubin", "ptx", "fatbin"]
nvcc = '/usr/local/cuda/bin/' + nvcc # --> here is the new line
if cache_dir:
checksum = _new_md5()
...
Save it and that's all
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mukul |
Solution 2 | greybeard |