nerfstudio icon indicating copy to clipboard operation
nerfstudio copied to clipboard

Nerfstudio not compile with latest Visual Studio 2022 due to MSC 1950

Open abrahamezzeddine opened this issue 1 year ago • 3 comments

Describe the bug Nerfstudio is not compatible with current Visual Studio 2022 17.10 due to differences in the MSC version being (194x)

#if _MSC_VER < 1910 || _MSC_VER >= 1940

The only version that supports the latest release Visual Studio 2022 17.10 is latest CUDA 12.5.

#if _MSC_VER < 1910 || _MSC_VER >= 1950

However, CUDA only supports compilers up to 193x according to the website. https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html

CUDA Requirements: MSVC Version 193x Visual Studio 2022 17.x

17.10 is however 194x when checking the cl.exe file.

To Reproduce To reproduce this error, install Nerfstudio from scratch using the latest Visual Studio 2022 17.10. Gsplat and Tiny Cuda will nt compile because CUDA 11.8 is not compatible.

Expected behavior A successful installation of nerfstudio

Additional context In order to install Nerfstudio, you must download and install an older version or Visual Studio 2022 17.9x.

https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#updating-your-installation-to-a-specific-release

Link to earlier releases. I guess Microsoft is pushing for this to have everyone install Copilot with the new Visual Studio 2022 update to 17.10, creating this incompability.

abrahamezzeddine avatar May 23 '24 04:05 abrahamezzeddine

fyi, we accidentally noticed that CUDA 12.4.0 could potentially work for Visual Studio 2022 17.10 e.g. https://github.com/pytorch/vision/actions/runs/9502323845/job/26190040599#step:11:154 is using Visual Studio 2022 Developer Command Prompt v17.10.1 and the CUDA version was 12.4.0.

nWEIdia avatar Jun 14 '24 00:06 nWEIdia

fyi, we accidentally noticed that CUDA 12.4.0 could potentially work for Visual Studio 2022 17.10 e.g. https://github.com/pytorch/vision/actions/runs/9502323845/job/26190040599#step:11:154 is using Visual Studio 2022 Developer Command Prompt v17.10.1 and the CUDA version was 12.4.0.

Does Nerfstudio work with CUDA 12.4? I am interested to know. Thanks!

abrahamezzeddine avatar Jun 25 '24 17:06 abrahamezzeddine

From my point of view, our documentation below was a little conservative

CUDA Requirements: MSVC Version 193x Visual Studio 2022 17.x

The https://github.com/pytorch/vision/actions/runs/9502323845/job/26190040599#step:11:154 is a proof that CUDA 12.4.0 indeed worked fine (in compiling and building pytorch) with MSVC Version 194 (VS 2022 Developer Command Prompt v17.10.1)

So, Nerfstudio should work with CUDA 12.4.

nWEIdia avatar Jun 25 '24 17:06 nWEIdia

I was able to install and use nerfstudio on Windows with the latest Visual Studio Community 2022 version from the app store and a few other newer dependencies, specifically:

Visual Studio Community 2022 17.14.11 Python 3.11 CUDA 12.9 Windows 11

Steps:

Create and activate your conda environment:

conda create --name nerfstudio -y python=3.11
conda activate nerfstudio

Update pip:

python -m pip install --upgrade pip

Install torch compiled for CUDA 12.9:

pip install --upgrade torch torchvision --extra-index-url https://download.pytorch.org/whl/cu129

Verify that torch is indeed compiled with CUDA by running:

python -c "import torch; print(torch.__version__); print(torch.cuda._is_compiled()); print(torch.version.cuda); print(torch.zeros(1).cuda())"

You should see output similar to:

2.8.0+cu129
True
12.9
tensor([0.], device='cuda:0')

Optional undo: If something wrong with the torch installation again you can undo this step by removing the packages, checking the official installation instructions on https://pytorch.org/get-started/locally/ and trying again:

pip uninstall -y torch torchvision functorch tinycudann

Install cuda-toolkit.

  • Newer versions of cuda-toolkit were split into smaller packages so because later steps of this process will need nvcc.exe you'll need to also install cuda-nvcc_win-64.
  • You can find the current list of cuda-toolkit versions here: https://anaconda.org/nvidia/cuda-toolkit
  • Additionally it's good to install vs2022_win-64 as it will cause your C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat to run automatically to setup the environment for compilation with Visual Studio every time the conda environment is activated.
conda install -y nvidia/label/cuda-12.9.1::cuda-toolkit nvidia/label/cuda-12.9.1::cuda-nvcc_win-64 vs2022_win-64

Check that nvcc.exe is in your %PATH%:

where nvcc

Optional undo: If something goes wrong above, you can undo this step by removing the conda packages before trying again:

conda remove -y cuda-toolkit cuda-nvcc_win-64 vs2022_win-64

Set your GPU architecture based on the numbers from https://developer.nvidia.com/cuda-gpus :

set TCNN_CUDA_ARCHITECTURES=NN

Allow the tinycudann build to find nv/target with never versions of cuda-toolkit:

set INCLUDE=%CONDA_PREFIX%\Library\include\targets\x64;%INCLUDE%

Build and install tinycudann:

pip install --verbose --no-build-isolation git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

Finally install Nerfstudio and, optionally, gsplat:

pip install nerfstudio gsplat

If you ever need to go back and try again from scratch just remove the conda environment:

conda deactivate
conda remove -n nerfstudio --all -y

Common problems:

If you get errors like CUDA_HOME environment variable is not set then it's possible you didn't install nvcc.exe or it's not being found in your %PATH% for some reason. Another possible reason for this error is that the version of torch that you've installed isn't compiled with CUDA. Use the validation steps above to double-check.

These helped:

  • https://github.com/conda/conda/issues/7757
  • https://github.com/trianglesplatting/triangle-splatting/issues/17
  • https://forums.developer.nvidia.com/t/why-does-cuda-fp16-h-hpp-require-nv-target-what-does-that-file-do/251000
  • https://stackoverflow.com/questions/75751907/oserror-cuda-home-environment-variable-is-not-set-please-set-it-to-your-cuda-i

plouj avatar Aug 09 '25 17:08 plouj

@plouj Thank you so much!!!! works like a charm for vs studio community 2022 v17.14+

MdotO avatar Aug 19 '25 21:08 MdotO

@plouj Thanks man, that worked flawless! I have been trying to set nerfstudio up on Win11 with RTX5090 for some time now. Needed Cuda 12.9 to be fully supported. tried with VS Studio Community 2022 v17.14.16. Runs really good (about 250 K rays /sec during training of poster data). Only thing I had to do is to set the $HOME variable (set HOME=%USERPROFILE%).

vdausmann avatar Oct 09 '25 11:10 vdausmann