shader-slang / slang-torch Goto Github PK
View Code? Open in Web Editor NEWA Python package for calling Slang modules from PyTorch.
License: MIT License
A Python package for calling Slang modules from PyTorch.
License: MIT License
Hello,
I am trying to run the example here:
and I get the following error message:
ImportError: /usr/local/home/[uname]/miniconda3/envs/slang_torch/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /usr/local/home/[uname]/work/example_slang/.slangtorch_cache/square/44136fa355b3678a/0/_slangtorch_square_44136fa355b3678a.so)
Here is my conda environment:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
bzip2 1.0.8 h5eee18b_6
ca-certificates 2024.3.11 h06a4308_0
expat 2.6.2 h6a678d5_0
filelock 3.14.0 pypi_0 pypi
fsspec 2024.5.0 pypi_0 pypi
hatchling 1.24.2 pypi_0 pypi
jinja2 3.1.4 pypi_0 pypi
ld_impl_linux-64 2.38 h1181459_1
libffi 3.4.4 h6a678d5_1
libgcc-ng 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
libuuid 1.41.5 h5eee18b_0
markupsafe 2.1.5 pypi_0 pypi
mpmath 1.3.0 pypi_0 pypi
ncurses 6.4 h6a678d5_0
networkx 3.3 pypi_0 pypi
ninja 1.11.1.1 pypi_0 pypi
numpy 1.26.4 pypi_0 pypi
nvidia-cublas-cu12 12.1.3.1 pypi_0 pypi
nvidia-cuda-cupti-cu12 12.1.105 pypi_0 pypi
nvidia-cuda-nvrtc-cu12 12.1.105 pypi_0 pypi
nvidia-cuda-runtime-cu12 12.1.105 pypi_0 pypi
nvidia-cudnn-cu12 8.9.2.26 pypi_0 pypi
nvidia-cufft-cu12 11.0.2.54 pypi_0 pypi
nvidia-curand-cu12 10.3.2.106 pypi_0 pypi
nvidia-cusolver-cu12 11.4.5.107 pypi_0 pypi
nvidia-cusparse-cu12 12.1.0.106 pypi_0 pypi
nvidia-nccl-cu12 2.20.5 pypi_0 pypi
nvidia-nvjitlink-cu12 12.4.127 pypi_0 pypi
nvidia-nvtx-cu12 12.1.105 pypi_0 pypi
openssl 3.0.13 h7f8727e_1
packaging 24.0 pypi_0 pypi
pathspec 0.12.1 pypi_0 pypi
pillow 10.3.0 pypi_0 pypi
pip 24.0 py312h06a4308_0
pluggy 1.5.0 pypi_0 pypi
python 3.12.3 h996f2a0_1
readline 8.2 h5eee18b_0
setuptools 69.5.1 py312h06a4308_0
slangtorch 1.2.0 pypi_0 pypi
sqlite 3.45.3 h5eee18b_0
sympy 1.12 pypi_0 pypi
tk 8.6.14 h39e8969_0
torch 2.3.0 pypi_0 pypi
torchaudio 2.3.0 pypi_0 pypi
torchvision 0.18.0 pypi_0 pypi
trove-classifiers 2024.5.17 pypi_0 pypi
typing-extensions 4.11.0 pypi_0 pypi
tzdata 2024a h04d1e81_0
wheel 0.43.0 py312h06a4308_0
xz 5.4.6 h5eee18b_1
zlib 1.2.13 h5eee18b_1
my gcc version
gcc (Debian 13.2.0-10) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
and my cuda-toolkit:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0
Seems to me that the libstdc++.so.6 that comes with torchslang is doesn't have 3.4.32 but that is a bit wierd because if I do:
ldd --version
I get:
ldd (Debian GLIBC 2.37-18+gl0) 2.37
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
Which is not 3.4.32
There desperately needs to be some documentation on setting up a working slangtorch environment with CUDA and pytorch that is a bit more detailed than "pip install slangtorch"
Hello,
when I try to run the first example in https://shader-slang.com/slang/user-guide/a1-02-slangpy.html,
I get following message
C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\torch\utils\cpp_extension.py:1967: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
Traceback (most recent call last):
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\torch\utils\cpp_extension.py", line 2107, in _run_ninja_build
subprocess.run(
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\WorkSpace\slangTest\111.py", line 4, in <module>
m = slangtorch.loadModule('square.slang')
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\slangtorch\slangtorch.py", line 616, in loadModule
rawModule = _loadModule(fileName, moduleName, buildDir, options, sourceDir=outputFolder, verbose=verbose, includePaths=includePaths, dryRun=False)
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\slangtorch\slangtorch.py", line 535, in _loadModule
slangLib, metadata = compileAndLoadModule(
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\slangtorch\slangtorch.py", line 426, in compileAndLoadModule
slangLib = _compileAndLoadModule(metadata, sources, moduleName, buildDir, slangSourceDir, verbose)
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\slangtorch\slangtorch.py", line 465, in _compileAndLoadModule
return jit_compile(
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\slangtorch\util\compile.py", line 71, in jit_compile
_write_ninja_file_and_build_library(
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\torch\utils\cpp_extension.py", line 1832, in _write_ninja_file_and_build_library
_run_ninja_build(
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\site-packages\torch\utils\cpp_extension.py", line 2122, in _run_ninja_build
message += f": {error.output.decode(*SUBPROCESS_DECODE_ARGS)}" # type: ignore[union-attr]
File "C:\Users\Dell\.conda\envs\surfel_splatting\lib\encodings\oem.py", line 15, in decode
return oem_decode(input, errors, True)
UnicodeDecodeError: 'cp1' codec can't decode bytes in position 0--1: No mapping for the Unicode character exists in the target code page.
My torch
version is 2.3.0, cuda
version is 12.0.
As I understand from the documents, this package only works with CUDA.
The question is, when can we expect other GPUs be supported such as Intel and AMD? (using slang's Vulkan backend for example).
Slang does not appear to be generating any cuda files from the .slang sources, which then causes a ReadFile error as it tries to compile a cuda object file from nonexistent cuda sources.
(base) PS C:\Users\rrauwend\slang-examples\fwd-rasterizer-example> python .\rasterizer2d.py
C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\utils\cpp_extension.py:1967: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation.
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
warnings.warn(
Traceback (most recent call last):
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\utils\cpp_extension.py", line 2107, in _run_ninja_build
subprocess.run(
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\rrauwend\slang-examples\fwd-rasterizer-example\rasterizer2d.py", line 7, in <module>
rasterizer2d = slangtorch.loadModule("rasterizer2d.slang")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\slangtorch\slangtorch.py", line 616, in loadModule
rawModule = _loadModule(fileName, moduleName, buildDir, options, sourceDir=outputFolder, verbose=verbose, includePaths=includePaths, dryRun=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\slangtorch\slangtorch.py", line 535, in _loadModule
slangLib, metadata = compileAndLoadModule(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\slangtorch\slangtorch.py", line 426, in compileAndLoadModule
slangLib = _compileAndLoadModule(metadata, sources, moduleName, buildDir, slangSourceDir, verbose)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\slangtorch\slangtorch.py", line 465, in _compileAndLoadModule
return jit_compile(
^^^^^^^^^^^^
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\slangtorch\util\compile.py", line 71, in jit_compile
_write_ninja_file_and_build_library(
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\utils\cpp_extension.py", line 1832, in _write_ninja_file_and_build_library
_run_ninja_build(
File "C:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\utils\cpp_extension.py", line 2123, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension '_slangtorch_rasterizer2d_44136fa355b3678a': [1/3] C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA\v12.1\bin\nvcc --generate-dependencies-with-compile --dependency-output rasterizer2d_cuda.cuda.o.d -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcompiler /EHsc -Xcompiler /wd4068 -Xcompiler /wd4067 -Xcompiler /wd4624 -Xcompiler /wd4190 -Xcompiler /wd4018 -Xcompiler /wd4275 -Xcompiler /wd4267 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4819 -Xcompiler /MD -DTORCH_EXTENSION_NAME=_slangtorch_rasterizer2d_44136fa355b3678a -DTORCH_API_INCLUDE_EXTENSION_H -IC:\Users\rrauwend\slang-examples\fwd-rasterizer-example -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\TH -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\THC "-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA\v12.1\include" -IC:\Users\rrauwend\AppData\Local\anaconda3\Include -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++17 --std=c++17 -c C:\Users\rrauwend\slang-examples\fwd-rasterizer-example\.slangtorch_cache\rasterizer2d\44136fa355b3678a\rasterizer2d_cuda.cu -o rasterizer2d_cuda.cuda.o
FAILED: rasterizer2d_cuda.cuda.o
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA\v12.1\bin\nvcc --generate-dependencies-with-compile --dependency-output rasterizer2d_cuda.cuda.o.d -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcompiler /EHsc -Xcompiler /wd4068 -Xcompiler /wd4067 -Xcompiler /wd4624 -Xcompiler /wd4190 -Xcompiler /wd4018 -Xcompiler /wd4275 -Xcompiler /wd4267 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4819 -Xcompiler /MD -DTORCH_EXTENSION_NAME=_slangtorch_rasterizer2d_44136fa355b3678a -DTORCH_API_INCLUDE_EXTENSION_H -IC:\Users\rrauwend\slang-examples\fwd-rasterizer-example -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\TH -IC:\Users\rrauwend\AppData\Local\anaconda3\Lib\site-packages\torch\include\THC "-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA\v12.1\include" -IC:\Users\rrauwend\AppData\Local\anaconda3\Include -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATninja: fatal: ReadFile: The handle is invalid.
ORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++17 --std=c++17 -c C:\Users\rrauwend\slang-examples\fwd-rasterizer-example\.slangtorch_cache\rasterizer2d\44136fa355b3678a\rasterizer2d_cuda.cu -o rasterizer2d_cuda.cuda.o
CreateProcess failed: The system cannot find the file specified.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.