FileNotFoundError: [Errno 2] No such file or directory: 'nvcc': 'nvcc

Traceback (most recent call last):
File “/media/cyoung/000E88CC0009670E/projectCV/implement_tvm/tvm_handson/compiling_model/main.py”, line 24, in
net, target, shape={“data”: data_shape}, params=params)
File “/home/cyoung/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/build_module.py”, line 304, in build
graph = graph.apply(“GraphCompile”)
File “/home/cyoung/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/graph.py”, line 234, in apply
check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
File “/home/cyoung/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/_base.py”, line 75, in check_call
raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: TVMCall CFunc Error:
Traceback (most recent call last):
File “tvm/_ffi/_cython/./function.pxi”, line 38, in tvm._ffi._cy3.core.tvm_callback
File “/home/cyoung/.local/lib/python3.6/site-packages/nnvm-0.8.0-py3.6.egg/nnvm/compiler/build_module.py”, line 124, in _build
return tvm.build(funcs, target=target, target_host=target_host)
File “/home/cyoung/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/build_module.py”, line 504, in build
mdev = codegen.build_module(fdevice, str(target_device))
File “/home/cyoung/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/codegen.py”, line 20, in build_module
return _Build(lowered_func, target)
File “/home/cyoung/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/_ffi/function.py”, line 280, in my_api_func
return flocal(*args)
File “tvm/_ffi/_cython/./function.pxi”, line 267, in tvm._ffi._cy3.core.FunctionBase.call
File “tvm/_ffi/_cython/./function.pxi”, line 216, in tvm._ffi._cy3.core.FuncCall
File “tvm/_ffi/_cython/./function.pxi”, line 208, in tvm._ffi._cy3.core.FuncCall3
File “tvm/_ffi/_cython/./base.pxi”, line 143, in tvm._ffi._cy3.core.CALL
tvm._ffi.base.TVMError: TVMCall CFunc Error:
Traceback (most recent call last):
File “tvm/_ffi/_cython/./function.pxi”, line 38, in tvm._ffi._cy3.core.tvm_callback
File “/home/cyoung/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/autotvm/measure/measure_methods.py”, line 489, in tvm_callback_cuda_compile
ptx = nvcc.compile_cuda(code, target=“ptx”, arch=AutotvmGlobalScope.current.cuda_target_arch)
File “/home/cyoung/.local/lib/python3.6/site-packages/tvm-0.4.0-py3.6-linux-x86_64.egg/tvm/contrib/nvcc.py”, line 69, in compile_cuda
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File “/home/cyoung/miniconda3/lib/python3.6/subprocess.py”, line 709, in init
restore_signals, start_new_session)
File “/home/cyoung/miniconda3/lib/python3.6/subprocess.py”, line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘nvcc’: ‘nvcc’

cmd nvcc -V:
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2017 NVIDIA Corporation
Built on Mon_Jun_26_16:13:28_CDT_2017
Cuda compilation tools, release 9.0, V9.0.102

I already add CUDA bin PATH:
export PATH=$PATH:/usr/local/cuda/bin

still given this error!

I fixed this already.Once I made the requisite changes to /etc/environment to add for /usr/local/cuda/bin it was all good.

2 Likes

hello when i use pycharm, face this porblem also, can you discribe the details? thanks

1 Like

Hello, I met the same problem, have you salve it yet? wating for you anwser!

TL;DR

This problem is due to the incorrect PATH value.

Adding the following code at the beginning of your code:

import os # adding this line
os.environ["PATH"] = os.environ["PATH"]+":/usr/local/cuda/bin/" # adding this line

Tips: Please be sure that you can execute nvcc on your shell.

Problem

I am facing the same problem when I use PyCharm and executing the code remotely:

I followed the calling stack then found a code that showing this problem:

    # tvm/autotvm/measure/measure.py
    def measure_batch(measure_inputs):
        build_results = builder.build(measure_inputs)
        # watch `build_results` then you got 
        # MeasureResult(costs=(TVMError('Traceback ...
        # FileNotFoundError: [Errno 2] No such file or directory: 'nvcc'
        #
        # Process finished with exit code 1
        #
        results = runner.run(measure_inputs, build_results)
        return results

Seems like python cannot find nvcc in my system.

Then I execute nvcc --version directly in bash:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89

Why python cannot find nvcc?

Therefore I wrote a small script to test:

import subprocess

proc = subprocess.Popen("nvcc", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = proc.communicate()
print(out)

It says:

Traceback (most recent call last):
  File "/disk1/jyhou/autotvmtest/unitest.py", line 5, in <module>
    proc = subprocess.Popen("nvcc", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "/disk1/jyhou/anaconda3/envs/tvm-build/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/disk1/jyhou/anaconda3/envs/tvm-build/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'nvcc'

Solution

My solution is adding nvcc path to PATH env:

import subprocess
import os # adding this line
os.environ["PATH"] = os.environ["PATH"]+":/usr/local/cuda/bin/" # adding this line

proc = subprocess.Popen("nvcc", stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(out, _) = proc.communicate()
print(out)

The result becomes:

b'nvcc fatal   : No input files specified; use option --help for more information\n'

Process finished with exit code 0

Here the problem solved!

1 Like

or try this, if someone do not have root permissions to edit etc/environment:

1 Like

could you describe more details? I meet this problem too. thanks.

it`s work! Sooooooo good!