shader-slang / slang-torch

A Python package for calling Slang modules from PyTorch.
Other
36 stars 8 forks source link

No cuda file generated #11

Closed randallrvr closed 4 months ago

randallrvr commented 5 months ago

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.
swoods-nv commented 4 months ago

Should be fixed by #4599 (I think?) linked above. Please reopen if this is still an issue.

saipraveenb25 commented 4 months ago

We still need to create a slang release (and then a slang-torch release), so it may be a day or two for the patch to land.