I am just confused why that line appears and whether it might indicate a problem.
Here is what I get for your specific example
>>> import torch, os
>>> os.environ['CXX'] = 'g++' # my default is c++, which fails
>>> from torch.utils.cpp_extension import load_inline
which: no nvcc in (/home/...:... i.e. my $PATH)
>>> cpp_source = '''
... torch::Tensor my_fun(torch::Tensor z) {
... auto s = torch::relu(z);
... return s;
... }
... '''
>>> module = load_inline(name='inline_extension', cpp_sources=[cpp_source], functions=['my_fun'])
>>> module.my_fun(torch.randn(10)) # everything fine.
Pytorch is only installed in the virtual environment, using pip. Do you not get the “no nvcc” line? For reference, here is exactly how I installed pytorch from scratch:
No, I don’t get the message regarding the missing nvcc when I execute the code.
Is this just a warning and your module still works or does it raise an error?
It seems to be just a warning, since the module works. However, the message doesn’t look intentional which is why I to asked if something might be wrong.
I’m not sure, why this warning is thrown and it seems PyTorch thinks you are trying to load a CUDA extension.
Do you have any paths or arguments in your environment, which could point to a (non-existing) nvcc or some CUDA folders?
that’s executed unconditionally when building extensions.
If it’s not causing an actual failure and is just alarming, you might be able to shut it up by setting CUDA_HOME or CUDA_PATH in the env even without CUDA installed.