Lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1666, in _run_ninja_build

jS5t3r: <p>Can someone tell me, what to do to fix this?</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1666, in _run_ninja_build
    subprocess.run(
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "eval_sde_adv.py", line 29, in &lt;module&gt;
    from runners.diffpure_sde import RevGuidedDiffusion
  File "/home/user/DiffusionPurification/DiffPure/runners/diffpure_sde.py", line 17, in &lt;module&gt;
    from score_sde.losses import get_optimizer
  File "/home/user/DiffusionPurification/DiffPure/score_sde/losses.py", line 22, in &lt;module&gt;
    from .models import utils as mutils
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/__init__.py", line 15, in &lt;module&gt;
    from . import  ncsnpp
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/ncsnpp.py", line 18, in &lt;module&gt;
    from . import utils, layers, layerspp, normalization
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/layerspp.py", line 20, in &lt;module&gt;
    from . import up_or_down_sampling
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/up_or_down_sampling.py", line 18, in &lt;module&gt;
    from ..op import upfirdn2d
  File "/home/user/DiffusionPurification/DiffPure/score_sde/op/__init__.py", line 9, in &lt;module&gt;
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_act.py", line 19, in &lt;module&gt;
    fused = load(
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1080, in load
    return _jit_compile(
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1293, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1405, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1682, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'fused': [1/3] /home/user/.conda/envs/py3.8_env/bin/nvcc  -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/TH -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/THC -isystem /home/user/.conda/envs/py3.8_env/include -isystem /home/user/.conda/envs/py3.8_env/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -std=c++14 -c /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o 
FAILED: fused_bias_act_kernel.cuda.o 
/home/user/.conda/envs/py3.8_env/bin/nvcc  -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/TH -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/THC -isystem /home/user/.conda/envs/py3.8_env/include -isystem /home/user/.conda/envs/py3.8_env/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -std=c++14 -c /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o 
cc1plus: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.
[2/3] c++ -MMD -MF fused_bias_act.o.d -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/TH -isystem /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/THC -isystem /home/user/.conda/envs/py3.8_env/include -isystem /home/user/.conda/envs/py3.8_env/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp -o fused_bias_act.o 
In file included from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/DeviceType.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/Device.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/Allocator.h:6,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/ATen.h:7,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                 from /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:9:
/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp: In function ‘at::Tensor fused_bias_act(const at::Tensor&amp;, const at::Tensor&amp;, const at::Tensor&amp;, int, int, float, float)’:
/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:15:42: warning: ‘at::DeprecatedTypeProperties&amp; at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tensor.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
   15 | #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor")
      |                                          ^
/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:21:5: note: in expansion of macro ‘CHECK_CUDA’
   21 |     CHECK_CUDA(input);
      |     ^~~~~~~~~~
In file included from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/Context.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                 from /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:9:
/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:338:30: note: declared here
  338 |   DeprecatedTypeProperties &amp; type() const {
      |                              ^~~~
In file included from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/DeviceType.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/Device.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/c10/core/Allocator.h:6,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/ATen.h:7,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                 from /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:9:
/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:15:42: warning: ‘at::DeprecatedTypeProperties&amp; at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tensor.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
   15 | #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor")
      |                                          ^
/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:22:5: note: in expansion of macro ‘CHECK_CUDA’
   22 |     CHECK_CUDA(bias);
      |     ^~~~~~~~~~
In file included from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/Context.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/ATen.h:9,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:8,
                 from /home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                 from /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act.cpp:9:
/home/user/.conda/envs/py3.8_env/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:338:30: note: declared here
  338 |   DeprecatedTypeProperties &amp; type() const {
      |                              ^~~~
ninja: build stopped: subcommand failed.
</code></pre>

ptrblck: <p>It seems you are trying to compile CUDA code with a compiler from <code>conda</code> which fails as files are missing:</p>
<pre><code class="lang-auto">cc1plus: fatal error: cuda_runtime.h: No such file or directory
</code></pre>
<p>Install a full CUDA toolkit locally and it should work.</p>

jS5t3r: <p>I cannot solve this installing cudatoolkit via anaconda, right?</p>
<p>This is the docker image: <a href="https://github.com/NVlabs/DiffPure/blob/master/diffpure.Dockerfile" rel="noopener nofollow ugc">https://github.com/NVlabs/DiffPure/blob/master/diffpure.Dockerfile</a></p>
<p>I am not able to use the docker image neither.</p>
<p>After installing cudatoolkit via conda:</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1533, in _run_ninja_build
    subprocess.run(
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "eval_sde_adv.py", line 29, in &lt;module&gt;
    from runners.diffpure_sde import RevGuidedDiffusion
  File "/home/user/DiffusionPurification/DiffPure/runners/diffpure_sde.py", line 17, in &lt;module&gt;
    from score_sde.losses import get_optimizer
  File "/home/user/DiffusionPurification/DiffPure/score_sde/losses.py", line 22, in &lt;module&gt;
    from .models import utils as mutils
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/__init__.py", line 15, in &lt;module&gt;
    from . import  ncsnpp
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/ncsnpp.py", line 18, in &lt;module&gt;
    from . import utils, layers, layerspp, normalization
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/layerspp.py", line 20, in &lt;module&gt;
    from . import up_or_down_sampling
  File "/home/user/DiffusionPurification/DiffPure/score_sde/models/up_or_down_sampling.py", line 18, in &lt;module&gt;
    from ..op import upfirdn2d
  File "/home/user/DiffusionPurification/DiffPure/score_sde/op/__init__.py", line 9, in &lt;module&gt;
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/user/DiffusionPurification/DiffPure/score_sde/op/fused_act.py", line 19, in &lt;module&gt;
    fused = load(
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 986, in load
    return _jit_compile(
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1193, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1297, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "/home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1555, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'fused': [1/2] /home/user/.conda/envs/py3.8_cuda11.3/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/TH -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/THC -isystem /home/user/.conda/envs/py3.8_cuda11.3/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -std=c++14 -c /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o 
FAILED: fused_bias_act_kernel.cuda.o 
/home/user/.conda/envs/py3.8_cuda11.3/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/TH -isystem /home/user/.conda/envs/py3.8_cuda11.3/lib/python3.8/site-packages/torch/include/THC -isystem /home/user/.conda/envs/py3.8_cuda11.3/include -isystem /home/user/.conda/envs/py3.8_cuda11.3/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -std=c++14 -c /home/user/DiffusionPurification/DiffPure/score_sde/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o 
ptxas /tmp/tmpxft_00014cdd_00000000-6_fused_bias_act_kernel.ptx, line 9; fatal   : Unsupported .version 8.2; current version is '7.7'
ptxas fatal   : Ptx assembly aborted due to errors
ninja: build stopped: subcommand failed.
</code></pre>

ptrblck: <p>I have never used the <code>conda</code> <code>cudatoolkit</code> to compile code only to run it, so would still recommend installing a full local CUDA toolkit from instead of <code>conda</code> packages.</p>