Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colab error: ModuleNotFoundError: No module named '_gridencoder' #349

Open
erikestany opened this issue Dec 15, 2023 · 4 comments
Open

Colab error: ModuleNotFoundError: No module named '_gridencoder' #349

erikestany opened this issue Dec 15, 2023 · 4 comments

Comments

@erikestany
Copy link

Hello. I have this error with colab:

ModuleNotFoundError: No module named '_gridencoder'
During handling of the above exception, another exception occurred:

CalledProcessError Traceback (most recent call last)

11 frames

CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py in _run_ninja_build(build_directory, verbose, error_prefix)
2114 if hasattr(error, 'output') and error.output: # type: ignore[union-attr]
2115 message += f": {error.output.decode(*SUBPROCESS_DECODE_ARGS)}" # type: ignore[union-attr]
-> 2116 raise RuntimeError(message) from e
2117
2118

RuntimeError: Error building extension 'grid_encoder': [1/3] /usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=grid_encoder -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /usr/local/lib/python3.10/dist-packages/torch/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.10/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.10 -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_75,code=compute_75 -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -c /content/stable-dreamfusion/gridencoder/src/gridencoder.cu -o gridencoder.cuda.o
FAILED: gridencoder.cuda.o
/usr/local/cuda/bin/nvcc -DTORCH_EXTENSION_NAME=grid_encoder -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /usr/local/lib/python3.10/dist-packages/torch/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.10/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.10 -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_75,code=compute_75 -gencode=arch=compute_75,code=sm_75 --compiler-options '-fPIC' -O3 -std=c++14 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_HALF2_OPERATORS__ -c /content/stable-dreamfusion/gridencoder/src/gridencoder.cu -o gridencoder.cuda.o
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/string_view.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/StringUtil.h:6,
from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/Exception.h:5,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/Generator.h:11,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/CPUGeneratorImpl.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/Context.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/cuda/CUDAContext.h:18,
from /content/stable-dreamfusion/gridencoder/src/gridencoder.cu:5:
/usr/local/lib/python3.10/dist-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
27 | #error You need C++17 to compile PyTorch
| ^~~~~
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,
from /content/stable-dreamfusion/gridencoder/src/gridencoder.cu:6:
/usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:4:2: error: #error C++17 or later compatible compiler is required to use PyTorch.
4 | #error C++17 or later compatible compiler is required to use PyTorch.
| ^~~~~
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:9,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/torch.h:3,
from /content/stable-dreamfusion/gridencoder/src/gridencoder.cu:6:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
4 | #error C++17 or later compatible compiler is required to use ATen.
| ^~~~~
[2/3] c++ -MMD -MF bindings.o.d -DTORCH_EXTENSION_NAME=_grid_encoder -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -isystem /usr/local/lib/python3.10/dist-packages/torch/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.10/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++17 -O3 -std=c++14 -c /content/stable-dreamfusion/gridencoder/src/bindings.cpp -o bindings.o
FAILED: bindings.o
c++ -MMD -MF bindings.o.d -DTORCH_EXTENSION_NAME=_grid_encoder -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -isystem /usr/local/lib/python3.10/dist-packages/torch/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.10/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.10/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++17 -O3 -std=c++14 -c /content/stable-dreamfusion/gridencoder/src/bindings.cpp -o bindings.o
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/torch/extension.h:5,
from /content/stable-dreamfusion/gridencoder/src/bindings.cpp:1:
/usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:4:2: error: #error C++17 or later compatible compiler is required to use PyTorch.
4 | #error C++17 or later compatible compiler is required to use PyTorch.
| ^~~~~
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/string_view.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/StringUtil.h:6,
from /usr/local/lib/python3.10/dist-packages/torch/include/c10/util/Exception.h:5,
from /usr/local/lib/python3.10/dist-packages/torch/include/c10/core/Device.h:5,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/TensorBody.h:11,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/Tensor.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/Tensor.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/function_hook.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/variable.h:6,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/autograd.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/extension.h:5,
from /content/stable-dreamfusion/gridencoder/src/bindings.cpp:1:
/usr/local/lib/python3.10/dist-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
27 | #error You need C++17 to compile PyTorch
| ^~~~~
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader_options.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/base.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader/stateful.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data/dataloader.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/data.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:9,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/extension.h:5,
from /content/stable-dreamfusion/gridencoder/src/bindings.cpp:1:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
4 | #error C++17 or later compatible compiler is required to use ATen.
| ^~~~~
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue.h:1499,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/List_inl.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/List.h:490,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/IListRef_inl.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/IListRef.h:632,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/WrapDimUtils.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/TensorNames.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/NamedTensorUtils.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/variable.h:11,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/autograd.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/extension.h:5,
from /content/stable-dreamfusion/gridencoder/src/bindings.cpp:1:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue_inl.h: In lambda function:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue_inl.h:1061:30: error: ‘is_convertible_v’ is not a member of ‘std’; did you mean ‘is_convertible’?
1061 | if constexpr (::std::is_convertible_v<typename c10::invoke_result_t<T &&, Future&>, IValueWithStorages>) {
| ^~~~~~~~~~~~~~~~
| is_convertible
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue_inl.h:1061:91: error: expected ‘(’ before ‘,’ token
1061 | if constexpr (::std::is_convertible_v<typename c10::invoke_result_t<T &&, Future&>, IValueWithStorages>) {
| ^
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue_inl.h:1061:111: error: expected primary-expression before ‘>’ token
1061 | if constexpr (::std::is_convertible_v<typename c10::invoke_result_t<T &&, Future&>, IValueWithStorages>) {
| ^
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/ivalue_inl.h:1061:112: error: expected primary-expression before ‘)’ token
1061 | if constexpr (::std::is_convertible_v<typename c10::invoke_result_t<T &&, Future&>, IValueWithStorages>) {
| ^
In file included from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/KernelFunction_impl.h:1,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/KernelFunction.h:251,
from /usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/op_registration/op_registration.h:11,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/library.h:68,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/autograd/autograd_not_implemented_fallback.h:3,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/autograd.h:4,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/local/lib/python3.10/dist-packages/torch/include/torch/extension.h:5,
from /content/stable-dreamfusion/gridencoder/src/bindings.cpp:1:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/impl/boxing.h: In static member function ‘static Result c10::impl::BoxedKernelWrapper<Result(Args ...), typename std::enable_if<((c10::guts::conjunction<c10::guts::disjunction<std::is_constructible<c10::IValue, typename std::decay::type>, std::is_same<c10::TensorOptions, typename std::decay::type> >...>::value && c10::guts::conjunction<c10::guts::disjunction<c10::impl::has_ivalue_to<T, void>, std::is_same<void, ReturnType> >, c10::guts::negation<std::is_lvalue_reference<_Tp> > >::value) && (! c10::impl::is_tuple_of_mutable_tensor_refs::value)), void>::type>::call(const c10::BoxedKernel&, const c10::OperatorHandle&, c10::DispatchKeySet, Args ...)’:
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/impl/boxing.h:229:25: error: ‘is_same_v’ is not a member of ‘std’; did you mean ‘is_same’?
229 | if constexpr (!std::is_same_v<void, Result>) {
| ^~~~~~~~~
| is_same
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/impl/boxing.h:229:35: error: expected primary-expression before ‘void’
229 | if constexpr (!std::is_same_v<void, Result>) {
| ^~~~
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/impl/boxing.h:229:35: error: expected ‘)’ before ‘void’
/usr/local/lib/python3.10/dist-packages/torch/include/ATen/core/boxing/impl/boxing.h:229:18: note: to match this ‘(’
229 | if constexpr (!std::is_same_v<void, Result>) {
| ^
ninja: build stopped: subcommand failed.

@gravelargo
Copy link

I solved this by following the environment guide "Ubuntu 22 with torch 1.12 & CUDA 11.6 on a V100.":
pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu116

@DongChengdongHangZhou
Copy link

Yes, thank you, bro. Following your suggestion I have successfully resolved this problem.

@yangluo23
Copy link

I solved this by following the environment guide "Ubuntu 22 with torch 1.12 & CUDA 11.6 on a V100.": pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu116

I followed the same configuration,but didnt work yet

@erikestany
Copy link
Author

Hi. I was able to fix it, and it generates the videos, but when it has to generate the mesh, this error appears. Some idea? Thanks.

Namespace(text=None, negative='', O=True, O2=False, test=True, eval_interval=1, workspace='trial', guidance='stable-diffusion', seed=0, save_mesh=True, mcubes_resolution=256, decimate_target=100000.0, iters=10000, lr=0.001, warm_iters=500, min_lr=0.0001, ckpt='latest', cuda_ray=True, taichi_ray=False, max_steps=1024, num_steps=64, upsample_steps=32, update_extra_interval=16, max_ray_batch=4096, warmup_iters=2000, jitter_pose=False, uniform_sphere_rate=0.5, bg_radius=1.4, density_activation='softplus', density_thresh=0.1, blob_density=10, blob_radius=0.5, backbone='grid', optim='adan', sd_version='2.1', hf_key=None, fp16=True, vram_O=False, w=64, h=64, bound=1, dt_gamma=0, min_near=0.1, radius_range=[1.0, 1.5], fovy_range=[40, 70], dir_text=True, suppress_face=False, angle_overhead=30, angle_front=60, lambda_entropy=0.0001, lambda_opacity=0, lambda_orient=0.01, lambda_tv=0, gui=False, W=800, H=800, radius=3, fovy=60, light_theta=60, light_phi=0, max_spp=1)
NeRFNetwork(
  (encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 2048 per_level_scale=1.3819 params=(6119864, 2) gridtype=hash align_corners=False interpolation=smoothstep
  (sigma_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=32, out_features=32, bias=True)
      (1): Linear(in_features=32, out_features=4, bias=True)
    )
  )
  (encoder_bg): FreqEncoder: input_dim=3 degree=6 output_dim=39
  (bg_net): MLP(
    (net): ModuleList(
      (0): Linear(in_features=39, out_features=16, bias=True)
      (1): Linear(in_features=16, out_features=3, bias=True)
    )
  )
)
[INFO] Cmdline: main.py -O --test --workspace trial --save_mesh
[INFO] Trainer: df | 2024-06-04_19-00-10 | cuda | fp16 | trial
[INFO] #parameters: 12241607
[INFO] Loading latest checkpoint ...
[INFO] Latest checkpoint is trial/checkpoints/df_ep0005.pth
[INFO] loaded model.
[INFO] load at epoch 5, global step 500
[WARN] Failed to load optimizer.
[INFO] loaded scheduler.
[INFO] loaded scaler.
==> Start Test, save results to trial/results
100% 100/100 [00:47<00:00,  2.21it/s]
==> Finished Test.
100% 100/100 [01:01<00:00,  1.64it/s]
==> Saving mesh to trial/mesh
[INFO] marching cubes thresh: 2.5 (3.3152773061539964e-12 ~ 12.096467971801758)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[/content/stable-dreamfusion/main.py](https://localhost:8080/#) in <module>
    143                 # a special loader for poisson mesh reconstruction,
    144                 # loader = NeRFDataset(opt, device=device, type='test', H=128, W=128, size=100).dataloader()
--> 145                 trainer.save_mesh()
    146 
    147     else:

3 frames
[/content/stable-dreamfusion/meshutils.py](https://localhost:8080/#) in clean_mesh(verts, faces, v_pct, min_f, min_d, repair, remesh)
     88 
     89     if v_pct > 0:
---> 90         ms.meshing_merge_close_vertices(threshold=pml.Percentage(v_pct)) # 1/10000 of bounding box diagonal
     91 
     92     ms.meshing_remove_duplicate_faces() # faces defined by the same verts

AttributeError: module 'pymeshlab' has no attribute 'Percentage'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants