nerfstudio-project / nerfacc

A General NeRF Acceleration Toolbox in PyTorch.
https://www.nerfacc.com/
Other
1.38k stars 113 forks source link

ImportError: cannot import name 'csrc' from 'nerfacc' when trying to train with instant-ngp #238

Open apassemard opened 1 year ago

apassemard commented 1 year ago

Hello, I've been trying to train a custom model with instant-ngp but facing this error:

C:\Users\anton.conda\envs\nerfstudio\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified warnings.warn(f'Error checking compiler version for {compiler}: {error}') ( ● ) NerfAcc: Setting up CUDA (This may take a few minutes the first time)INFO: Could not find files for the given pattern(s). Printing profiling stats, from longest to shortest duration in seconds Trainer.train_iteration: 1.6244 VanillaPipeline.get_train_loss_dict: 1.6234 Traceback (most recent call last): File "C:\Users\anton.conda\envs\nerfstudio\lib\site-packages\nerfacc\cuda_backend.py", line 53, in from nerfacc import csrc as _C ImportError: cannot import name 'csrc' from 'nerfacc' (C:\Users\anton.conda\envs\nerfstudio\lib\site-packages\nerfacc__init__.py)

My environment works great with nerfacto just FYI, I'm on Windows 11 and have nerfacc 0.5.2 cuda 11.8 torch 2.0.1

Any pointer?

dylanhu7 commented 1 year ago

It will try to compile nerfacc the first time you use it, so this build step may be failing. Is there any more information after the ImportError?

I ran into this issue because the version of my C compiler (gcc for me on Linux, not sure what it is exactly on Windows) was too high (11 works, 12 and 13 do not).

dylanhu7 commented 1 year ago

Here it looks like it cannot even find your compiler (perhaps referenced as cl on Windows?). I'm not too familiar with Windows but I would suggest looking at guidance on MSVC (Microsoft Visual C++). For example: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options?view=msvc-170

apassemard commented 1 year ago

I'll check it out and report. Thanks for the pointer.

savvaki commented 7 months ago

I'll check it out and report. Thanks for the pointer.

I know this is an old issue but did you manage to sort this out? I have the same issue.

HanTnx commented 7 months ago

PyTorch under Windows 10 reports an error UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the specified file.

Solution: This error is due to the fact that the vc environment is not configured in the environment variables, so you only need to configure the environment. First, you need to download any version of VS20xx. It is recommended to directly search for the cl.exe file in the C:\Program Files (x86)\Microsoft Visual Studio path and find the directory. Because my system is 64-bit, I have to choose 64-bit. If you are 32-bit, Just choose X86.

Like my cl.exe path is "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64"

Add the path into System Properties >>>Environments Variables >> Path (Edit Environment Variables)

Leonever commented 6 months ago

I meet the same issue. The details are as below: Can anyone help me? Error executing job with overrides: ['dataset.image_path=./example_data/livingroom/image.png', 'device.base_exp_dir=./exp'] Traceback (most recent call last): File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/nerfacc/cuda/_backend.py", line 53, in from nerfacc import csrc as _C ImportError: cannot import name 'csrc' from 'nerfacc' (/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/nerfacc/init.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1893, in _run_ninja_build subprocess.run( File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/subprocess.py", line 524, 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:

AdvancedHe commented 6 months ago

I meet the same issue. The details are as below: Can anyone help me? Error executing job with overrides: ['dataset.image_path=./example_data/livingroom/image.png', 'device.base_exp_dir=./exp'] Traceback (most recent call last): File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/nerfacc/cuda/_backend.py", line 53, in from nerfacc import csrc as _C ImportError: cannot import name 'csrc' from 'nerfacc' (/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/nerfacc/init.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1893, in _run_ninja_build subprocess.run( File "/home/journey_x/anaconda3/envs/perf/lib/python3.9/subprocess.py", line 524, 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:

Do you solve this problem?

rohit7044 commented 5 months ago

PyTorch under Windows 10 reports an error UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the specified file.

Solution: This error is due to the fact that the vc environment is not configured in the environment variables, so you only need to configure the environment. First, you need to download any version of VS20xx. It is recommended to directly search for the cl.exe file in the C:\Program Files (x86)\Microsoft Visual Studio path and find the directory. Because my system is 64-bit, I have to choose 64-bit. If you are 32-bit, Just choose X86.

Like my cl.exe path is "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64"

Add the path into System Properties >>>Environments Variables >> Path (Edit Environment Variables)

This one worked for me