NVlabs / tiny-cuda-nn

Lightning fast C++/CUDA neural network framework
Other
3.66k stars 449 forks source link

Error when install on Windows 11 #200

Open GuillaumeFX opened 1 year ago

GuillaumeFX commented 1 year ago

C:\Windows\System32>pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

Collecting git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch Cloning https://github.com/NVlabs/tiny-cuda-nn/ to c:\users\guilla~1\appdata\local\temp\pip-req-build-qac_cyqn Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/tiny-cuda-nn/ 'C:\Users\GUILLA~1\AppData\Local\Temp\pip-req-build-qac_cyqn' Resolved https://github.com/NVlabs/tiny-cuda-nn/ to commit c18f6803668dec3a56a36deaa48d53f7a0582d8d Running command git submodule update --init --recursive -q Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [7 lines of output] Traceback (most recent call last): File "", line 36, in File "", line 34, in File "C:\Users\GUILLA~1\AppData\Local\Temp\pip-req-build-qac_cyqn\bindings/torch\setup.py", line 30, in raise EnvironmentError("Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically.") OSError: Unknown compute capability. Specify the target compute capabilities in the TCNN_CUDA_ARCHITECTURES environment variable or install PyTorch with the CUDA backend to detect it automatically. Building PyTorch extension for tiny-cuda-nn version 1.6 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

swframe commented 1 year ago

Make sure you install cuda 11.7 after installing MS VS 2019. The cuda 11 installer edits the MS VS configuration so VS knows how to build cuda code. That should fix the TCNN_CUDA_ARCHITECTURES problem you reported.

I suspect you will run into another problem with c++ language settings diff between tiny-cuda-nn, cuda 11 and VS. MS Visual Studio 2019 installed includes files that require c++17. The tiny-cuda-nn CMakeLists.txt sets the cxx version to c++14. I couldn't downgrade the VS header files correctly but you might want to try that if you know how to config MS VS. Instead, I updated the tiny-cuda-nn's CMakeLists.txt to use c++17 since the nvcc docs says it supports c++17. I changed the CMakeLists.txt config: set(CMAKE_CXX_STANDARD 14) to set(CMAKE_CXX_STANDARD 17) and set(CMAKE_CUDA_STANDARD 14) to set(CMAKE_CUDA_STANDARD 17)

That allowed me to build locally but note I initially tried to use cuda 11.3 but it has a few files that require c++14 and from googling I decided it was easier to upgrade to cuda 11.7. There is supposed to be version of 11.3 that fixes the c++17 issues but I didn't know why it wouldn't already be in the latest 11.3 install files since the bug was reported last year.

The torch bindings are compiled using flags defined in bindings/torch/setup.py. I changed -std=c++14 to -std=c++17 and ran git install bindings/torch locally. As the docs says, if you build locally on windows make sure you run the 'Developer Command Prompt for VS 2019' since it sets the env correctly.

I want to share what I've found with you but please understand I may not be able to explain to you how to fix all the problems you might have with tiny-cuda-nn. I'm not affiliated with this project.

Jordan-Pierce commented 1 year ago

Add to @swframe's comment: I had VS 2022 and Cuda 11.3 installed. Was getting a lot of linking errors. I started fresh by uninstalling VS 2022 and installing VS 2019 (community), I installed ninja (maybe that helped), and then Cuda 11.7

Installed tiny cuda using pip properly with these changes

Mrhetsko commented 1 year ago

@swframe , Thank You. Its alive now)