SuLvXiangXin / zipnerf-pytorch

Unofficial implementation of ZipNeRF
Apache License 2.0
783 stars 85 forks source link

No module named '_cuda_backend' #101

Closed YuiNsky closed 4 months ago

YuiNsky commented 4 months ago

Hello, i try to use NerfStudio as you mentioned, but rise the error like:

│ /workspace/nerf-studio-local/zipnerf-pytorch/extensions/backend.py:93 in _get_backend_name       │
│                                                                                                  │
│    90 │   │   │   backend_name = __import__('_cuda_backend')                                     │
│    91 │   │   except ImportError:                                                                │
│    92 │   │   │   # TODO:self.compile()                                                          │
│ ❱  93 │   │   │   backend_name = __import__('_cuda_backend')                                     │
│    94 │   │                                                                                      │
│    95 │   │   return backend_name                                                                │

ModuleNotFoundError: No module named '_cuda_backend'
  In call to configurable 'Model' (<class 'internal.models.Model'>)

Then i try to pip install ./extensions/cuda, rise the error:

Processing ./extensions/cuda
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: cuda_backend
  Building wheel for cuda_backend (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running bdist_wheel
      running build
      running build_ext
      /home/user/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py:424: UserWarning: There are no x86_64-linux-gnu-g++ version bounds defined for CUDA version 11.8
        warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}')
      building '_cuda_backend' extension
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda
      creating /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src
      Emitting ninja build file /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/build.ninja...
      Compiling objects...
      Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
      1.10.1
      creating build/lib.linux-x86_64-cpython-310
      x86_64-linux-gnu-g++ -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/bindings.o /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/gridencoder.o /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/pdf.o -L/home/user/.local/lib/python3.10/site-packages/torch/lib -L/usr/local/cuda/lib64 -L/usr/lib/x86_64-linux-gnu -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-cpython-310/_cuda_backend.cpython-310-x86_64-linux-gnu.so
      /usr/bin/ld: cannot find /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/bindings.o: No such file or directory
      /usr/bin/ld: cannot find /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/gridencoder.o: No such file or directory
      /usr/bin/ld: cannot find /workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/build/temp.linux-x86_64-cpython-310/workspace/nerf-studio-local/zipnerf-pytorch/extensions/cuda/src/pdf.o: No such file or directory
      collect2: error: ld returned 1 exit status
      error: command '/usr/bin/x86_64-linux-gnu-g++' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cuda_backend
  Running setup.py clean for cuda_backend
Failed to build cuda_backend
ERROR: Could not build wheels for cuda_backend, which is required to install pyproject.toml-based projects

My nerfstudio version is docker image1.0.2

YuiNsky commented 4 months ago

I solved this by uninstall ninja.

rohit7044 commented 2 months ago

Was stuck on this for a while. Thanks

danielmao2019 commented 1 month ago

I am still getting the following error after pip uninstall ninja:

        895 |     attn_output_weights = AT_DISPATCH_FLOATING_TYPES(
            |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cuda_backend
  Running setup.py clean for cuda_backend
Failed to build cuda_backend
ERROR: Could not build wheels for cuda_backend, which is required to install pyproject.toml-based projects

any idea? Thanks!

rohit7044 commented 1 month ago

Since I was using Windows, I solved this problem by basically checking if visual studio is properly installed with latest version and made sure that the MSVC path is set in environment variables. Also check your gcc version and install new versions if it helps.

danielmao2019 commented 1 month ago

Can I know what CUDA version and gcc version I should use? Btw I'm on unbuntu. Thanks!

rohit7044 commented 1 month ago

CUDA 11.8 gcc 11.4

danielmao2019 commented 1 month ago

Thanks!

sumanttyagi commented 2 weeks ago

I solved this by uninstall ninja.

why should we uninstall ninja ? it might break other models ?