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

automatically add the visual studio compiler folder to the environment path #351

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

martinResearch
Copy link
Contributor

@martinResearch martinResearch commented Aug 21, 2024

Problem:
In some case gsplat needs to compile cuda/c++ code on the fly (just-in-time compilation),
to handle different number of color channels for example, like done in the test test_rasterize_to_pixels when using channels=128.

In that case cl.exe needs to be on the path when on windows in order for pytorch to be able to do the compilation.
One can follow the step documented here
but that requires a manual step each time time one wants to use gsplat, which very unconvenient.

Solution:
We can instead add the folder automatically to the path at runtime using a mechanism used in CuPy here to discover the folder that contains the cl.exe file.

Ideally this mechanism would be implemented in pytorch, but that may take a while to be completed. We can implement it in gsplat in the mean time.

@martinResearch martinResearch changed the title automatically add the micosoft visual studio compiler binary to the environment path automatically add the visual studio compiler folder to the environment path Aug 21, 2024
@liruilong940607
Copy link
Collaborator

Hey this looks useful! I'm not a windows player but this PR in general looks reasonable to me, with a few question:

In some case gsplat needs to compile cuda/c++ code on the fly (just-in-time compilation),
to handle different number of color channels for example, like done in the test test_rasterize_to_pixels when using channels=128.

Just want to clarify channels=128 should not be any special w.r.t. compiling gsplat. If you install gsplat via pip install git+https://github.com/nerfstudio-project/gsplat/, it will trigger setup.py, which will build (compile) at installation and it should not trigger JIT after installation in any cases.

In that case cl.exe needs to be on the path

What is cl.exe? Is it something needed for JIT compile only?

@martinResearch
Copy link
Contributor Author

Cl.exe is the executable used to run the Microsoft visual studio compiler and linker. I misinterpreted the need for cl when running some of the tests as being due to jit compiling still being required after the package Install. I will investigate why cl is still needed for some tests at runtime.

@martinResearch
Copy link
Contributor Author

I realized the problem is in the nerfacc library, not in gsplat.
The installation using pip install nerfacc uses the pipy.org file nerfacc-0.5.3-py3-none-any.whl and not nerfacc-0.5.3.tar.gz and as a results the CUDA code is not compiled during the installation, but compiled one the fly the first time nerfacc is imported.
On windows, this requires cl.exe to be on the path at runtime. A workaround is to install nerfacc from source using pip install --no-binary=nerfacc nerfacc

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

Successfully merging this pull request may close these issues.

2 participants