Closed voruin closed 1 year ago
Something seems to go wrong when the build file is being written, given that the log says Emitting ninja build file C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117\nvdiffrast_plugin\build.ninja...
but you cannot see the file, or even the folder.
Could this be a permission issue, i.e., the process cannot write the file (or create the folder) in your AppData directory for some reason? The PyTorch installation you use also looks nonstandard, as it is located under your project directory (C:\Users\Voruin\test_dream\dreamfusion\lib\site-packages\torch
) according to the traceback. I haven't seen this kind of installation before — maybe you have multiple versions of PyTorch on your system that are somehow clashing?
To debug this further, you could find where the log line about emitting the ninja build file is printed, and insert additional prints to indicate where the file actually goes or if any errors occur.
The garbled error message is a bug in ninja. I'd guess the error is that the file is not found.
Thanks for replying!
The weird PyTorch installation location is because I used py -m venv dreamfusion
.\dreamfusion\scripts\activate
and created a virtual environment. Will this matter?
Anyway, I tried running without virtual environment, also tried running as administrator in cmd or PowerShell, but still get the same error:
Using C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117\nvdiffrast_plugin\build.ninja...
Building extension module nvdiffrast_plugin...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: error: loading 'build.ninja': 系统找不到指定的路径。
Traceback (most recent call last):
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\cpp_extension.py", line 1894, in _run_ninja_build
subprocess.run(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 526, 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 "C:\Users\Voruin\stable-dreamfusion\main.py", line 149, in <module>
trainer.save_mesh()
File "C:\Users\Voruin\stable-dreamfusion\nerf\utils.py", line 506, in save_mesh
self.model.export_mesh(save_path, resolution=self.opt.mcubes_resolution, decimate_target=self.opt.decimate_target)
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Users\Voruin\stable-dreamfusion\nerf\renderer.py", line 362, in export_mesh
_export(v, f)
File "C:\Users\Voruin\stable-dreamfusion\nerf\renderer.py", line 270, in _export
glctx = dr.RasterizeCudaContext()
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nvdiffrast\torch\ops.py", line 177, in __init__
self.cpp_wrapper = _get_plugin().RasterizeCRStateWrapper(cuda_device_idx)
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nvdiffrast\torch\ops.py", line 118, in _get_plugin
torch.utils.cpp_extension.load(name=plugin_name, sources=source_paths, extra_cflags=opts, extra_cuda_cflags=opts+['-lineinfo'], extra_ldflags=ldflags, with_cuda=True, verbose=True)
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\cpp_extension.py", line 1284, in load
return _jit_compile(
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\cpp_extension.py", line 1509, in _jit_compile
_write_ninja_file_and_build_library(
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\cpp_extension.py", line 1624, in _write_ninja_file_and_build_library
_run_ninja_build(
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\utils\cpp_extension.py", line 1910, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension 'nvdiffrast_plugin'
I've put the path containing ninja.exe
into the environment variable and have no idea why this problem keeps appearing.
I just tried manually creating the nvdiffrast_plugin
folder under C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117\
and copied the ninja
package into the folder directly and it gave me a new error module 'nvdiffrast_plugin' has no attribute 'RasterizeCRStateWrapper'. Did you mean: 'RasterizeGLStateWrapper'?
:
Guess that nvdiffrast_plugin was not successfully built by doing so. But after running this, it generates a build
folder with files under nvdiffrast_plugin
. So maybe it's not the permission issue?
Using C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file C:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117\nvdiffrast_plugin\build.ninja...
Building extension module nvdiffrast_plugin...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\debug_flags.cc /Fobuild\debug_flags.obj /Fdbuild\ninja.pdb
[2/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\edit_distance.cc /Fobuild\edit_distance.obj /Fdbuild\ninja.pdb
[3/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\depfile_parser.cc /Fobuild\depfile_parser.obj /Fdbuild\ninja.pdb
[4/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\eval_env.cc /Fobuild\eval_env.obj /Fdbuild\ninja.pdb
[5/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\graphviz.cc /Fobuild\graphviz.obj /Fdbuild\ninja.pdb
[6/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\clparser.cc /Fobuild\clparser.obj /Fdbuild\ninja.pdb
[7/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\deps_log.cc /Fobuild\deps_log.obj /Fdbuild\ninja.pdb
[8/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\dyndep.cc /Fobuild\dyndep.obj /Fdbuild\ninja.pdb
[9/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\build_log.cc /Fobuild\build_log.obj /Fdbuild\ninja.pdb
[10/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\graph.cc /Fobuild\graph.obj /Fdbuild\ninja.pdb
[11/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\dyndep_parser.cc /Fobuild\dyndep_parser.obj /Fdbuild\ninja.pdb
[12/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\json.cc /Fobuild\json.obj /Fdbuild\ninja.pdb
[13/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\clean.cc /Fobuild\clean.obj /Fdbuild\ninja.pdb
[14/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\lexer.cc /Fobuild\lexer.obj /Fdbuild\ninja.pdb
[15/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\parser.cc /Fobuild\parser.obj /Fdbuild\ninja.pdb
[16/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\version.cc /Fobuild\version.obj /Fdbuild\ninja.pdb
[17/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\string_piece_util.cc /Fobuild\string_piece_util.obj /Fdbuild\ninja.pdb
[18/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\manifest_parser.cc /Fobuild\manifest_parser.obj /Fdbuild\ninja.pdb
[19/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\status.cc /Fobuild\status.obj /Fdbuild\ninja.pdb
[20/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\state.cc /Fobuild\state.obj /Fdbuild\ninja.pdb
[21/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\getopt.c /Fobuild\getopt.obj /Fdbuild\
[22/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\missing_deps.cc /Fobuild\missing_deps.obj /Fdbuild\ninja.pdb
[23/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\msvc_helper-win32.cc /Fobuild\msvc_helper-win32.obj /Fdbuild\ninja.pdb
[24/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\metrics.cc /Fobuild\metrics.obj /Fdbuild\ninja.pdb
[25/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\line_printer.cc /Fobuild\line_printer.obj /Fdbuild\ninja.pdb
[26/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\msvc_helper_main-win32.cc /Fobuild\msvc_helper_main-win32.obj /Fdbuild\ninja.pdb
[27/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\includes_normalize-win32.cc /Fobuild\includes_normalize-win32.obj /Fdbuild\ninja.pdb
[28/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\subprocess-win32.cc /Fobuild\subprocess-win32.obj /Fdbuild\ninja.pdb
[29/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\util.cc /Fobuild\util.obj /Fdbuild\ninja.pdb
[30/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\disk_interface.cc /Fobuild\disk_interface.obj /Fdbuild\ninja.pdb
[31/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\minidump-win32.cc /Fobuild\minidump-win32.obj /Fdbuild\ninja.pdb
[32/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\build.cc /Fobuild\build.obj /Fdbuild\ninja.pdb
[33/35] cl /showIncludes /nologo /Zi /W4 /WX /wd4530 /wd4100 /wd4706 /wd4244 /wd4512 /wd4800 /wd4702 /wd4819 /wd4127 /wd4355 /wd4091 /GR- /wd4267 /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /D_HAS_EXCEPTIONS=0 /DNINJA_PYTHON="python.exe" /FS /Ox /DNDEBUG /GL -I. -c src\ninja.cc /Fobuild\ninja.obj /Fdbuild\ninja.pdb
[34/35] lib /nologo /ltcg /out:build\ninja.lib build\build.obj build\build_log.obj build\clean.obj build\clparser.obj build\debug_flags.obj build\depfile_parser.obj build\deps_log.obj build\disk_interface.obj build\dyndep.obj build\dyndep_parser.obj build\edit_distance.obj build\eval_env.obj build\graph.obj build\graphviz.obj build\json.obj build\lexer.obj build\line_printer.obj build\manifest_parser.obj build\metrics.obj build\missing_deps.obj build\parser.obj build\state.obj build\status.obj build\string_piece_util.obj build\util.obj build\version.obj build\subprocess-win32.obj build\includes_normalize-win32.obj build\msvc_helper-win32.obj build\msvc_helper_main-win32.obj build\minidump-win32.obj build\getopt.obj
[35/35] cl build\ninja.obj ninja.lib /nologo /link /DEBUG /libpath:build /LTCG /OPT:REF /OPT:ICF /out:ninja.exe
Generating code
Finished generating code
Loading extension module nvdiffrast_plugin...
Traceback (most recent call last):
File "C:\Users\Voruin\testagain\main.py", line 149, in <module>
trainer.save_mesh()
File "C:\Users\Voruin\testagain\nerf\utils.py", line 506, in save_mesh
self.model.export_mesh(save_path, resolution=self.opt.mcubes_resolution, decimate_target=self.opt.decimate_target)
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "C:\Users\Voruin\testagain\nerf\renderer.py", line 362, in export_mesh
_export(v, f)
File "C:\Users\Voruin\testagain\nerf\renderer.py", line 270, in _export
glctx = dr.RasterizeCudaContext()
File "C:\Users\Voruin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nvdiffrast\torch\ops.py", line 177, in __init__
self.cpp_wrapper = _get_plugin().RasterizeCRStateWrapper(cuda_device_idx)
AttributeError: module 'nvdiffrast_plugin' has no attribute 'RasterizeCRStateWrapper'. Did you mean: 'RasterizeGLStateWrapper'?
What I am doing is trying to run Stable Dreamfusion, when call python main.py --workspace trial -O --test --save_mesh
it will import nvdiffrast.torch in the process. There is no code calling ninja directly in the source code, so I am not sure where the log line about emitting the ninja
build file is printed. I can only find the part using nvdiffrast
, which is located at ./nerf/renderer.py. Is this the part that cause the error? How to further find out what the problem is? Sorry, I'm new to it. I really appreciate your help.
## stable-dreamfusion/nerf/renderer.py: 241-276
# unwrap uvs
import xatlas
import nvdiffrast.torch as dr
from sklearn.neighbors import NearestNeighbors
from scipy.ndimage import binary_dilation, binary_erosion
atlas = xatlas.Atlas()
atlas.add_mesh(v_np, f_np)
chart_options = xatlas.ChartOptions()
chart_options.max_iterations = 4 # for faster unwrap...
atlas.generate(chart_options=chart_options)
vmapping, ft_np, vt_np = atlas[0] # [N], [M, 3], [N, 2]
# vmapping, ft_np, vt_np = xatlas.parametrize(v_np, f_np) # [N], [M, 3], [N, 2]
vt = torch.from_numpy(vt_np.astype(np.float32)).float().to(device)
ft = torch.from_numpy(ft_np.astype(np.int64)).int().to(device)
# render uv maps
uv = vt * 2.0 - 1.0 # uvs to range [-1, 1]
uv = torch.cat((uv, torch.zeros_like(uv[..., :1]), torch.ones_like(uv[..., :1])), dim=-1) # [N, 4]
if ssaa > 1:
h = int(h0 * ssaa)
w = int(w0 * ssaa)
else:
h, w = h0, w0
if h <= 2048 and w <= 2048:
glctx = dr.RasterizeCudaContext()
else:
glctx = dr.RasterizeGLContext()
rast, _ = dr.rasterize(glctx, uv.unsqueeze(0), ft, (h, w)) # [1, h, w, 4]
xyzs, _ = dr.interpolate(v.unsqueeze(0), rast, f) # [1, h, w, 3]
mask, _ = dr.interpolate(torch.ones_like(v[:, :1]).unsqueeze(0), rast, f) # [1, h, w, 1]
This error: module 'nvdiffrast_plugin' has no attribute 'RasterizeCRStateWrapper'. Did you mean: 'RasterizeGLStateWrapper'?
is interesting. The RasterizeCRStateWrapper
class was added in the C++ extension in nvdiffrast v0.3.0, and the older RasterizeGLStateWrapper
was moved into a separate C++ extension named nvdiffrast_plugin_gl
.
So in short, the error message suggests that the python side is from nvdiffrast v0.3.0, whereas the C++ extension is from nvdiffrast v0.2.8 or older. I don't know how this could happen.
What do you mean by "copied the ninja package into the folder directly"? Does the dreamfusion codebase come with a pre-compiled version of the nvdiffrast extension plugin? The compilation log looks like it's compiling ninja itself, not the nvdiffrast extension plugin, yet it somehow finds the RasterizeGLStateWrapper
somewhere in there. I'm thoroughly confused by all of this.
I haven't personally used virtual environments, and I don't know if the extension compilation mechanism could somehow be confused by it. On the other hand, nvdiffrast uses PyTorch's standard torch.utils.cpp_extension.load()
to compile and load the extension, and if using a virtual environment broke that, it would break a lot of other projects too.
I reinstalled many packages including cuda toolkit. I also ran Visual C++ Redistributable, installed MinGW, rebuild a virtual environment and installed all requirements again. It finally works. Don't know which step changed this. I think it should not be the nvdiffrast's problem, because it gave similar error when runing other projects which wants to build a plugin at the same place. Thank you very much for your patient reply!
Glad to hear you got it working!
Hello, I got the error during building extension 'nvdiffrast_plugin'. I struggled for hours and still haven't fixed it.
And here is the output when I run
pip list
:I also looked up your answers to similar questions and change the code
torch.utils.cpp_extension.load(name=plugin_name, sources=source_paths, extra_cflags=opts, extra_cuda_cflags=opts+['-lineinfo'], extra_ldflags=ldflags, with_cuda=True, verbose=False)
to..., verbose=True)
innvdiffrast\torch\ops.py
, and the errors are:I also did not see
nvdiffrast_plugin
folder underC:\Users\Voruin\AppData\Local\torch_extensions\torch_extensions\Cache\py310_cu117
. I don't know why. Also don't know why ninja is giving me garbled errorsCan anyone help me out? Thanks a lot!!!
Best,