Torch.compile fails with C++ compile error: expected identifier before ‘[’ token

Laurent1: <p>Hi,<br>
Using PyTorch 2.4.0 under Linux on CPU, my model runs fine without <code>torch.compile</code><br>
With <code>torch.compile</code>, I got the following error:</p>
<pre><code class="lang-auto">Traceback (most recent call last):

  File "/home/laurent/project/main.py", line 279, in &lt;module&gt;

    main(args)

  File "/home/laurent/project/main.py", line 63, in main

    train_fct(args=args,

  File "/home/laurent/project/train.py", line 299, in train_nn_model

    train_loss, val_loss, test_loss = train(args=args, trial=trial,

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/project/train.py", line 469, in train

    loss, batch_size = forward_backward_pass_model(

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/project/train.py", line 880, in forward_backward_pass_model

    predictions = model(inputs)

                  ^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl

    return self._call_impl(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl

    return forward_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 433, in _fn

    return fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl

    return self._call_impl(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl

    return forward_call(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 1116, in __call__

    return self._torchdynamo_orig_callable(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 948, in __call__

    result = self._inner_convert(

             ^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 472, in __call__

    return _compile(

           ^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_utils_internal.py", line 84, in wrapper_function

    return StrobelightCompileTimeProfiler.profile_compile_time(

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_strobelight/compile_time_profiler.py", line 129, in profile_compile_time

    return func(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 817, in _compile

    guarded_code = compile_inner(code, one_graph, hooks, transform)

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 636, in compile_inner

    out_code = transform_code_object(code, transform)

               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/bytecode_transformation.py", line 1185, in transform_code_object

    transformations(instructions, code_options)

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 178, in _fn

    return fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/convert_frame.py", line 582, in transform

    tracer.run()

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2451, in run

    super().run()

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 893, in run

    while self.step():

          ^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 805, in step

    self.dispatch_table[inst.opcode](self, inst)

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2642, in RETURN_VALUE

    self._return(inst)

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/symbolic_convert.py", line 2627, in _return

    self.output.compile_subgraph(

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/output_graph.py", line 1098, in compile_subgraph

    self.compile_and_call_fx_graph(tx, list(reversed(stack_values)), root)

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/output_graph.py", line 1318, in compile_and_call_fx_graph

    compiled_fn = self.call_user_compiler(gm)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/output_graph.py", line 1409, in call_user_compiler

    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/output_graph.py", line 1390, in call_user_compiler

    compiled_fn = compiler_fn(gm, self.example_inputs())

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/repro/after_dynamo.py", line 129, in __call__

    compiled_gm = compiler_fn(gm, example_inputs)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/__init__.py", line 1951, in __call__

    return compile_fx(model_, inputs_, config_patches=self.config)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/compile_fx.py", line 1505, in compile_fx

    return aot_autograd(

           ^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/backends/common.py", line 69, in __call__

    cg = aot_module_simplified(gm, example_inputs, **self.kwargs)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_functorch/aot_autograd.py", line 954, in aot_module_simplified

    compiled_fn, _ = create_aot_dispatcher_function(

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_functorch/aot_autograd.py", line 687, in create_aot_dispatcher_function

    compiled_fn, fw_metadata = compiler_fn(

                               ^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_functorch/_aot_autograd/jit_compile_runtime_wrappers.py", line 461, in aot_dispatch_autograd

    compiled_fw_func = aot_config.fw_compiler(fw_module, adjusted_flat_args)

                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/compile_fx.py", line 1410, in fw_compiler_base

    return inner_compile(

           ^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/repro/after_aot.py", line 84, in debug_wrapper

    inner_compiled_fn = compiler_fn(gm, example_inputs)

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/debug.py", line 304, in inner

    return fn(*args, **kwargs)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/compile_fx.py", line 527, in compile_fx_inner

    compiled_graph = fx_codegen_and_compile(

                     ^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/contextlib.py", line 81, in inner

    return func(*args, **kwds)

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/compile_fx.py", line 831, in fx_codegen_and_compile

    compiled_fn = graph.compile_to_fn()

                  ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/graph.py", line 1749, in compile_to_fn

    return self.compile_to_module().call

           ^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/graph.py", line 1699, in compile_to_module

    mod = PyCodeCache.load_by_key_path(

          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 3062, in load_by_key_path

    mod = _reload_python_module(key, path)

          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/runtime/compile_tasks.py", line 45, in _reload_python_module

    exec(code, mod.__dict__, mod.__dict__)

  File "/yatmp/scr1/torchinductor_laurent/6z/c6zltwwwixsx6dshpxgxhzat44qrvx7dkcxxniu33cspr2inhgqs.py", line 499, in &lt;module&gt;

    async_compile.wait(globals())

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/async_compile.py", line 247, in wait

    scope[key] = result.result()

                 ^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 3433, in result

    return self.result_fn()

           ^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 2654, in future

    result = get_result()

             ^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 2478, in load_fn

    future.result()

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/concurrent/futures/_base.py", line 456, in result

    return self.__get_result()

           ^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result

    raise self._exception

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/concurrent/futures/thread.py", line 58, in run

    result = self.fn(*self.args, **self.kwargs)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 2504, in _worker_compile_cpp

    compile_file(input_path, output_path, shlex.split(cmd))

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_dynamo/utils.py", line 231, in time_wrapper

    r = func(*args, **kwargs)

        ^^^^^^^^^^^^^^^^^^^^^

  File "/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/_inductor/codecache.py", line 2360, in compile_file

    raise exc.CppCompileError(cmd, output) from e

torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:

CppCompileError: C++ compile error

 

Command:

g++ /yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp -shared -fPIC -Wall -std=c++17 -Wno-unused-variable -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -I/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/include -I/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/include/torch/csrc/api/include -I/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/include/TH -I/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/include/THC -I/home/laurent/python3.11_pytorch2.4/include/python3.11 -L/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/lib -L/home/laurent/python3.11_pytorch2.4/lib -L/home/laurent/python3.11_pytorch2.4/lib/python3.11/site-packages/torch/lib -ltorch -ltorch_cpu -lgomp -ltorch_python -lc10 -mavx2 -mfma -D CPU_CAPABILITY_AVX2 -O3 -DNDEBUG -ffast-math -fno-finite-math-only -fno-unsafe-math-optimizations -ffp-contract=off -march=native -fopenmp -D TORCH_INDUCTOR_CPP_WRAPPER -D C10_USING_CUSTOM_GENERATED_MACROS -o /yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.so

 

Output:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In function ‘T parse_arg(PyObject*, size_t) [with T = long int; PyObject = _object; size_t = long unsigned int]’:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:106:10: error: expected identifier before ‘[’ token

         [[unlikely]] throw std::runtime_error("expected int arg");

          ^

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In lambda function:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:106:22: error: expected ‘{’ before ‘throw’

         [[unlikely]] throw std::runtime_error("expected int arg");

                      ^~~~~

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In function ‘T parse_arg(PyObject*, size_t) [with T = long int; PyObject = _object; size_t = long unsigned int]’:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:106:22: error: expected ‘;’ before ‘throw’

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In function ‘PyObject* kernel_py(PyObject*, PyObject*)’:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:115:14: error: expected identifier before ‘[’ token

             [[unlikely]] throw std::runtime_error("tuple args required");

              ^

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In lambda function:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:115:26: error: expected ‘{’ before ‘throw’

             [[unlikely]] throw std::runtime_error("tuple args required");

                          ^~~~~

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In function ‘PyObject* kernel_py(PyObject*, PyObject*)’:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:115:26: error: expected ‘;’ before ‘throw’

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:117:14: error: expected identifier before ‘[’ token

             [[unlikely]] throw std::runtime_error("requires 10 args");

              ^

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In lambda function:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:117:26: error: expected ‘{’ before ‘throw’

             [[unlikely]] throw std::runtime_error("requires 10 args");

                          ^~~~~

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp: In function ‘PyObject* kernel_py(PyObject*, PyObject*)’:

/yatmp/scr1/torchinductor_laurent/m4/cm4llt7tjnefqnqsjkj2tlli2ips4twifait3zzvm3ed2u6gy5it.cpp:117:26: error: expected ‘;’ before ‘throw’

 

 

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

 

 

You can suppress this exception and fall back to eager by setting:

    import torch._dynamo

    torch._dynamo.config.suppress_errors = True
</code></pre>
<p>I hope there is an obvious cure, otherwise I will try to reduce my code and post it.<br>
Thanks for any help.</p>
<p>Collecting environment information…</p>
<p>PyTorch version: 2.4.0<br>
Is debug build: False<br>
CUDA used to build PyTorch: Could not collect<br>
ROCM used to build PyTorch: N/A</p>
<p>OS: SUSE Linux Enterprise Server 15 SP5 (x86_64)<br>
GCC version: (SUSE Linux) 7.5.0<br>
Clang version: Could not collect<br>
CMake version: version 3.20.4<br>
Libc version: glibc-2.31</p>
<p>Python version: 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:08:17) [GCC 12.2.0] (64-bit runtime)<br>
Python platform: Linux-5.14.21-150500.55.52-default-x86_64-with-glibc2.31<br>
Is CUDA available: False<br>
CUDA runtime version: Could not collect<br>
CUDA_MODULE_LOADING set to: N/A<br>
GPU models and configuration: GPU 0: GRID T4-2B<br>
Nvidia driver version: 470.239.06<br>
cuDNN version: Could not collect<br>
HIP runtime version: N/A<br>
MIOpen runtime version: N/A<br>
Is XNNPACK available: True</p>
<p>CPU:<br>
Architecture:                         x86_64<br>
CPU op-mode(s):                       32-bit, 64-bit<br>
Address sizes:                        45 bits physical, 48 bits virtual<br>
Byte Order:                           Little Endian<br>
CPU(s):                               6<br>
On-line CPU(s) list:                  0-5<br>
Vendor ID:                            GenuineIntel<br>
Model name:                           Intel(R) Xeon(R) Gold 6142 CPU @ 2.60GHz<br>
CPU family:                           6<br>
Model:                                85<br>
Thread(s) per core:                   1<br>
Core(s) per socket:                   1<br>
Socket(s):                            6<br>
Stepping:                             4<br>
BogoMIPS:                             5187.81<br>
Flags:                                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves arat pku ospke md_clear flush_l1d arch_capabilities<br>
Hypervisor vendor:                    VMware<br>
Virtualization type:                  full<br>
L1d cache:                            192 KiB (6 instances)<br>
L1i cache:                            192 KiB (6 instances)<br>
L2 cache:                             6 MiB (6 instances)<br>
L3 cache:                             132 MiB (6 instances)<br>
NUMA node(s):                         1<br>
NUMA node0 CPU(s):                    0-5<br>
Vulnerability Gather data sampling:   Unknown: Dependent on hypervisor status<br>
Vulnerability Itlb multihit:          KVM: Mitigation: VMX unsupported<br>
Vulnerability L1tf:                   Mitigation; PTE Inversion<br>
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT Host state unknown<br>
Vulnerability Meltdown:               Mitigation; PTI<br>
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT Host state unknown<br>
Vulnerability Reg file data sampling: Not affected<br>
Vulnerability Retbleed:               Mitigation; IBRS<br>
Vulnerability Spec rstack overflow:   Not affected<br>
Vulnerability Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl and seccomp<br>
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization<br>
Vulnerability Spectre v2:             Mitigation; IBRS, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected<br>
Vulnerability Srbds:                  Not affected<br>
Vulnerability Tsx async abort:        Not affected</p>
<p>Versions of relevant libraries:<br>
[pip3] numpy==1.26.4<br>
[pip3] pytorch-optimizer==2.11.0<br>
[pip3] torch==2.4.0<br>
[pip3] torch_geometric==2.4.0<br>
[pip3] torchdiffeq==0.2.2<br>
[pip3] torchmetrics==0.11.4<br>
[conda] blas                      1.0                         mkl<br>
[conda] mkl                       2020.1                      217<br>
[conda] mkl-service               2.3.0<br>
[conda] mkl_fft                   1.1.0<br>
[conda] mkl_random                1.1.1<br>
[conda] numpy                     1.18.5<br>
[conda] numpy-base                1.18.5<br>
[conda] numpy-stl                 2.12.0<br>
[conda] numpydoc                  1.1.0</p>

ptrblck: <p>The compiler seems to have issues with <code>[[unlikely]]</code> which is part of C++20 if I’m not mistaken. <a class="mention" href="/u/marksaroufim">@marksaroufim</a> or <a class="mention" href="/u/malfet">@malfet</a> do you know if the C++ standard was recently bumped?</p>

malfet: <p>Hmm, no, we should adhere to C++17 standard for both static as well as generated code.<br>
This looks similar to <a href="https://github.com/pytorch/pytorch/issues/130815" class="inline-onebox" rel="noopener nofollow ugc">[inductor] build failed with gcc8.3 · Issue #130815 · pytorch/pytorch · GitHub</a> issue, give me some time to investigate.</p>
<p>On the other hand, please note, that PyTorch targets gcc-9 or above, as gcc-7.5.x , that you are using, were not fully compliant with c++17 standard</p>

malfet: <p>And here is the fix for the problem: <a href="https://github.com/pytorch/pytorch/pull/130816" class="inline-onebox" rel="noopener nofollow ugc">Replace [[unlikely]] with unlikely(x) by Danielmic · Pull Request #130816 · pytorch/pytorch · GitHub</a></p>

Laurent1: <p>Thanks for the prompt answer.<br>
How do I set the (path to) compiler used by <code>torch.compile</code> ?</p>
<pre><code class="lang-auto">import torch._inductor.config as config
config.cpp.cxx=("/path/to/my/compiler")
</code></pre>
<p>?</p>