From 3c40205f61c71d227c6f1a9c82d1c24eaea0e846 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 14:24:34 +0100 Subject: [PATCH 01/16] simplify the windows installation --- docs/INSTALL_WIN.md | 104 +++++++++++++++++++++++++++++++--------- environment.yml | 16 +++++++ gsplat/cuda/_backend.py | 35 ++++++++++++++ setup.py | 59 ++++++++++++++++++----- 4 files changed, 180 insertions(+), 34 deletions(-) create mode 100644 environment.yml diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index a79366dd0..a040b6255 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -4,7 +4,35 @@ Follow these steps to install `gsplat` on Windows. ## Prerequisites -1. Install Visual Studio Build Tools. If MSVC 143 does not work, you may also need to install MSVC 142 for Visual Studio 2019. And your CUDA environment should be set up properly. +1. Install Visual Studio Build Tools. If MSVC 143 does not work, you may also need to install MSVC 142 for Visual Studio 2019. +2. Install CUDA Toolkit 11.8 and setup the CUDA_PATH Variable. The toolkit installer can be downloaded from. +We recommand to skip this step and instead to use conda to install the CUDA dependencies in isolation in the python environment (see bellow). + + +## Create the python environment + +We recommand create the python environement using conda because it allows to install the CUDA dependencies in isolation. + +Run `conda env create -f environment.yml` with the following `environment.yml` file + +``` +name: gsplat +channels: + - pytorch + - defaults + - nvidia/label/cuda-11.8.0 + - conda-forge +dependencies: + - python=3.10 + - cuda-version==11.8 + - cudnn==8.9.7.29 + - cuda-toolkit=11.8 + - pytorch=2.1.0 + - pip: + - numpy==1.26.4 +variables: + CUDA_PATH: "" +``` 2. Activate your conda environment: ```bash @@ -15,29 +43,16 @@ Follow these steps to install `gsplat` on Windows. conda activate gsplat ``` -3. Activate your Visual C++ environment: - Navigate to the directory where `vcvars64.bat` is located. This path might vary depending on your installation. A common path is: - ``` - C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build - ``` -4. Run the following command: - ```bash - ./vcvars64.bat - ``` +## Install `gsplat` - If the above command does not work, try activating an older version of VC: - ```bash - ./vcvarsall.bat x64 -vcvars_ver= - ``` - Replace `` with the version of your VC++ compiler toolset. The version number should appear in the same folder. - - For example: - ```bash - ./vcvarsall.bat x64 -vcvars_ver=14.29 - ``` +gsplat can be installed using the source package in pypi.org or using a clone of the repository + +### Installation using the pypi package + +`pip install gsplat` -## Clone the Repository +### Installation using the Repository 5. Clone the `gsplat` repository: ```bash @@ -49,9 +64,54 @@ Follow these steps to install `gsplat` on Windows. cd gsplat ``` -## Install `gsplat` 7. Install `gsplat` using pip: ```bash pip install . ``` + you can install in edit mode using `pip install -e .` + +## Run the tests + +Some additional dependencies are require to run all the tests. They can be installed using + +``` +pip install pytest numpy==1.26.4 +``` + +Some more dependencie are required to run the compression tests: +``` +pip install git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 +``` + +## Troubleshoot + +Error: +```fatal error C1083: Cannot open include file: 'glm/glm.hpp': No such file or directory``` + +Solutions: +glm is provided in the thridparty folder when using tje `--recursive` argument when clonning the repository. +Alternativeley you can use `git submodule init` and `git submodule update`. + + +Error: +``` +A module that was compiled using NumPy 1.x cannot be run in +NumPy 2.1.0 as it may crash. To support both 1.x and 2.x +versions of NumPy, modules must be compiled with NumPy 2.0. +Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. +``` +Solution: + +install numpy 1.26.4. + +```subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1``` +make sure cl.exd is in the path. Note the cl should be automatically found after PR ? + + +```NerfAcc: No CUDA toolkit found. NerfAcc will be disabled.``` +make sure `nvcc.exe` in in the path once the python environment has been activated. It shoudl have been installed in the conda environement with the line `cuda-toolkit=11.8` + + +```TypeError: sparse_coo_tensor() received an invalid combination of arguments - got (indices=Tensor, values=Tensor, size=torch.Size, is_coalesced=bool, )```. + `is_coalesced` has been added in pytorch 2.1 \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 000000000..3d4e25fed --- /dev/null +++ b/environment.yml @@ -0,0 +1,16 @@ +name: gsplat +channels: + - pytorch + - defaults + - nvidia/label/cuda-11.8.0 + - conda-forge +dependencies: + - python=3.10 + - cuda-version==11.8 + - cudnn==8.9.7.29 + - cuda-toolkit=11.8 + - pytorch=2.1.0 + - pip: + - numpy==1.26.4 +variables: + CUDA_PATH: "" \ No newline at end of file diff --git a/gsplat/cuda/_backend.py b/gsplat/cuda/_backend.py index b646c0bcb..442f9977f 100644 --- a/gsplat/cuda/_backend.py +++ b/gsplat/cuda/_backend.py @@ -10,6 +10,9 @@ _import_module_from_library, load, ) +import platform +import warnings +import sys PATH = os.path.dirname(os.path.abspath(__file__)) NO_FAST_MATH = os.getenv("NO_FAST_MATH", "0") == "1" @@ -19,6 +22,38 @@ need_to_unset_max_jobs = True os.environ["MAX_JOBS"] = "10" +def _get_extra_path_for_msvc(): + "copied from cupy/cuda/compiler.py" + + cl_exe = shutil.which('cl.exe') + if cl_exe: + # The compiler is already on PATH, no extra path needed. + return None + + try: + import setuptools + vctools = setuptools.msvc.EnvironmentInfo(platform.machine()).VCTools + except Exception as e: + warnings.warn(f'Failed to auto-detect cl.exe path: {type(e)}: {e}') + return None + + for path in vctools: + cl_exe = os.path.join(path, 'cl.exe') + if os.path.exists(cl_exe): + return path + warnings.warn(f'cl.exe could not be found in {vctools}') + return None + +def add_msvc_path(): + """Add MSVC path to PATH.""" + extra_path = _get_extra_path_for_msvc() + if extra_path is not None: + # add path to PATH + os.environ['PATH'] = os.pathsep.join([extra_path, os.environ['PATH']]) + assert shutil.which('cl.exe') is not None, "cl.exe not found in PATH" + +if sys.platform == "win32": + add_msvc_path() def load_extension( name, diff --git a/setup.py b/setup.py index 3ea2dfe33..bb8c19210 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ import sys from setuptools import find_packages, setup +import shutil, warnings __version__ = None exec(open("gsplat/version.py", "r").read()) @@ -23,6 +24,37 @@ print(f"Setting MAX_JOBS to {os.environ['MAX_JOBS']}") +def _get_extra_path_for_msvc(): + "copied from cupy/cuda/compiler.py" + + cl_exe = shutil.which('cl.exe') + if cl_exe: + # The compiler is already on PATH, no extra path needed. + return None + + try: + import setuptools + vctools = setuptools.msvc.EnvironmentInfo(platform.machine()).VCTools + except Exception as e: + warnings.warn(f'Failed to auto-detect cl.exe path: {type(e)}: {e}') + return None + + for path in vctools: + cl_exe = os.path.join(path, 'cl.exe') + if os.path.exists(cl_exe): + return path + warnings.warn(f'cl.exe could not be found in {vctools}') + return None + +def add_msvc_path(): + """Add MSVC path to PATH.""" + extra_path = _get_extra_path_for_msvc() + if extra_path is not None: + # add path to PATH + os.environ['PATH'] = os.pathsep.join([extra_path, os.environ['PATH']]) + assert shutil.which('cl.exe') is not None, "cl.exe not found in PATH" + + def get_ext(): from torch.utils.cpp_extension import BuildExtension @@ -50,6 +82,7 @@ def get_extensions(): define_macros = [] if sys.platform == "win32": + add_msvc_path() define_macros += [("gsplat_EXPORTS", None)] extra_compile_args = {"cxx": ["-O3"]} @@ -97,15 +130,18 @@ def get_extensions(): current_dir = pathlib.Path(__file__).parent.resolve() glm_path = os.path.join(current_dir, "gsplat", "cuda", "csrc", "third_party", "glm") - extension_v1 = CUDAExtension( - "gsplat.csrc_legacy", - sources_v1, - include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. - define_macros=define_macros, - undef_macros=undef_macros, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, - ) + extensions = [] + # extension_v1 = CUDAExtension( + # "gsplat.csrc_legacy", + # sources_v1, + # include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. + # define_macros=define_macros, + # undef_macros=undef_macros, + # extra_compile_args=extra_compile_args, + # extra_link_args=extra_link_args, + # ) + # extensions.append(extension_v1) + extension_v2 = CUDAExtension( "gsplat.csrc", sources_v2, @@ -115,9 +151,8 @@ def get_extensions(): extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) - - return [extension_v1, extension_v2] - + extensions.append(extension_v2) + return extensions setup( name="gsplat", From 7bbf8adbac58ca5865038cbb59cc6b5ab4f77d68 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 15:11:26 +0100 Subject: [PATCH 02/16] improve the windows installation documentation --- docs/INSTALL_WIN.md | 112 +++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 73 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index a040b6255..d6866e9bf 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -4,68 +4,56 @@ Follow these steps to install `gsplat` on Windows. ## Prerequisites -1. Install Visual Studio Build Tools. If MSVC 143 does not work, you may also need to install MSVC 142 for Visual Studio 2019. -2. Install CUDA Toolkit 11.8 and setup the CUDA_PATH Variable. The toolkit installer can be downloaded from. -We recommand to skip this step and instead to use conda to install the CUDA dependencies in isolation in the python environment (see bellow). +### Visual Studio Build Tools +Install Visual Studio Build Tools. If MSVC 143 does not work, you may also need to install MSVC 142 for Visual Studio 2019. -## Create the python environment +### CUDA Toolkit -We recommand create the python environement using conda because it allows to install the CUDA dependencies in isolation. +We recommend installing the CUDA dependencies as part of the Conda python environment creation. This has the advantage to install the CUDA dependencies automatically and in isolation from other python environment on the system, making the process less error prone. -Run `conda env create -f environment.yml` with the following `environment.yml` file +Alternatively, you can install CUDA Toolkit 11.8 using the installer from [here](https://developer.nvidia.com/cuda-11-8-0-download-archive). You will then need to setup the PATH and CUDA_PATH variables accordingly. -``` -name: gsplat -channels: - - pytorch - - defaults - - nvidia/label/cuda-11.8.0 - - conda-forge -dependencies: - - python=3.10 - - cuda-version==11.8 - - cudnn==8.9.7.29 - - cuda-toolkit=11.8 - - pytorch=2.1.0 - - pip: - - numpy==1.26.4 -variables: - CUDA_PATH: "" +## Python environment setup + +We suggest using Conda to create the Python environment as it enables you to install the CUDA dependencies in isolation. + +### Create the python environment using Conda. +Run `conda env create -f environment.yml -n ` with the `environment.yml`[environment.yml] you will find [here](../environment.yml). + +### Activate your conda environment: + +```bash +conda activate ``` -2. Activate your conda environment: - ```bash - conda activate - ``` - Replace `` with the name of your conda environment. For example: - ```bash - conda activate gsplat - ``` +Replace `` with the name of your conda environment. For example: +```bash +conda activate gsplat +``` ## Install `gsplat` -gsplat can be installed using the source package in pypi.org or using a clone of the repository +`gsplat` can be installed using either the source package published in `pypi.org` or using a clone of the repository ### Installation using the pypi package -`pip install gsplat` +Run `pip install gsplat` ### Installation using the Repository -5. Clone the `gsplat` repository: +1. Clone the `gsplat` repository: ```bash git clone --recursive https://github.com/nerfstudio-project/gsplat.git ``` -6. Change into the `gsplat` directory: +2. Change into the `gsplat` directory: ```bash cd gsplat ``` - -7. Install `gsplat` using pip: +3. Install `gsplat` using pip: ```bash pip install . ``` @@ -73,45 +61,23 @@ gsplat can be installed using the source package in pypi.org or using a clone of ## Run the tests -Some additional dependencies are require to run all the tests. They can be installed using +You will need to install the package in edit mode using `pip install -e .` for the tests to run as some of the tests assets are not packaged in the package. -``` -pip install pytest numpy==1.26.4 -``` - -Some more dependencie are required to run the compression tests: -``` -pip install git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 -``` - -## Troubleshoot - -Error: -```fatal error C1083: Cannot open include file: 'glm/glm.hpp': No such file or directory``` - -Solutions: -glm is provided in the thridparty folder when using tje `--recursive` argument when clonning the repository. -Alternativeley you can use `git submodule init` and `git submodule update`. +Some additional dependencies are required to run all the tests. They can be installed using `pip install pytest` +Some more dependencie are required to run the compression tests. They can be installed using `pip install nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3` -Error: -``` -A module that was compiled using NumPy 1.x cannot be run in -NumPy 2.1.0 as it may crash. To support both 1.x and 2.x -versions of NumPy, modules must be compiled with NumPy 2.0. -Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. -``` -Solution: - -install numpy 1.26.4. +You can then run the test using `pytest tests` -```subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1``` -make sure cl.exd is in the path. Note the cl should be automatically found after PR ? - - -```NerfAcc: No CUDA toolkit found. NerfAcc will be disabled.``` -make sure `nvcc.exe` in in the path once the python environment has been activated. It shoudl have been installed in the conda environement with the line `cuda-toolkit=11.8` +Note: the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) +## Troubleshoot -```TypeError: sparse_coo_tensor() received an invalid combination of arguments - got (indices=Tensor, values=Tensor, size=torch.Size, is_coalesced=bool, )```. - `is_coalesced` has been added in pytorch 2.1 \ No newline at end of file +We list here some errors that can be uncountered when following the process above with possible solutions. +|Error|Solution| +|-----|--------| +|fatal error C1083: Cannot open include file: 'glm/glm.hpp': No such file or directory| glm is provided in the thridparty folder when using tje `--recursive` argument when clonning the repository. Alternativeley you can use `git submodule init` and `git submodule update`. +A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.0 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0.Some module may need to rebuild instead e.g. with 'pybind11>=2.12'`| install numpy 1.26.4. +subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1| make sure the visual studio compiler `cl.exe` is in the path. +NerfAcc: No CUDA toolkit found. NerfAcc will be disabled.| make sure `nvcc.exe` in in the path once the python environment has been activated. It should have been installed in the conda environement with the line `cuda-toolkit=11.8` +TypeError: sparse_coo_tensor() received an invalid combination of arguments - got (indices=Tensor, values=Tensor, size=torch.Size, is_coalesced=bool, ).| `is_coalesced` has been added in pytorch 2.1 \ No newline at end of file From f22774ad91b3297cd832be0b41a4606f644ad041 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 15:21:43 +0100 Subject: [PATCH 03/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index d6866e9bf..15a481db7 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -19,7 +19,7 @@ Alternatively, you can install CUDA Toolkit 11.8 using the installer from [here] We suggest using Conda to create the Python environment as it enables you to install the CUDA dependencies in isolation. ### Create the python environment using Conda. -Run `conda env create -f environment.yml -n ` with the `environment.yml`[environment.yml] you will find [here](../environment.yml). +Run `conda env create -f environment.yml -n ` with the `environment.yml` file you will find [here](../environment.yml). ### Activate your conda environment: From bc5a25ce8131c85a9e46273b15a2d22f8fc0bab2 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 15:46:55 +0100 Subject: [PATCH 04/16] remove cl.exe auto discovery --- docs/INSTALL_WIN.md | 22 +++++++++++++---- gsplat/cuda/_backend.py | 33 -------------------------- setup.py | 52 ++++++++--------------------------------- 3 files changed, 28 insertions(+), 79 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 15a481db7..297b2c1ab 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -18,10 +18,10 @@ Alternatively, you can install CUDA Toolkit 11.8 using the installer from [here] We suggest using Conda to create the Python environment as it enables you to install the CUDA dependencies in isolation. -### Create the python environment using Conda. +### 1. Create the python environment using Conda. Run `conda env create -f environment.yml -n ` with the `environment.yml` file you will find [here](../environment.yml). -### Activate your conda environment: +### 2. Activate your conda environment: ```bash conda activate @@ -33,6 +33,20 @@ Replace `` with the name of your conda environment. For conda activate gsplat ``` +### 3. Activate the Visual Studio C++ environment + +1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: +``` +C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build +``` + +2. Run the following command: +``` +./vcvars64.bat +``` + +3. Check that `cl.exe` is in the path by using `where cl.exe`. + ## Install `gsplat` `gsplat` can be installed using either the source package published in `pypi.org` or using a clone of the repository @@ -61,7 +75,7 @@ Run `pip install gsplat` ## Run the tests -You will need to install the package in edit mode using `pip install -e .` for the tests to run as some of the tests assets are not packaged in the package. +You will need to install the package in edit mode using `pip install -e .` for the tests to run as some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environement as described above before running the tests because some of the test use jit compilation to compile code that has not beend compile during the package installation. Some additional dependencies are required to run all the tests. They can be installed using `pip install pytest` @@ -78,6 +92,6 @@ We list here some errors that can be uncountered when following the process abov |-----|--------| |fatal error C1083: Cannot open include file: 'glm/glm.hpp': No such file or directory| glm is provided in the thridparty folder when using tje `--recursive` argument when clonning the repository. Alternativeley you can use `git submodule init` and `git submodule update`. A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.0 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0.Some module may need to rebuild instead e.g. with 'pybind11>=2.12'`| install numpy 1.26.4. -subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1| make sure the visual studio compiler `cl.exe` is in the path. +subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1| make sure the visual studio compiler `cl.exe` is in the path (see section on activating the visual studio C++ environment) . NerfAcc: No CUDA toolkit found. NerfAcc will be disabled.| make sure `nvcc.exe` in in the path once the python environment has been activated. It should have been installed in the conda environement with the line `cuda-toolkit=11.8` TypeError: sparse_coo_tensor() received an invalid combination of arguments - got (indices=Tensor, values=Tensor, size=torch.Size, is_coalesced=bool, ).| `is_coalesced` has been added in pytorch 2.1 \ No newline at end of file diff --git a/gsplat/cuda/_backend.py b/gsplat/cuda/_backend.py index 442f9977f..fe2b5a144 100644 --- a/gsplat/cuda/_backend.py +++ b/gsplat/cuda/_backend.py @@ -22,39 +22,6 @@ need_to_unset_max_jobs = True os.environ["MAX_JOBS"] = "10" -def _get_extra_path_for_msvc(): - "copied from cupy/cuda/compiler.py" - - cl_exe = shutil.which('cl.exe') - if cl_exe: - # The compiler is already on PATH, no extra path needed. - return None - - try: - import setuptools - vctools = setuptools.msvc.EnvironmentInfo(platform.machine()).VCTools - except Exception as e: - warnings.warn(f'Failed to auto-detect cl.exe path: {type(e)}: {e}') - return None - - for path in vctools: - cl_exe = os.path.join(path, 'cl.exe') - if os.path.exists(cl_exe): - return path - warnings.warn(f'cl.exe could not be found in {vctools}') - return None - -def add_msvc_path(): - """Add MSVC path to PATH.""" - extra_path = _get_extra_path_for_msvc() - if extra_path is not None: - # add path to PATH - os.environ['PATH'] = os.pathsep.join([extra_path, os.environ['PATH']]) - assert shutil.which('cl.exe') is not None, "cl.exe not found in PATH" - -if sys.platform == "win32": - add_msvc_path() - def load_extension( name, sources, diff --git a/setup.py b/setup.py index bb8c19210..c497ea4d9 100644 --- a/setup.py +++ b/setup.py @@ -24,37 +24,6 @@ print(f"Setting MAX_JOBS to {os.environ['MAX_JOBS']}") -def _get_extra_path_for_msvc(): - "copied from cupy/cuda/compiler.py" - - cl_exe = shutil.which('cl.exe') - if cl_exe: - # The compiler is already on PATH, no extra path needed. - return None - - try: - import setuptools - vctools = setuptools.msvc.EnvironmentInfo(platform.machine()).VCTools - except Exception as e: - warnings.warn(f'Failed to auto-detect cl.exe path: {type(e)}: {e}') - return None - - for path in vctools: - cl_exe = os.path.join(path, 'cl.exe') - if os.path.exists(cl_exe): - return path - warnings.warn(f'cl.exe could not be found in {vctools}') - return None - -def add_msvc_path(): - """Add MSVC path to PATH.""" - extra_path = _get_extra_path_for_msvc() - if extra_path is not None: - # add path to PATH - os.environ['PATH'] = os.pathsep.join([extra_path, os.environ['PATH']]) - assert shutil.which('cl.exe') is not None, "cl.exe not found in PATH" - - def get_ext(): from torch.utils.cpp_extension import BuildExtension @@ -82,7 +51,6 @@ def get_extensions(): define_macros = [] if sys.platform == "win32": - add_msvc_path() define_macros += [("gsplat_EXPORTS", None)] extra_compile_args = {"cxx": ["-O3"]} @@ -131,16 +99,16 @@ def get_extensions(): current_dir = pathlib.Path(__file__).parent.resolve() glm_path = os.path.join(current_dir, "gsplat", "cuda", "csrc", "third_party", "glm") extensions = [] - # extension_v1 = CUDAExtension( - # "gsplat.csrc_legacy", - # sources_v1, - # include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. - # define_macros=define_macros, - # undef_macros=undef_macros, - # extra_compile_args=extra_compile_args, - # extra_link_args=extra_link_args, - # ) - # extensions.append(extension_v1) + extension_v1 = CUDAExtension( + "gsplat.csrc_legacy", + sources_v1, + include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. + define_macros=define_macros, + undef_macros=undef_macros, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + ) + extensions.append(extension_v1) extension_v2 = CUDAExtension( "gsplat.csrc", From c2cbcbe8200cefe4342107ea8bc3a250dc8586c9 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 16:02:04 +0100 Subject: [PATCH 05/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 297b2c1ab..92252791b 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -35,6 +35,9 @@ conda activate gsplat ### 3. Activate the Visual Studio C++ environment +The installation script setup.pt should automatically find the path to the visual studio compiler. However `gsplat` also requires to be able to compile C++ code on the fly (jit compilation) in some instances, which requires `cl.exe` to be on the path. + +In order to have `cl.exe` on the path you can: 1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: ``` C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build From 0cca98d9ce3c1c58455db6c5ae4d8574851dfd92 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 16:31:48 +0100 Subject: [PATCH 06/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 92252791b..8ed41bbb1 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -35,7 +35,7 @@ conda activate gsplat ### 3. Activate the Visual Studio C++ environment -The installation script setup.pt should automatically find the path to the visual studio compiler. However `gsplat` also requires to be able to compile C++ code on the fly (jit compilation) in some instances, which requires `cl.exe` to be on the path. +The installation step using pip has a mechanism to automatically find the path to the visual studio compiler `cl.exe`, an thus one does not need to manually activate the visual studio environment to install `gsplat` with `pip`. However `gsplat` requires to be able to compile C++ code on the fly at runtime (just-in-time compilation) in some instances, which requires `cl.exe` to be on the path at runtime. This is the case for example when using 128 color channels. In order to have `cl.exe` on the path you can: 1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: From dcedae3acb6ed321e0f35662b8cb47030a1e40c6 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:14:13 +0100 Subject: [PATCH 07/16] cleaning the PR --- docs/INSTALL_WIN.md | 23 ++++++++++++++++++++++- environment.yml | 16 ---------------- gsplat/cuda/_backend.py | 4 +--- setup.py | 22 ++++++++++------------ 4 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 environment.yml diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 8ed41bbb1..83e422130 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -19,7 +19,28 @@ Alternatively, you can install CUDA Toolkit 11.8 using the installer from [here] We suggest using Conda to create the Python environment as it enables you to install the CUDA dependencies in isolation. ### 1. Create the python environment using Conda. -Run `conda env create -f environment.yml -n ` with the `environment.yml` file you will find [here](../environment.yml). + +Create conda `environment.yml` files containing +``` +name: +channels: + - pytorch + - defaults + - nvidia/label/cuda-11.8.0 + - conda-forge +dependencies: + - python=3.10 + - cuda-version==11.8 + - cudnn==8.9.7.29 + - cuda-toolkit=11.8 + - pytorch=2.1.0 + - pip: + - numpy==1.26.4 +variables: + CUDA_PATH: "" +``` + +Then run `conda env create -f environment.yml` ### 2. Activate your conda environment: diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 3d4e25fed..000000000 --- a/environment.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: gsplat -channels: - - pytorch - - defaults - - nvidia/label/cuda-11.8.0 - - conda-forge -dependencies: - - python=3.10 - - cuda-version==11.8 - - cudnn==8.9.7.29 - - cuda-toolkit=11.8 - - pytorch=2.1.0 - - pip: - - numpy==1.26.4 -variables: - CUDA_PATH: "" \ No newline at end of file diff --git a/gsplat/cuda/_backend.py b/gsplat/cuda/_backend.py index fe2b5a144..b646c0bcb 100644 --- a/gsplat/cuda/_backend.py +++ b/gsplat/cuda/_backend.py @@ -10,9 +10,6 @@ _import_module_from_library, load, ) -import platform -import warnings -import sys PATH = os.path.dirname(os.path.abspath(__file__)) NO_FAST_MATH = os.getenv("NO_FAST_MATH", "0") == "1" @@ -22,6 +19,7 @@ need_to_unset_max_jobs = True os.environ["MAX_JOBS"] = "10" + def load_extension( name, sources, diff --git a/setup.py b/setup.py index c497ea4d9..a96460bfe 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,6 @@ import sys from setuptools import find_packages, setup -import shutil, warnings __version__ = None exec(open("gsplat/version.py", "r").read()) @@ -98,17 +97,15 @@ def get_extensions(): current_dir = pathlib.Path(__file__).parent.resolve() glm_path = os.path.join(current_dir, "gsplat", "cuda", "csrc", "third_party", "glm") - extensions = [] extension_v1 = CUDAExtension( - "gsplat.csrc_legacy", - sources_v1, - include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. - define_macros=define_macros, - undef_macros=undef_macros, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, + "gsplat.csrc_legacy", + sources_v1, + include_dirs=[extensions_dir_v2, glm_path], # glm lives in v2. + define_macros=define_macros, + undef_macros=undef_macros, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, ) - extensions.append(extension_v1) extension_v2 = CUDAExtension( "gsplat.csrc", @@ -119,8 +116,9 @@ def get_extensions(): extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) - extensions.append(extension_v2) - return extensions + + return [extension_v1, extension_v2] + setup( name="gsplat", From 6b2510383a2d638851dbda21804e0cad58a958a2 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:18:39 +0100 Subject: [PATCH 08/16] clean PR --- docs/INSTALL_WIN.md | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 83e422130..806e247fd 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -85,6 +85,7 @@ Run `pip install gsplat` ```bash git clone --recursive https://github.com/nerfstudio-project/gsplat.git ``` + MAke sure you do not forget the `--recursive` argument to get the `glm/glm.hpp` file. 2. Change into the `gsplat` directory: ```bash @@ -99,23 +100,11 @@ Run `pip install gsplat` ## Run the tests -You will need to install the package in edit mode using `pip install -e .` for the tests to run as some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environement as described above before running the tests because some of the test use jit compilation to compile code that has not beend compile during the package installation. - -Some additional dependencies are required to run all the tests. They can be installed using `pip install pytest` - -Some more dependencie are required to run the compression tests. They can be installed using `pip install nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3` - +You will need to install the package in edit mode using `pip install -e .` for the tests to run because some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environment as described above before running the tests because some of the test use just-in-time compilation to compile code that has not been compiled during the package installation. +Some additional dependencies are required to run all the tests. They can be installed using +``` +pip install pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 +``` You can then run the test using `pytest tests` Note: the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) - -## Troubleshoot - -We list here some errors that can be uncountered when following the process above with possible solutions. -|Error|Solution| -|-----|--------| -|fatal error C1083: Cannot open include file: 'glm/glm.hpp': No such file or directory| glm is provided in the thridparty folder when using tje `--recursive` argument when clonning the repository. Alternativeley you can use `git submodule init` and `git submodule update`. -A module that was compiled using NumPy 1.x cannot be run in NumPy 2.1.0 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0.Some module may need to rebuild instead e.g. with 'pybind11>=2.12'`| install numpy 1.26.4. -subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1| make sure the visual studio compiler `cl.exe` is in the path (see section on activating the visual studio C++ environment) . -NerfAcc: No CUDA toolkit found. NerfAcc will be disabled.| make sure `nvcc.exe` in in the path once the python environment has been activated. It should have been installed in the conda environement with the line `cuda-toolkit=11.8` -TypeError: sparse_coo_tensor() received an invalid combination of arguments - got (indices=Tensor, values=Tensor, size=torch.Size, is_coalesced=bool, ).| `is_coalesced` has been added in pytorch 2.1 \ No newline at end of file From 75276e85f41a0d223c01fb45253f57f1bd8089a4 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:21:37 +0100 Subject: [PATCH 09/16] Update setup.py --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a96460bfe..3ea2dfe33 100644 --- a/setup.py +++ b/setup.py @@ -106,7 +106,6 @@ def get_extensions(): extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) - extension_v2 = CUDAExtension( "gsplat.csrc", sources_v2, @@ -116,7 +115,7 @@ def get_extensions(): extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) - + return [extension_v1, extension_v2] From 34b742c44343ea983cfa5fadbc881d15721f9f31 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:27:58 +0100 Subject: [PATCH 10/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 806e247fd..98f3ba672 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -60,14 +60,20 @@ The installation step using pip has a mechanism to automatically find the path t In order to have `cl.exe` on the path you can: 1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: -``` -C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build -``` + ``` + C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build + ``` 2. Run the following command: -``` -./vcvars64.bat -``` + ``` + ./vcvars64.bat + ``` + If the above command does not work, try activating an older version of VC: + ```bash + ./vcvarsall.bat x64 -vcvars_ver= + ``` + Replace `` with the version of your VC++ compiler toolset. The version number should appear in the same folder. For example `./vcvarsall.bat x64 -vcvars_ver=14.29` + 3. Check that `cl.exe` is in the path by using `where cl.exe`. @@ -75,11 +81,11 @@ C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Buil `gsplat` can be installed using either the source package published in `pypi.org` or using a clone of the repository -### Installation using the pypi package +### Installation using the package pub;ished on `pypi.org` Run `pip install gsplat` -### Installation using the Repository +### Installation using a clone of the repository 1. Clone the `gsplat` repository: ```bash From f956c07f14e056b3af2cf7b23e587c6e19f4bcc3 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:31:51 +0100 Subject: [PATCH 11/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 98f3ba672..56714ff1f 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -106,7 +106,7 @@ Run `pip install gsplat` ## Run the tests -You will need to install the package in edit mode using `pip install -e .` for the tests to run because some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environment as described above before running the tests because some of the test use just-in-time compilation to compile code that has not been compiled during the package installation. +You will need to clone the gsplat repository locally and install the gsplat package in edit mode using `pip install -e .` for the tests to run because some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environment as described above before running the tests because some of the test use just-in-time compilation to compile code that has not been compiled during the package installation. Some additional dependencies are required to run all the tests. They can be installed using ``` pip install pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 From 0d803df48fb7cc4eaa298b543a888907e6ece57d Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:32:11 +0100 Subject: [PATCH 12/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 56714ff1f..9eb35ff92 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -111,6 +111,6 @@ Some additional dependencies are required to run all the tests. They can be inst ``` pip install pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 ``` -You can then run the test using `pytest tests` +You can then run the tests using `pytest tests` Note: the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) From 55748f47db22a4c4c4072b04d2e01756beebba15 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Wed, 21 Aug 2024 17:34:15 +0100 Subject: [PATCH 13/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 9eb35ff92..6c9a21d60 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -40,10 +40,11 @@ variables: CUDA_PATH: "" ``` -Then run `conda env create -f environment.yml` +Then run `conda env create -f environment.yml` to create the conda environment. ### 2. Activate your conda environment: +Activate your environeent using: ```bash conda activate ``` @@ -102,7 +103,8 @@ Run `pip install gsplat` ```bash pip install . ``` - you can install in edit mode using `pip install -e .` + +Note: If you an to run the tests or modify the code you will to install the package in edit mode instead using `pip install -e .` ## Run the tests From b7d0a077f93c77240e75e1e61d774dd0e42addcc Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Thu, 22 Aug 2024 10:19:40 +0100 Subject: [PATCH 14/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 6c9a21d60..948d9b086 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -57,7 +57,7 @@ conda activate gsplat ### 3. Activate the Visual Studio C++ environment -The installation step using pip has a mechanism to automatically find the path to the visual studio compiler `cl.exe`, an thus one does not need to manually activate the visual studio environment to install `gsplat` with `pip`. However `gsplat` requires to be able to compile C++ code on the fly at runtime (just-in-time compilation) in some instances, which requires `cl.exe` to be on the path at runtime. This is the case for example when using 128 color channels. +The installation step using pip has a mechanism to automatically find the path to the visual studio compiler `cl.exe`, an thus one does not need to manually activate the visual studio environment to install `gsplat` with `pip`. However, depending on how the dependency `nerfacc` used in the tests is installed, you may still need to compile some C++ code on the fly at runtime (just-in-time compilation) to run the tests, which requires `cl.exe` to be on the path at runtime. In order to have `cl.exe` on the path you can: 1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: @@ -111,8 +111,10 @@ Note: If you an to run the tests or modify the code you will to install the pack You will need to clone the gsplat repository locally and install the gsplat package in edit mode using `pip install -e .` for the tests to run because some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environment as described above before running the tests because some of the test use just-in-time compilation to compile code that has not been compiled during the package installation. Some additional dependencies are required to run all the tests. They can be installed using ``` -pip install pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 +pip install --no-binary=nerfacc pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 ``` You can then run the tests using `pytest tests` -Note: the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) +Notes +* We use `--no-binary=nerfacc` so that the `nerfacc` CUDA code gets compiled during the installation step. Without this argument the nerfacc CUDA code is compiled on the fly during the first import, which requires the visual studio folder executable `cl.exe` to be on the path. +* the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) From 3a14ff26298ea69802be51dfae210f9adcb3f4f8 Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Thu, 22 Aug 2024 11:01:39 +0100 Subject: [PATCH 15/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 69 +++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index 948d9b086..f431569ed 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -55,36 +55,25 @@ Replace `` with the name of your conda environment. For conda activate gsplat ``` -### 3. Activate the Visual Studio C++ environment +## 3. Install `gsplat` -The installation step using pip has a mechanism to automatically find the path to the visual studio compiler `cl.exe`, an thus one does not need to manually activate the visual studio environment to install `gsplat` with `pip`. However, depending on how the dependency `nerfacc` used in the tests is installed, you may still need to compile some C++ code on the fly at runtime (just-in-time compilation) to run the tests, which requires `cl.exe` to be on the path at runtime. +`gsplat` can be installed using either the source package published in `pypi.org`, the wheel published on `pypi.org` or using a clone of the repository. -In order to have `cl.exe` on the path you can: -1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: - ``` - C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build - ``` +### Installation using the source package published on `pypi.org` -2. Run the following command: - ``` - ./vcvars64.bat - ``` - If the above command does not work, try activating an older version of VC: - ```bash - ./vcvarsall.bat x64 -vcvars_ver= - ``` - Replace `` with the version of your VC++ compiler toolset. The version number should appear in the same folder. For example `./vcvarsall.bat x64 -vcvars_ver=14.29` - - -3. Check that `cl.exe` is in the path by using `where cl.exe`. - -## Install `gsplat` - -`gsplat` can be installed using either the source package published in `pypi.org` or using a clone of the repository +We recommand install gsplat from the published source package and not the wheel by using +``` +pip install --no-binary=gsplat gsplat +``` +the CUDA code will be compiled during the installation and the cvisual stdio compiler `cl.exe` does not need to be added to the path, because the installation process as an automatic way to find it. -### Installation using the package pub;ished on `pypi.org` +### Installation using the wheel published on `pypi.org` -Run `pip install gsplat` +You can install the `gsplat` using using the wheel published on `pypi.org` by using +``` +pip install gsplat +``` +The wheel that does not contain the compiled CUDA binaries. The CUDA code is not compiled during the installation when using wheels, and will be compiled at the first import of `gsplat` wich requires `cl.exe` to be on the path (see section bellow documenting how to do this). ### Installation using a clone of the repository @@ -92,7 +81,7 @@ Run `pip install gsplat` ```bash git clone --recursive https://github.com/nerfstudio-project/gsplat.git ``` - MAke sure you do not forget the `--recursive` argument to get the `glm/glm.hpp` file. + Make sure you do not forget the `--recursive` argument to get the `glm/glm.hpp` file. 2. Change into the `gsplat` directory: ```bash @@ -108,7 +97,8 @@ Note: If you an to run the tests or modify the code you will to install the pack ## Run the tests -You will need to clone the gsplat repository locally and install the gsplat package in edit mode using `pip install -e .` for the tests to run because some of the tests assets are not packaged in the package. You will also need to activate the visual C++ environment as described above before running the tests because some of the test use just-in-time compilation to compile code that has not been compiled during the package installation. +You will need to clone the gsplat repository locally and install the gsplat package in edit mode using `pip install -e .` for the tests to run because the tests assets are not packaged in the published package. + Some additional dependencies are required to run all the tests. They can be installed using ``` pip install --no-binary=nerfacc pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 @@ -116,5 +106,28 @@ pip install --no-binary=nerfacc pytest nerfacc git+https://github.com/fraunhofer You can then run the tests using `pytest tests` Notes -* We use `--no-binary=nerfacc` so that the `nerfacc` CUDA code gets compiled during the installation step. Without this argument the nerfacc CUDA code is compiled on the fly during the first import, which requires the visual studio folder executable `cl.exe` to be on the path. +* We use `--no-binary=nerfacc` so that the `nerfacc` CUDA code gets compiled during the installation step. Without this argument the nerfacc CUDA code is compiled on the fly during the first import, which requires the visual studio folder executable `cl.exe` to be on the path (see how to do this bellow). * the test ` tests/test_compression.py::test_png_compression` currently fails due to some problem in kmeans (`ValueError: Cannot take a larger sample than population when 'replace=False'`) + +### Activate the Visual Studio C++ environment + +The installation step from source using `pip install --no-binary=gsplat gsplat` has a mechanism to automatically find the path to the visual studio compiler `cl.exe`, an thus one should not need to manually activate the visual studio environment to add `cl.exe` to the path. However, in case the dependency `nerfacc` used in the tests has been installed using the published wheel instead of the source package or if the installation of `gsplat` has been done from the published wheel using `pip install gsplat`, then you may still need to compile some C++ and CUDA code on the fly at runtime (just-in-time compilation) which requires `cl.exe` to be on the path at runtime. + +In order to have `cl.exe` on the path you can: +1. Navigate to the directory where vcvars64.bat is located. This path might vary depending on your installation. A common path is: + ``` + C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build + ``` + +2. Run the following command: + ``` + ./vcvars64.bat + ``` + If the above command does not work, try activating an older version of VC: + ```bash + ./vcvarsall.bat x64 -vcvars_ver= + ``` + Replace `` with the version of your VC++ compiler toolset. The version number should appear in the same folder. For example `./vcvarsall.bat x64 -vcvars_ver=14.29` + + +3. Check that `cl.exe` is in the path by using `where cl.exe`. From 6131be1fa06caa6bb0fe7bc4f721c564f263111e Mon Sep 17 00:00:00 2001 From: Martin de La Gorce Date: Thu, 22 Aug 2024 14:22:56 +0100 Subject: [PATCH 16/16] Update INSTALL_WIN.md --- docs/INSTALL_WIN.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/INSTALL_WIN.md b/docs/INSTALL_WIN.md index f431569ed..903b8b989 100644 --- a/docs/INSTALL_WIN.md +++ b/docs/INSTALL_WIN.md @@ -41,7 +41,8 @@ variables: ``` Then run `conda env create -f environment.yml` to create the conda environment. - +Note: `pytorch=2.0.0` also works, but some of the tests require `pytorch=2.1.0` to run. + ### 2. Activate your conda environment: Activate your environeent using: @@ -63,9 +64,10 @@ conda activate gsplat We recommand install gsplat from the published source package and not the wheel by using ``` -pip install --no-binary=gsplat gsplat +pip install --no-binary=gsplat gsplat --no-cache-dir ``` -the CUDA code will be compiled during the installation and the cvisual stdio compiler `cl.exe` does not need to be added to the path, because the installation process as an automatic way to find it. +The CUDA code will be compiled during the installation and the cvisual stdio compiler `cl.exe` does not need to be added to the path, because the installation process as an automatic way to find it. +We use `--no-cache-dir` to avoid using a potential wheel from `pypi.org` dowloaded previously that does not have the binaries. ### Installation using the wheel published on `pypi.org` @@ -101,7 +103,8 @@ You will need to clone the gsplat repository locally and install the gsplat pack Some additional dependencies are required to run all the tests. They can be installed using ``` -pip install --no-binary=nerfacc pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 +pip install --no-binary=nerfacc nerfacc --no-cache-dir +pip install pytest nerfacc git+https://github.com/fraunhoferhhi/PLAS.git imageio torchpq cupy-cuda11x==12.3 ``` You can then run the tests using `pytest tests`