Skip to content

Commit

Permalink
WSL 2 support, bump nanobind & drjit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Sep 23, 2024
1 parent 8698699 commit 93f84e9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ This command will also install :monosp:`Dr.Jit` on your system if not already av
See the :ref:`developer guide <sec-compiling>` for complete instructions on building
from the git source tree.

When using the `Windows Subsystem for Linux 2 (WSL2)
<https://learn.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2>`__,
you must follow the :ref:`linked instructions <optix-wsl2>` to enable hardware-accelerated
ray tracing on NVIDIA GPUs.

Requirements
^^^^^^^^^^^^

Expand Down Expand Up @@ -149,5 +154,6 @@ When using Mitsuba 3 in academic projects, please cite:
:hidden:

src/gallery
src/optix_setup
release_notes
zz_bibliography
2 changes: 1 addition & 1 deletion docs/src/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Going further
developer_guide/documentation
developer_guide/variants_cpp
developer_guide/writing_plugin
developer_guide/testing
developer_guide/testing
63 changes: 63 additions & 0 deletions docs/src/optix_setup.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. _optix-wsl2:

Mitsuba on WSL 2
----------------

Mitsuba uses the `NVIDIA OptiX
<https://developer.nvidia.com/rtx/ray-tracing/optix>`__ framework for
hardware-accelerated ray tracing. While OptiX is not yet officially supported
on the `Windows Subsystem for Linux 2 (WSL 2)
<https://learn.microsoft.com/en-us/windows/wsl/compare-versions#whats-new-in-wsl-2>`__,
it *is* possible to get it to run in practice. The following instructions are
based on an NVIDIA `forum post by @dhart
<https://forums.developer.nvidia.com/t/problem-running-optix-7-6-in-wsl/239355/8>`__
Use them at your own risk.

- Determine your driver version using the ``nvidia-smi`` command. This is a number
such as ``560.94`` shown in the middle of the first row.

- Go to the `NVIDA driver webpage <https://www.nvidia.com/en-us/drivers>`__ to
download a similar driver version for Linux (64 bit). You may have to click on
the "New feature branch" tab to find newer driver versions.

- Following this step, you should have file named
``NVIDIA-Linux-x86_64-*.run``. Move it to your WSL home directory but *do
not install it*. Instead, merely extract its contents within a WSL session using
the following command:

.. code-block:: console
$ bash NVIDIA-Linux-x86_64-*.run -x --target driver
Create a symbolic link that exposes the already installed CUDA driver to runtime loading:

.. code-block:: console
$ ln -s /usr/lib/wsl/lib/libcuda.so /usr/lib/x86_64-linux-gnu/
Next, copy-paste and run the following command:

.. code-block:: console
$ mkdir driver-dist && cp driver/libnvoptix.so.* driver-dist/libnvoptix.so.1 && cp driver/libnvidia-ptxjitcompiler.so.* driver-dist/libnvidia-ptxjitcompiler.so.1 && cp driver/libnvidia-rtcore.so.* driver-dist && cp driver/libnvidia-gpucomp.so.* driver-dist && cp driver/nvoptix.bin driver-dist && explorer.exe driver-dist && explorer.exe "C:\Windows\System32\lxss\lib"
This will open two Explorer windows: one to a system path containing internal
WSL driver files (``C:\Windows\System32\lxss\lib``), and another to a newly
created ``driver-dist`` directory containing files that need to be copied to
``C:\Windows\System32\lxss\lib``. Perform this copy manually using Explorer and
overwrite existing files if present. It will warn you that this is dangerous,
and you will need to give permission.

Close all WSL windows, and enter the following command in a ``cmd.exe`` or
PowerShell session:

.. code-block:: pwsh-session
C:\Users\...> wsl --shutdown
Following this, OptiX should be usable within WSL.

.. warning::

Using CUDA and OptiX through WSL degrades performance. Please do not collect
performance data within WSL, since the results will not be representative.
2 changes: 1 addition & 1 deletion ext/nanobind
Submodule nanobind updated 76 files
+109 −2 .github/workflows/ci.yml
+7 −2 .gitignore
+6 −4 CMakeLists.txt
+24 −0 cmake/darwin-ld-cpython.sym
+24 −2 cmake/nanobind-config.cmake
+7 −7 docs/api_bazel.rst
+9 −2 docs/api_cmake.rst
+140 −12 docs/api_core.rst
+126 −33 docs/api_extra.rst
+1 −1 docs/bazel.rst
+131 −11 docs/changelog.rst
+12 −5 docs/classes.rst
+1 −0 docs/faq.rst
+301 −0 docs/free_threaded.rst
+55 −0 docs/functions.rst
+6 −5 docs/index.rst
+9 −2 docs/meson.rst
+450 −310 docs/ndarray.rst
+20 −1 docs/typeslots.rst
+37 −12 docs/why.rst
+3 −1 include/nanobind/eigen/dense.h
+1 −1 include/nanobind/nanobind.h
+15 −6 include/nanobind/nb_accessor.h
+116 −12 include/nanobind/nb_attr.h
+4 −1 include/nanobind/nb_call.h
+6 −16 include/nanobind/nb_cast.h
+27 −12 include/nanobind/nb_class.h
+9 −0 include/nanobind/nb_defs.h
+17 −8 include/nanobind/nb_descr.h
+56 −2 include/nanobind/nb_func.h
+10 −7 include/nanobind/nb_lib.h
+55 −5 include/nanobind/nb_misc.h
+9 −9 include/nanobind/nb_traits.h
+2 −2 include/nanobind/nb_tuple.h
+19 −10 include/nanobind/nb_types.h
+265 −291 include/nanobind/ndarray.h
+2 −2 include/nanobind/stl/bind_map.h
+2 −2 include/nanobind/stl/bind_vector.h
+2 −0 include/nanobind/stl/detail/nb_dict.h
+75 −38 src/common.cpp
+6 −3 src/error.cpp
+10 −6 src/implicit.cpp
+80 −17 src/nb_enum.cpp
+153 −90 src/nb_func.cpp
+115 −46 src/nb_internals.cpp
+162 −16 src/nb_internals.h
+171 −140 src/nb_ndarray.cpp
+20 −4 src/nb_static_property.cpp
+367 −110 src/nb_type.cpp
+10 −4 src/stubgen.py
+17 −7 src/trampoline.cpp
+49 −23 tests/CMakeLists.txt
+1 −3 tests/py_stub_test.py
+2 −2 tests/py_stub_test.pyi
+2 −2 tests/py_stub_test.pyi.ref
+1 −1 tests/test_classes.cpp
+4 −0 tests/test_classes.py
+26 −1 tests/test_enum.cpp
+34 −0 tests/test_enum.py
+49 −0 tests/test_enum_ext.pyi.ref
+2 −2 tests/test_functions.cpp
+0 −1 tests/test_functions.py
+1 −1 tests/test_functions_ext.pyi.ref
+81 −6 tests/test_ndarray.cpp
+176 −42 tests/test_ndarray.py
+36 −9 tests/test_ndarray_ext.pyi.ref
+6 −3 tests/test_stl.cpp
+15 −4 tests/test_stl.py
+1 −1 tests/test_stl_bind_map.cpp
+5 −5 tests/test_stl_bind_map.py
+1 −1 tests/test_stl_bind_vector.cpp
+3 −3 tests/test_stl_bind_vector.py
+37 −0 tests/test_thread.cpp
+100 −0 tests/test_thread.py
+7 −0 tests/test_typing.cpp
+5 −0 tests/test_typing_ext.pyi.ref

0 comments on commit 93f84e9

Please sign in to comment.